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 [2021/07/12 18:31]
wikiadmin
gem300_scripts [2025/02/28 20:17] (current)
wikiadmin
Line 80: Line 80:
   print ("State Change for " + prJob.getPrJobId() + " From: " + ProcessJob.getStateName(oldState) + " to " + ProcessJob.getStateName(newState));   print ("State Change for " + prJob.getPrJobId() + " From: " + ProcessJob.getStateName(oldState) + " to " + ProcessJob.getStateName(newState));
   // send the new state for the process job to the PLC   // send the new state for the process job to the PLC
-  /E40PLC/ProcessJobId->setStringValue(prJob.getPrJobId()); +  /GEM300PLC/ProcessJobId->setStringValue(prJob.getPrJobId()); 
-  /E40PLC/CurrentProcessJobState->setIntValue(newState);+  /GEM300PLC/CurrentProcessJobState->setIntValue(newState);
  },  },
  prJobCreate : function (prJob) {  prJobCreate : function (prJob) {
Line 89: Line 89:
    print ("Job Creation of " + prJob.getPrJobId() + " permitted");    print ("Job Creation of " + prJob.getPrJobId() + " permitted");
    // indicate that this job is not allocated    // indicate that this job is not allocated
-   /E40PLC/Allocated->setIntValue(0);+   /GEM300PLC/Allocated->setIntValue(0);
    // record the id    // record the id
-   /E40PLC/ProcessJobId->setStringValue(prJob.getPrJobId());+   /GEM300PLC/ProcessJobId->setStringValue(prJob.getPrJobId());
  },  },
  prSetRecipeVariable : function (prJob, recVarList) {  prSetRecipeVariable : function (prJob, recVarList) {
Line 122: Line 122:
      
   // first indicate which process job the command is being executed on   // first indicate which process job the command is being executed on
-  /E40PLC/ProcessJobId->setStringValue(prJob.getPrJobId());+  /GEM300PLC/ProcessJobId->setStringValue(prJob.getPrJobId());
   // send the parameters - here we just print them   // send the parameters - here we just print them
   if ( prCmdParameterList != null ) {   if ( prCmdParameterList != null ) {
Line 132: Line 132:
   // get the index of the command   // get the index of the command
   cmdId = cmds.indexOf(prCmd);   cmdId = cmds.indexOf(prCmd);
-  /E40PLC/PrCmd->setIntValue(cmdId);+  /GEM300PLC/PrCmd->setIntValue(cmdId);
  }  }
   };   };
Line 143: Line 143:
         //print("host is still null");           //print("host is still null");  
         Thread.sleep(50); //wait 50 ms         Thread.sleep(50); //wait 50 ms
-        controller = TransSecsController.findController("E40PLCTool");+        controller = TransSecsController.findController("GEM300PLCTool");
     } while (controller == null);     } while (controller == null);
              
Line 173: Line 173:
  }  }
 </code> </code>
