top of page

Adding SECS/GEM to your Equipment or Tool.

This short article shows how to integrate SecsToHost.Net to your equipment application software using Visual C#.

Adding SECS/GEM capabilities into your equipment controller doesn't need to be complicated. With SecsToHost.Net, it simply means 3 easy steps (with minimum coding) to accomplish it with less than an hour!


Step #1 - Dynamic Configuration


Use Model Builder (included in the SDK) to add or define equipment parameters (such as Status Variables, Discrete Variables or Equipment Constants/Settings), Events, Alarms, Remote/Host Commands, etc.

You can add as many GEM data items and these configurations are saved to the EquipmentTemplate.xml file. (file name can be changed)


To follow through the example in this article, you need to define these GEM data items:

  1. StatusVariables: add "Pressure" and "Temperature"

  2. CEIDs: add "SensorDataChanged"

  3. Alarms: add "Alarm1"

All the GEM data item ID will be automatically generated

Step #2 - Integrate SecsToHost.Net DLLs to your application


After you have defined all the required GEM data items in step 1, add these DLLs to your project reference.







Initialize the GEMController object with the EquipmentTemplate.xml that was generated in step 1.

private GEMController gemController;

private void InitializeSecsToHost() 
{
	gemController = new GEMController();
			
	try 
	{
       // Subscribe to the Communication state transition event
        gemController.CommunicationStateChanged += OnCommunicationStateChanged;

        // Subscribe to the GEM control state transition event
        gemController.ControlStateChanged += OnControlStateChanged;

        // Subscribe to the GEM Remote Command sent by Host (S2F21, S2F41, S2F49)
        gemController.RemoteCommandIn += OnRemoteCommandIn;

        // Subscribe to the GEM Recipe Download Inquire (S7F1)
        gemController.RecipeDownloadInquired += OnRecipeDownloadInquired;

        // Subscribe to the GEM Recipe Download (S7F3) sent by Host
        gemController.RecipeDownloadReceived += OnRecipeDownloadReceived;

        // Subscribe to the GEM Recipe Upload Request (S7F5)
        gemController.RecipeUploadRequested += OnRecipeUploadRequested;

        // Subscribe to the GEM Terminal Message (S10F3) sent by Host.
        gemController.TerminalMessageReceived += OnTerminalMessageReceived;

	  // Initialize GEM Controller
        gemController.Initialize("EquipmentTemplate.xml", @"C:\Temp");
                
     }
    catch (Exception ex) 
    {
       Logger("Error: Failed to initialize SecsToHost.Net");
	}
}

The codes above gemController.Initialize method takes in the EquipmentTemplate.xml file to load the GEM data items at runtime.


Whenever the equipment's parameter value changes, you call the gemController.SetAttribute method to update its value.

For example to update parameter "Pressure" and "Temperature":

// Update the SVID: Pressure
gemController.SetAttribute("Pressure", AttributeType.SV, "89");

// Update the SVID: Temperature
gemController.SetAttribute("Temperature", AttributeType.SV, "122.8");

To send event notification to the Host:

// Raise CEID: SensorDataChanged event notification to the Host
gemController.SendCollectionEvent("SensorDataChanged");

To raise alarm or clear alarm notification to the Host:

// Raise ALID: Alarm1: sending alarm set notification to the Host
gemController.SetAlarm("Alarm1");

// Clear ALID: Alarm1: sending alarm clear notification to the Host
gemController.ClearAlarm("Alarm1");

To receive recipe download from the Host, first subscribe to the RecipeDownloadReceived callback:

// Subscribe to the GEM Recipe Download (S7F3) sent by Host
gemController.RecipeDownloadReceived += OnRecipeDownloadReceived;

Retrieve the recipeId and recipeBody parameters in the OnRecipeDownloadReceived event handler:

private void OnRecipeDownloadReceived(object sender, RecipeEventArgs<ACKC7> e)
{
    string recipeId = e.RecipeId;
    byte[] binPPBody = e.GetRecipeBody<byte[]>();

    // Send S7F4 ack to Host.
    e.SetReply(ACKC7.Accepted);
} 


Step #3 - Test your GEM application with SWIFT Simulator


SWIFT simulator is another utility comes with the SDK and can be used to simulate the HOST.


Run the SWIFT simulator as HOST to test your newly created GEM application:

Once your GEM application call these codes:

// Update the SVID: Pressure
gemController.SetAttribute("Pressure", AttributeType.SV, "89");

// Update the SVID: Temperature
gemController.SetAttribute("Temperature", AttributeType.SV, "122.8");

In SWIFT simulator, send the S1F3 to query the value of "Pressure (SVID: 1016)" and "Temperature (SVID: 1017)" and GEMController will reply the S1F4 seamlessly for you.







690 views0 comments

Recent Posts

See All

Commentaires


Les commentaires ont été désactivés.
bottom of page