# Secs-Gem and Dynamic States

**URL:** <https://community.criticalmanufacturing.com/t/secs-gem-and-dynamic-states/412>\
**Category:** Blog\
**Created:** [February 27, 2025, 12:00am UTC](https://community.criticalmanufacturing.com/t/secs-gem-and-dynamic-states/412 "2025-02-27T00:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joao\_Roque](https://yyz2.discourse-cdn.com/flex050/user_avatar/community.criticalmanufacturing.com/joao_roque/32/24_2.png) [@Joao\_Roque](https://community.criticalmanufacturing.com/u/Joao_Roque)\
**Post date:** [February 27, 2025, 12:00am UTC](https://community.criticalmanufacturing.com/t/secs-gem-and-dynamic-states/412/1 "2025-02-27T00:00:00Z")

</div>

![Secs-Gem and Dynamic States](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/19f1d0afcd28391c84434cea4956bc5482197323.png)

This post is about a twist on a popular tutorial.

# Tutorial SecsGem

One of the most common protocols for the semi-conductor area is Secs-Gem. Secs-Gem is a very robust and reliable protocol with a standardized format.

One simple example that showcases how `Connect IoT` handles secs-gem is a change of state model of a machine (i.e `MES Resource`).

It’s common that a machine has a state model different from the standard SEMI E-10. Sometimes the machine offers more states or most often than not, the machine is only able to partially achieve the SEMI E-10. The MES is able to work with the machine integration to offer a fuller view of what is happening in the machine.

This tutorial is an example where we have a secs-gem machine that as a mapping of integers from 1-6 to SEMI E10 States. The integration must connect to the machine, listen to an event and correctly change the states of the machine. CM’s tutorial on this is very extensive, I will give a quick recap.

* * *

## Create an Automation Protocol

An `Automation Protocol` is responsible for creating the base configuration for a transport protocol. All driver definitions inherit their settings from the automation protocol. Most of the settings can also be changed in the controller, via the equipment configuration task.

![Secs Gem Automation Protocol](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/5afde0657133dd89d622a1a0340d3ac58377e2a7.png)

 **Info:** The technical specification of the vendor is very important in understanding how to setup each particular protocol setting.

* * *

## Create an Automation Driver Definition

The `Automation Driver Definition` will be where we map the relevant fields of the specification. Here is where we will configure all the events that we want to listen or commands that we want to execute.

The tutorial has a very simple example of of collecting the change of status, so let’s imagine a very simple specification:

| VID | VID Type | Format | Name | Description |
| --- | --- | --- | --- | --- |
| 2011 | SV | U1 | Process status | Indicates the current process status of the equipment |

Table: VID Property

| CEID | Description/Trigger | RPTID |
| --- | --- | --- |
| 1000 | Occurs when the equipment process status changes | 2 |

Table: CEID Property

| Equipment Status | MES Resource SEMI E10 State |
| --- | --- |
| 1 | Nonscheduled |
| 2 | Unscheduled Down |
| 3 | Scheduled Down |
| 4 | Engineering |
| 5 | Standby |
| 6 | Productive |

Table: Mapping SEMI E10 Resource State to a property

In our example, we have to create a property:

![Secs Gem Automation Driver Definition Property](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/dc164813a2727506f23781e8d2e663a21ac86292.png)

An event:

![Secs Gem Automation Driver Definition Event](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/4ad1f74efd46c245e4c9acbb5b7c225c4f2879ae.png)

And the link between properties and events, for secs-gem this is very important as properties are grouped in reports and reports are associated to events:

![Secs Gem Automation Driver Definition Event Property](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/da61fe33369dbbb98717ebed80166419e2926cd8.png)

* * *

## Create an Automation Controller

The tutorial presents the following solution to this problem:

![Secs Gem Workflow State Changed](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/0098715aaac06d7ee63dda09056fff9c612c3da4.png)

The solution is a workflow that will receive the event `Status Changed` with a single property `Status`, it will collect the entity instance linked to this integration (for example `Etch 01`) and will convert the machine value to SEMI E10 status with a switch and called the `Adjust State` task which will change the status of the Resource in the MES.

![Secs Gem Tutorial](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/de34e9f0431bde498b641f50c408c759a1c2fe3f.gif)

This solution is quite valid, but it lack some dynamism. It is very tailored to narrow use case.

Let’s try and find out a better solution for this.

* * *

## Dynamic State Control

As we saw the integration was fully defined in the workflow. One way we can achieve a more flexible approach is with the use of a smart table.

A smart table allows us to have a context based definition of states. We can have states that are managed by a subset of resource type or by resource or by any other contextual inference we may want.

For these types of use cases, the most common one’s are by resource type, this way we can have a topology of integrations. For example, if all the etching machines behave the same way for their state model, we can have a resource type be `Etching`, if for example we have a different type of machines that have the same use case of state management but are `CNC` we can leverage the same configuration table to orchestrate all the state management between the machine and the MES.

### Create a Smart Table

For this example I created a simple table with three keys, `Resource`, `ResourceType` and `Machine Status` and a value which is the `SEMIE10Status`. My precedence rules are quite simple, if we have a `Resource` key that is the one with the most precedence, followed by `Resource Type`.

![Machine State Table Resolution](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/58e08f35e9cf2d181b76d40bf0b1d5d10010de31.png)

### Adding the Mapping

The `Etch-01` resource has a resource type of type `General`. We can add that mapping in our smart table:

![Machine State Table Resolution Mapping](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/7ed440a51fc17da42ab4dbed3a6d88e35a5bb6e1.png)

Now even across different Automation Controllers of different machines, they are able to leverage this table.

### Changing the Workflow

In my workflow, I can now replace all the switch logic with a invocation to the smart table:

![Secs Gem Workflow State Changed](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/2c261b22e7b4bc766da3da1ccfc05b9a617b4c35.png)

Notice how this is a very minor change, we replace the switch with a call to the smart table.

![Secs Gem Tutorial](https://canada1.discourse-cdn.com/flex050/uploads/community_criticalmanufacturing/original/1X/e8450ef96245ebab795d9993279a34c5adc59920.gif)

We could even have states that are machine specific and states that impact a whole set of resource types, you can now play around with this idea to best suite your integration.

Take note of how a simple tweak in architecture can transform a solution from being very narrow and covering only one integration to one that leverages the MES for cross-integration.

 **Info:** You can find the project used for this demo at [SecsGem-Dynamic](https://github.com/jrk94/cm-demo-repos/tree/main/SecsGem-Dynamic)

Thank you for reading !!!

* * *
This is a companion discussion topic for the original entry at [https://j-roque.com/posts/20250227-secsgem/](https://j-roque.com/posts/20250227-secsgem/)