-        +==== E40 Java Example ==== 
 +=== E40 Java Using the Service wrapper calls to process a job === 
 +Executing a job through E40 requires indicating to the process job the current state of the process. For example: 
 +<code java> 
 +Initialize the handlers: 
 +    try { 
 +      E39MessageHandler.addMessageHandler(equipmentController.getControllerName()); 
 +      E40MessageHandler.addMessageHandler(); 
 +      E94MessageHandler.addMessageHandler(); 
 +      E87MessageHandler.addMessageHandler(2,4); 
 +    } catch (BadParameterException e) { 
 +      e.printStackTrace(); 
 +    } 
 +    E40ServiceWrapper.getInstance().registerCallback(new E40Callback()); 
 +[...] 
 + /** Process a Job. */ 
 +  protected void processJob() { 
 +    ProcessJob[] allProcessJobs = E40ServiceWrapper.getInstance().getAllPRJobs(); 
 +    if ( allProcessJobs.length > 0 ) { 
 +      ProcessJob processJob = allProcessJobs[0]; 
 +      processJob.allocated(); 
 +      processJob.materialArrived(); 
 +      wait500(); 
 +      processJob.readyToStart(); 
 +      while ( processJob.getPrJobState() == ProcessJobStates.WAITINGFORSTART.getStateId() ) { 
 +        wait500(); 
 +      } 
 +      wait500();    
 +      try { 
 +        processJob.complete(); 
 +        processJob.materialDeparted(); 
 +      } catch (InvalidStateTransitionException e) { 
 +        e.printStackTrace(); 
 +      } 
 +    } 
 +  } 
 +</code> 
 +Notification of changes in process are sent through the  
 +<code java> 
 +import com.ergotech.secs.e39.E39MessageHandler; 
 +import com.ergotech.secs.e40.E40MessageHandler; 
 +import com.ergotech.secs.e40.E40ServiceWrapper; 
 +import com.ergotech.secs.e40.E40CallbackInterface; 
 +import com.ergotech.secs.e40.ProcessJob; 
 +import com.ergotech.transsecs.secs.TransSecsController; 
 + 
 +public class E40Callback { 
 +    public E40Callback() { 
 +        System.out.println("Register GEM300"); 
 + 
 +        TransSecsController controller = TransSecsController.findController("GEM300Tool"); 
 +        } while (controller == null); 
 + 
 +        try { 
 +            E39MessageHandler.addMessageHandler(controller.getControllerName()); 
 +            E40MessageHandler.addMessageHandler(); 
 +        } catch (Exception e) { 
 +            System.out.println(e); 
 +        } 
 + 
 +        E40ServiceWrapper.getInstance().registerCallback(new E40CallbackInterface() { 
 +            @Override 
 +            public void prStateChange(ProcessJob prJob, int oldState, int newState) { 
 +                System.out.println("State Change for " + prJob.getPrJobId() + " From: " + 
 +                        ProcessJob.getStateName(oldState) + " to " + ProcessJob.getStateName(newState)); 
 +                 
 +             } 
 + 
 +            @Override 
 +            public void prJobCreate(ProcessJob prJob) { 
 +                System.out.println("Job Creation of " + prJob.getPrJobId() + " permitted"); 
 +                 
 +             } 
 + 
 +            @Override 
 +            public void prSetRecipeVariable(ProcessJob prJob, List<?> recVarList) { 
 +                if (recVarList != null) { 
 +                    for (Object recVar : recVarList) { 
 +                        System.out.println("Host Requested Recipe Variable \"" + recVar.toString() + "\" on " + prJob); 
 +                    } 
 +                } 
 +            } 
 + 
 +            @Override 
 +            public void prSetMtrlOrder(int prCurrentMtrlOrder, int prNewMtrlOrder) { 
 +                // Handle material order settings 
 +            } 
 + 
 +            @Override 
 +            public void prCommandCallback(ProcessJob prJob, String prCmd, List<?> prCmdParameterList) { 
 +                System.out.println("Host Requested \"" + prCmd + "\" on " + prJob + " with parameters " + prCmdParameterList); 
 +                 
 +                String[] cmds = {"NONE", "ABORT", "STOP", "CANCEL", "PAUSE", "RESUME", "STARTPROCESS"}; 
 +                int cmdId = Arrays.asList(cmds).indexOf(prCmd); 
 +                 
 +                  
 +                // Send the parameters 
 +                if (prCmdParameterList != null) { 
 +                    for (Object param : prCmdParameterList) { 
 +                        System.out.println("Host Requested Parameter \"" + param.toString() + "\" on " + prJob); 
 +                    } 
 +                } 
 + 
 +            } 
 +        }); 
 + 
 +        System.out.println("E40 Registered"); 
 +    } 
 +
 +</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 366:
 === 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 ===
Line 275: Line 461:
 </code> </code>
  
