Hello Guest it is March 28, 2024, 04:29:58 PM

Author Topic: Mach 3/4 Autoload and execute control from external program.  (Read 7285 times)

0 Members and 1 Guest are viewing this topic.

Offline CWare

*
  •  14 14
    • View Profile
Re: Mach 3/4 Autoload and execute control from external program.
« Reply #10 on: March 14, 2016, 01:03:51 PM »
Thanks a lot for replying,
I guess its the
procedure LoadRun(const FileName: WideString);

I havent done anything in pascal though its not familiar.

 where can i find documentation for it or a sample program would be awesome?
« Last Edit: March 14, 2016, 01:13:23 PM by CWare »
Re: Mach 3/4 Autoload and execute control from external program.
« Reply #11 on: March 14, 2016, 01:18:19 PM »
The mach3 sdk can be downloaded here:


http://www.machsupport.com/software/downloads-updates/

Contains .h files and some examples but I don't know of any manuals.

If your development environment has the ability to import a type library that will create the wrapper for you.

Offline CWare

*
  •  14 14
    • View Profile
Re: Mach 3/4 Autoload and execute control from external program.
« Reply #12 on: March 15, 2016, 12:53:14 PM »
Ok seems this is a bit above my experience level.
I'm not familiar with the way vs creates dialogs. I use qt for gui's if needed.
Writing to registry is also something unfamiliar.
Well eh you get the picture.
I was hoping to be able to use the methods in the headers to establish communication.

I found your thread
https://www.machsupport.com/forum/index.php?topic=11240.0
Installed it.
unfortunately it's expired?

Saw on your yt channel what it does...

You've done exactly what I look for .
I'm still a bit confused though to how you did it and how this works.


Installed vs2010  yesterday which isn't the right one but at least I see the project tree of the sdk plugin.
Watched the video of I believe Jerry on creating a plugin.


You didn't seem to need a plugin.
Your program asks for the mach.exe and the xml?


Found this online
COM clients are applications that make use of a COM object implemented by another application Automation Servers (Automation controllers) and applications that host an ActiveX control (ActiveX containers).

To make information about the COM server available to your client application, you must import the information about the server that is stored in the server's type library. Your application can then use the resulting generated classes to control the server object.

You wrote
"If your development environment has the ability to import a type library that will create the wrapper for you."
searched wrapper
so you took the mach. exe and wrapped it in a class?

I haven't done anything like that
Also what is that machremote example doing.
This seems to connect

Code: [Select]
void CMachRemoteDlg::OnBnClickedConnect()
{
LPUNKNOWN lpUnk;
LPDISPATCH lpDispatch;
COleException e;
HRESULT res;

if (CLSIDFromProgID(OLESTR("Mach4.Document"), &clsid) != NOERROR)
{
   return;
}
    if (res = GetActiveObject( clsid, NULL, &lpUnk) == NOERROR)
{
HRESULT hr = lpUnk->QueryInterface(IID_IDispatch,
(LPVOID*)&lpDispatch);
lpUnk->Release();
if (hr == NOERROR)
{
mach4.AttachDispatch(lpDispatch, TRUE);
lpDispatch = mach4.GetScriptDispatch();
scripter.AttachDispatch(lpDispatch, TRUE);
}
    connected = true;
m_Status = "Connected to Mach3.";
UpdateData(false);
SetTimer( 1, 200, NULL );
return ;
}

m_Status = "No Connection to Mach3.";
UpdateData(false);

}

Am I correct that there are 3ways to do something similar.

1 plugin.
2 some remote access.
3 wrapper com

trying to figure out which one the easiest is to implement without using vs.


« Last Edit: March 15, 2016, 12:59:39 PM by CWare »

Offline CWare

*
  •  14 14
    • View Profile
Re: Mach 3/4 Autoload and execute control from external program.
« Reply #13 on: March 15, 2016, 01:41:24 PM »
Figured out something more

plugin = a dll that loads at runtime. The code in the dll is executed in the update loop of mach I guess.

That MachRemote application uses OLE https://en.wikipedia.org/wiki/Object_Linking_and_Embedding  to communicate.
I guess that means mach must be active in the background.

Could you show me how to make a wrapper for mach?
You showed mach's dro's updated when you changed values from from machme. What is going on there? Was machme altering some files which mach also reads or was it the mach gui and machme gui loaded together.
Later when you closed mach machme was still operational?

Re: Mach 3/4 Autoload and execute control from external program.
« Reply #14 on: March 15, 2016, 04:01:42 PM »
Ok, that's a lot of questions!  Many of the answers depend upon what your are really trying to do and what programming environment you will use.  You stated that you wanted to be able to control monitor a file for changes.  This can be done with a plugin.  Mach polls your plugin every so often and your plugin(dll) could be checking to see if the date changed and tell mach to load and run a file.

The code (C or C++) that you referenced above shows how to create a connection to Mach and get a reference to a mach object that connects to the running Mach3 program.  Once  you have that object you can query and set various properties and objects within the running Mach3 program.  The Programmer Reference pdf has all of the calls and their parameters and returns.  It has been years since I programmed in C and each IDE has different capabilites so I can't help you there.

My program (Delphi Object Pascal) checks to see if Mach is a running and if not loads it.  My program initially asks for the Mach3.exe file location and saves that to an ini file.  It also asks for the mach profile you want to load (mach3mill.xml or turn.xml or whatever you named your active profile) so that it can load the program with the appropriate profile and saves that as well.

It then creates a IMyScriptObject that connects to Mach.  I extended the class by creating an inherited class object (wrapper) that does all of this and simplifies certain tasks.  For example have a property xDro that so that I can program xDro:=2.5 or set a variable myVar:=xDro instead of setOEMdro(800,2.5) or myVar:=getOEMdro(800).

The gui is the most complicated item to implement including threads that must be syncronized to update my displays.  So to answer your question I am simply reading the values and updating my gui just as mach is updating its gui.  Possible but not necessary for what you are trying to do.  MachMe has to have a running version of Mach to operate on, it just hid Mach's GUI.

Offline CWare

*
  •  14 14
    • View Profile
Re: Mach 3/4 Autoload and execute control from external program.
« Reply #15 on: March 17, 2016, 01:55:13 PM »
Thanks a bunch for clearing that up.
I should be able to manage with that much info.
I'll take it from here and try to write a console application in code::blocks if I manage i'll post it here.

cheers

Offline CWare

*
  •  14 14
    • View Profile