Programming in C# with CIMConnect
The software development work to make a GEM interface is very easy with CIMConnect. Using a simple wrapper class, you can implement a powerful GEM interface with only a few lines of code. Below are some examples of typical development. For a CIMConnect demo, or more information, click the button below.
References the Cimetrix libraries:
Initialize CIMConnect & Load the setup file:
CMyCimetrix.Initialize("Company.Equipment.epj");
When done initializing, turn on the GEM interface:
_CMyCimetrix.InitializeFinal();
How to handle collection events:
Setup file:
101=CE1,Collection event with no data variables,,
102=CE2,Collection event with data variables,,L {A DV1} {A DV2}
101=DV1,Example user defined data variable.,,DV,U4,,0,0,,,U4,
102=DV2,Example user defined data variable.,,DV,U4,,0,0,,,U4,
Programming:
CMyCimetrix.SendCollectionEvent("CE1");
var dataNames = new string[] { "DV1", "DV2" };
var dataValues = new CxValue[] { new U4Value((uint)_eventCounter), new U4Value((uint)_Random.Next()) };
_CMyCimetrix.SendCollectionEventWithData(0, dataNames, dataValues, "CE2");
How to handle status variables:
Setup file:
201=SV1,Description of SV1.,,SV,F8,,0,0,F8 5.50,F8 1000.99,F8 6.22,
202=SV2,Description of SV2.,,SV,A,,0,0,,,A
,
203=SV3,Description of SV3,,SV,Bo,,0,0,,,Bo,
204=SV4,Description of SV4,,SV,U4,,0,0,U4 100,U4 10000,U4 500,
205=SV5,Description of SV5,,SV,U4,,0,0,U4 100,U4 10000,U4 500,
206=SV6,Description of SV6,,SV,U4,,0,0,U4 100,U4 10000,U4 500,
Programming, using caching
CMyCimetrix.CacheVariable("SV1", _Random.NextDouble() * 1000);
var statusDataNames = new string[3];
statusDataNames[0] = "SV2";
statusDataNames[1] = "SV3";
statusDataNames[2] = "SV4";
var statusDataValues = new CxValue[3];
statusDataValues[0] = new AValue(_Random.Next().ToString());
statusDataValues[1] = new BoValue(_currentCycle % 2 == 0);
statusDataValues[2] = new U4Value((uint)_Random.Next());
_CMyCimetrix.CacheVariables(0, statusDataNames, statusDataValues);
How to program Remote Commands. There is no work in the setup file.
var commandDescription = "Select Recipe for execution with a PPID argument.";
_CMyCimetrix._CxClientClerk.RegisterCommandHandler("PPSELECT", ref commandDescription, _CMyCimetrix);
void CMyCIMConnect_RemoteCommandHandler(object sender, CMyCimetrix.RemoteCommandArgs e)
{
switch (e.Command)
{
case "PPSELECT":
// Implementation of PPSELECT
SECS-II Message Logging is implemented using SEMI E173 standard called XML SECS-II Message Notation (SMN)
Here is a short example of what this looks like:
<SECSMessage s="1" f="13" direction="E to H" replyBit="True" txid="45" time="2019-03-07T10:57:08.630-08:00">
<LST>
<ASC>MODEL</ASC>
<ASC>00.01</ASC>
</LST>
</SECSMessage>
<SECSMessage s="1" f="14" direction="H to E" replyBit="False" txid="45" time="2019-03-07T10:57:08.875-08:00">
<LST>
<BIN>0</BIN>
<LST />
</LST>
</SECSMessage>
<SECSMessage s="6" f="11" direction="E to H" replyBit="True" txid="51" time="2019-03-07T10:57:09.956-08:00">
<LST>
<UI4>25</UI4>
<UI4>101</UI4>
<LST>
<LST>
<UI4>11</UI4>
<LST>
<UI4>8</UI4>
<UI4>1626018047</UI4>
<FP8>4.45764763022663430000e+002</FP8>
<ASC>1118746803</ASC>
<BOO>1</BOO>
<UI4>500</UI4>
<UI4>0</UI4>
<UI4>9</UI4>
<ASC>2019-03-07T18:57:09.918Z</ASC>
</LST>
</LST>
</LST>
</LST>
</SECSMessage>
<SECSMessage s="6" f="12" direction="H to E" replyBit="False" txid="51" time="2019-03-07T10:57:09.980-08:00">
<BIN>0</BIN>
</SECSMessage>