-=== E94 Callback Interface ===+The most commonly used methods to manage an E87 carrier are contained in the Facade interface: 
 +<code java> 
 +package  com.ergotech.secs.e87; 
 + 
 + 
 +import com.ergotech.secs.SecsException; 
 +import com.ergotech.secs.SecsFormat00; 
 +import com.ergotech.secs.e39.InvalidStateTransitionException; 
 +import com.ergotech.secs.e87.E87ServiceWrapper.CMStatus; 
 +import com.ergotech.vib.exceptions.BadParameterException; 
 + 
 + 
 + 
 +/** This implements the E87 services. It is normally called from E39. */ 
 +public interface E87ServiceWrapperFacadeInterface { 
 +  /** Creates the load port object for the specific id. 
 +   * @param loadPortId the id of the load port to create 
 +   * @param readyForService true if the load port is ready for service, otherwise false. 
 +   * If this parameter is true then the load port will transition to "IN SERVICE" 
 +   * and so to "READY TO LOAD" as soon as it is created. 
 +   * @return a new LoadPort 
 +   * @throws BadParameterException thrown if a load port with the given id already exists. 
 +   */ 
 +  public void createLoadPort(int loadPortId, boolean readyForService)throws BadParameterException; 
 + 
 +  /** This service shall associate a CarrierID to a load port and shall cause  
 +   * the load port to transition to the RESERVED state. 
 +   * @param portId the port id where the carrier is expected. 
 +   * @param carrierId the expected carrierID. 
 +   * @return CMStatus information concerning the result of the service 
 +   */ 
 +  public CMStatus bind ( int portId, String carrierId); 
 + 
 + 
 +  /** This service cancels a CarrierID to load port association and shall cause 
 +    the load port to transition to the NOT RESERVED state. 
 +   * @param loadPortId the portID for which to cancel the load port to carrier  
 +   * association.  Either PortID or CarrierID must be specified. 
 +   * @param carrierId the CarrierId for which to cancel the load port to carrier  
 +   * association.  Either PortID or CarrierID must be specified. 
 +   * @return information concerning the result of the service 
 +   */ 
 +  public CMStatus cancelBind ( int loadPortId, String carrierId ); 
 + 
 +  /** This service shall Cancel the current carrier related action, and the  
 +   * production equipment shall return the carrier to the unload position 
 +   * of the load port. 
 +   * @param carrierId the carrierID to cancel 
 +   * @param portId the PortID where the carrier object is located.  This 
 +   * parameter is not required if the carrier object has previously been  
 +   * instantiated. 
 +   @return information concerning the result of the service 
 +   */ 
 +  public CMStatus cancelCarrier ( int portId, String carrierId); 
 + 
 +  /** This service shall Cancel the current carrier related action, 
 +   * and the production equipment shall return the carrier to the unload  
 +   * position of the load port. 
 +   * @param portId any carrier that exist on the load port specified shall be  
 +    made ready for unloading. 
 +   * @return information concerning the result of the service 
 +   */ 
 +  public CMStatus cancelCarrierAtPort ( int portId ); 
 + 
 +  /** Create a carrier.  This can be mocked for unit testing.  
 +   * @throws BadParameterException thrown if a Carrier with the given ID already 
 +   * exists. 
 +   * @throws SecsException thrown if the properties list contains a slot map  
 +   * or a content map who's size does not match the capacity of the carrier. 
 +   */ 
 +  public Carrier createCarrier (String carrierId, int loadPortId,  SecsFormat00 propertiesList, int transition ) throws BadParameterException, SecsException; 
 + 
 +  /** Stores the callback object. 
 +   * @see com.ergotech.secs.e87.E87Interface#registerCallBack(com.ergotech.secs.e87.E87CallbackInterface) 
 +   */ 
 +  public void registerCallBack(E87CallbackInterface callback); 
 + 
 +  /** Attempt the state transition on the port.  The port is not checked for 
 +   * validity and an attempt to call this method on an invalid port will cause 
 +   * a null pointer exception. 
 +   */ 
 +  public void setLoadPortTransferState(int port, int stateTransition) throws InvalidStateTransitionException; 
 + 
 +  /** Return the transfer state of the port.  The port is not checked for 
 +   * validity and an attempt to call this method on an invalid port will cause 
 +   * a null pointer exception. 
 +   * @see com.ergotech.secs.e87.E87Interface#getLoadPortTransferState(int) 
 +   */ 
 +  public int getLoadPortTransferState(int port); 
 + 
 +  /** Attempt the state transition on the port.  The port is not checked for 
 +   * validity and an attempt to call this method on an invalid port will cause 
 +   * a null pointer exception. 
 +   */ 
 +  public void setLoadPortAccessState(int port, int state) throws InvalidStateTransitionException, SecsException; 
 + 
 +  /** Returns the current access state of the port.  The port is not checked for 
 +   * validity and an attempt to call this method on an invalid port will cause 
 +   * a null pointer exception. 
 +   * @see com.ergotech.secs.e87.E87Interface#getLoadPortAccessState(int) 
 +   */ 
 +  public int getLoadPortAccessState(int port); 
 + 
 +  /**  
 +   * Change the carrier access status.  There are three states:<p> 
 +     begin=0<p> 
 +     complete=1<p> 
 +     stopped=2<p> 
 +   * The carrier is not checked for validity and an attempt to access an invalid 
 +   * carrier will result in a null pointer exception. 
 +   * @throws InvalidStateTransitionException thrown if the access attempt is invalid 
 +   * @throws SecsException thrown if the status is an invalid request. 
 +   */ 
 +  public void accessCarrier(String carrierID, Carrier.CarrierAccessE87State state) throws InvalidStateTransitionException, SecsException; 
 + 
 +  /** Request to put the port in service.  The port is not checked for 
 +   * validity and an attempt to call this method on an invalid port will cause 
 +   * a null pointer exception. 
 +   * @throws InvalidStateTransitionException 
 +   * @see com.ergotech.secs.e87.E87Interface#getLoadPortAccessState(int) 
 +   */ 
 +  public void requestInService(int port) throws InvalidStateTransitionException; 
 + 
 +  /** Request to put the port in service.   
 +   * The port is not checked for validity and an attempt to call this  
 +   * method on an invalid port will cause a null pointer exception. 
 +   * @throws InvalidStateTransitionException 
 +   * @see com.ergotech.secs.e87.E87Interface#requestOutOfService(int) 
 +   */ 
 +  public void requestOutOfService(int port) throws InvalidStateTransitionException; 
 + 
 +   /** 
 +   * The application will invoke this when a carrier has arrived at a given port, 
 +   * after it has read the carrier id. 
 +   *  
 +   * @param carrierId 
 +   * @param port The load port.  The port is not checked for validity and an  
 +               attempt to call this method on an invalid port will cause a  
 +               null pointer exception. 
 +   * @param readOK the carrier id read is valid. 
 +   * @param bypassReadId if this is true, the carrierID and readOK flags 
 +          are ignored and processing continues with the carrier that is at the 
 +          provided port. 
 +   * @return 0:verified, 2:waiting for host proceed (or cancel), 3: duplicate id 
 +   * @throws InvalidStateTransitionException 
 +   * @throws BadParameterException 
 +   */ 
 +  public int carrierArrived(String carrierId, int port, boolean readOK, boolean bypassReadId, boolean hostVerification ) throws InvalidStateTransitionException, BadParameterException; 
 + 
 +  /** When the carrier arrives, the LoadPort may already be in the "Transfer Blocked" state (eg as part of E84). 
 +   * This method will check the current state of the load port.  If it is not in "Transfer Blocked" it will attempt 
 +   * the transition 6.  If that transition is invalide, the method will throw. 
 +   *  
 +   * @param loadPort the load port on which to execute the transition. 
 +   * @throws InvalidStateTransitionException thrown if load port transition 6 is not a valid transition. 
 +   */ 
 +  public void conditionalLoadPortTransition6(LoadPort loadPort) throws InvalidStateTransitionException; 
 + 
 +  /** When the carrier departs, the LoadPort may not be in the "Transfer Blocked" state (eg as part of E84). 
 +   * This method will check the current state of the load port.  If it is not in "Transfer Blocked" it will attempt 
 +   * the transition 6.  If that transition is invalide, the method will throw. 
 +   *  
 +   * @param loadPort the load port on which to execute the transition. 
 +   * @throws InvalidStateTransitionException thrown if load port transition 6 is not a valid transition. 
 +   */ 
 +  public void conditionalLoadPortTransition8(LoadPort loadPort) throws InvalidStateTransitionException; 
 + 
 +  /** Execute transition21 to indicate that the carrier has departed.  This also destroys the  
 +   * carrier instance. 
 +   * Set the carrier to null to indicate that it has departed. 
 +   * The port is not checked for validity and an attempt to call this  
 +   * method on an invalid port will cause a null pointer exception. 
 +   * @throws InvalidStateTransitionException 
 +   * @see com.ergotech.secs.e87.E87Interface#carrierDeparted(int) 
 +   */ 
 +  public void carrierDeparted(int port, String carrierId ) throws InvalidStateTransitionException; 
 + 
 +  /**  
 +   * The port is not checked for validity and an attempt to call this  
 +   * method on an invalid port will cause a null pointer exception. 
 +   * @throws InvalidStateTransitionException 
 +   * @see com.ergotech.secs.e87.E87Interface#carrierDeparted(int) 
 +   */ 
 +  public void carrierDeparted(int port) throws InvalidStateTransitionException; 
 + 
 +  /** Cancel the carrier at the port. 
 +   * The port is not checked for validity and an attempt to call this  
 +   * method on an invalid port will cause a null pointer exception. 
 +   * @throws InvalidStateTransitionException 
 +   */ 
 +  public void cancelCarrier(int port) throws InvalidStateTransitionException; 
 +   
 +  /** Returns all carriers 
 +   * @return  an array of all carriers. 
 +   */ 
 +  public Carrier[] getAllCarriers(); 
 + 
 +  /** Return the carrier instance for the ID, or null if the carrier does not exist.  
 +   *  
 +   * @param carrierId the carrier id 
 +   */ 
 +  public Carrier getCarrier ( String carrierId ); 
 + 
 +
 +</code> 
 + 
 +=== E87 Callback Interface ===
  
 The E87 Callback Interface provides notification of activity from the host.  A sample implementation of the interface is provided below. The tool control system should implement as many of the methods are required to progress the carrier through the tool. The E87 Callback Interface provides notification of activity from the host.  A sample implementation of the interface is provided below. The tool control system should implement as many of the methods are required to progress the carrier through the tool.
  
 <code> <code>
-var E40Callback = new E87CallbackInterface() {+var E87Callback = new E87CallbackInterface() {
      
  
  • gem300_scripts.1626132693.txt.gz
  • Last modified: 2021/07/12 18:31
  • by wikiadmin