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/09/19 14:52]
wikiadmin
gem300_scripts [2025/02/28 20:17] (current)
wikiadmin
Line 172: Line 172:
      
  }  }
 +</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> </code>
 ==== E40 Python Example ==== ==== E40 Python Example ====
-<code>+<code python>
 #!/usr/bin/python3 #!/usr/bin/python3
 import jpype import jpype
Line 181: Line 291:
 from jpype.types import * from jpype.types import *
  
-jpype.startJVM(classpath=['.', './YourJarFile.jar'])+jpype.startJVM(classpath=['.', './GEMTool.jar'])
  
 # Importing the necessary Java classes # Importing the necessary Java classes
Line 349: Line 459:
       // carrier has departed       // carrier has departed
       e87ServiceWrapper.carrierDeparted(carrier.getLoadPortId(), carrier.getCarrierId());       e87ServiceWrapper.carrierDeparted(carrier.getLoadPortId(), carrier.getCarrierId());
 +</code>
 +
 +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> </code>
  
  • gem300_scripts.1726775545.txt.gz
  • Last modified: 2024/09/19 14:52
  • by wikiadmin