gem300_scripts

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gem300_scripts [2024/02/01 14:25]
wikiadmin
gem300_scripts [2024/09/19 14:54] (current)
wikiadmin
Line 173: Line 173:
  }  }
 </code> </code>
-        +==== E40 Python Example ==== 
 +<code python> 
 +#!/usr/bin/python3 
 +import jpype 
 +from jpype import JProxy, JArray, JInt 
 +import jpype.imports 
 +from jpype.types import * 
 + 
 +jpype.startJVM(classpath=['.', './GEMTool.jar']) 
 + 
 +# Importing the necessary Java classes 
 +from com.ergotech.secs.e39 import E39MessageHandler 
 +from com.ergotech.secs.e40 import E40MessageHandler, E40ServiceWrapper, E40CallbackInterface, ProcessJob 
 +from com.ergotech.transsecs.secs import TransSecsController 
 +from java.lang import Thread 
 + 
 +# Create the callback interface using a proxy 
 +class E40CallbackImplementation(E40CallbackInterface): 
 +    def prStateChange(self, prJob, oldState, newState): 
 +        print(f"State Change for {prJob.getPrJobId()} From: {ProcessJob.getStateName(oldState)} to {ProcessJob.getStateName(newState)}"
 +        # Send the new state for the process job to the PLC 
 +        # /GEM300PLC/ProcessJobId->setStringValue(prJob.getPrJobId()); 
 +        # /GEM300PLC/CurrentProcessJobState->setIntValue(newState); 
 + 
 +    def prJobCreate(self, prJob): 
 +        print(f"Job Creation of {prJob.getPrJobId()} permitted"
 +        # Indicate that this job is not allocated 
 +        # /GEM300PLC/Allocated->setIntValue(0); 
 +        # Record the id 
 +        # /GEM300PLC/ProcessJobId->setStringValue(prJob.getPrJobId()); 
 + 
 +    def prSetRecipeVariable(self, prJob, recVarList): 
 +        if recVarList is not None: 
 +            for counter in range(recVarList.size()): 
 +                print(f"Host Requested Recipe Variable \"{recVarList.get(counter).getStringValue()}\" on {prJob}"
 + 
 +    def prSetMtrlOrder(self, prCurrentMtrlOrder, prNewMtrlOrder): 
 +        # Set the order in which process jobs should be processed 
 +        pass 
 + 
 +    def prCommandCallback(self, prJob, prCmd, prCmdParameterList): 
 +        print(f"Host Requested \"{prCmd}\" on {prJob} with parameters {prCmdParameterList}"
 +        cmds = ['NONE', 'ABORT', 'STOP', 'CANCEL', 'PAUSE', 'RESUME', 'STARTPROCESS'
 +        # First indicate which process job the command is being executed on 
 +        # /GEM300PLC/ProcessJobId->setStringValue(prJob.getPrJobId()); 
 + 
 +        if prCmdParameterList is not None: 
 +            for counter in range(prCmdParameterList.size()): 
 +                print(f"Host Requested Parameter \"{prCmdParameterList.get(counter).getStringValue()}\" on {prJob}"
 + 
 +        # Get the index of the command 
 +        cmdId = cmds.index(prCmd) 
 +        # /GEM300PLC/PrCmd->setIntValue(cmdId); 
 + 
 +# Instantiate the callback 
 +E40Callback = E40CallbackImplementation() 
 + 
 +# Main Python code 
 +print("Register GEM300"
 + 
 +controller = None 
 +while controller is None: 
 +    Thread.sleep(50)  # wait 50 ms 
 +    controller = TransSecsController.findController("GEM300PLCTool"
 + 
 +try: 
 +    E39MessageHandler.addMessageHandler(controller.getControllerName()) 
 +    E40MessageHandler.addMessageHandler() 
 +except Exception as e: 
 +    print(e) 
 + 
 +# Register the callback 
 +E40ServiceWrapper.getInstance().registerCallback(E40Callback) 
 + 
 +print("E40 Registered"
 + 
 +</code>
 ==== E94 ==== ==== E94 ====
  
Line 180: Line 256:
 === E94 Service Wrapper === === E94 Service Wrapper ===
  
-The E94 Service Wrapper provides access to control the flow of E94, however there are not actions required by the tool controller to manage a control job.+The E94 Service Wrapper provides access to control the flow of E94, however there are no actions required by the tool controller to manage a control job.
  
 === E94 Callback Interface === === E94 Callback Interface ===
  • gem300_scripts.1706819100.txt.gz
  • Last modified: 2024/02/01 14:25
  • by wikiadmin