Differences
This shows you the differences between two versions of the page.
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: | ||
| | ||
} | } | ||
+ | </ | ||
+ | ==== 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, | ||
+ | } 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(); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | 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(" | ||
+ | |||
+ | TransSecsController controller = TransSecsController.findController(" | ||
+ | } 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(" | ||
+ | ProcessJob.getStateName(oldState) + " to " + ProcessJob.getStateName(newState)); | ||
+ | | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public void prJobCreate(ProcessJob prJob) { | ||
+ | System.out.println(" | ||
+ | | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public void prSetRecipeVariable(ProcessJob prJob, List<?> | ||
+ | if (recVarList != null) { | ||
+ | for (Object recVar : recVarList) { | ||
+ | System.out.println(" | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public void prSetMtrlOrder(int prCurrentMtrlOrder, | ||
+ | // Handle material order settings | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public void prCommandCallback(ProcessJob prJob, String prCmd, List<?> | ||
+ | System.out.println(" | ||
+ | | ||
+ | String[] cmds = {" | ||
+ | int cmdId = Arrays.asList(cmds).indexOf(prCmd); | ||
+ | | ||
+ | |||
+ | // Send the parameters | ||
+ | if (prCmdParameterList != null) { | ||
+ | for (Object param : prCmdParameterList) { | ||
+ | System.out.println(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | } | ||
+ | }); | ||
+ | |||
+ | System.out.println(" | ||
+ | } | ||
+ | } | ||
</ | </ | ||
==== E40 Python Example ==== | ==== E40 Python Example ==== | ||
- | < | + | < |
# | # | ||
import jpype | import jpype | ||
Line 181: | Line 291: | ||
from jpype.types import * | from jpype.types import * | ||
- | jpype.startJVM(classpath=[' | + | jpype.startJVM(classpath=[' |
# Importing the necessary Java classes | # Importing the necessary Java classes | ||
Line 349: | Line 459: | ||
// carrier has departed | // carrier has departed | ||
e87ServiceWrapper.carrierDeparted(carrier.getLoadPortId(), | e87ServiceWrapper.carrierDeparted(carrier.getLoadPortId(), | ||
+ | </ | ||
+ | |||
+ | The most commonly used methods to manage an E87 carrier are contained in the Facade interface: | ||
+ | <code java> | ||
+ | package | ||
+ | |||
+ | |||
+ | 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 | ||
+ | | ||
+ | * @param loadPortId the portID for which to cancel the load port to carrier | ||
+ | * association. | ||
+ | * @param carrierId the CarrierId for which to cancel the load port to carrier | ||
+ | * association. | ||
+ | * @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. | ||
+ | * parameter is not required if the carrier object has previously been | ||
+ | * instantiated. | ||
+ | | ||
+ | */ | ||
+ | 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 | ||
+ | | ||
+ | * @return information concerning the result of the service | ||
+ | */ | ||
+ | public CMStatus cancelCarrierAtPort ( int portId ); | ||
+ | |||
+ | /** Create a carrier. | ||
+ | * @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, | ||
+ | |||
+ | /** Stores the callback object. | ||
+ | * @see com.ergotech.secs.e87.E87Interface# | ||
+ | */ | ||
+ | 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# | ||
+ | */ | ||
+ | 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, | ||
+ | |||
+ | /** 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# | ||
+ | */ | ||
+ | public int getLoadPortAccessState(int port); | ||
+ | |||
+ | /** | ||
+ | * Change the carrier access status. | ||
+ | | ||
+ | | ||
+ | | ||
+ | * 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, | ||
+ | |||
+ | /** Request to put the port in service. | ||
+ | * 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# | ||
+ | */ | ||
+ | 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# | ||
+ | */ | ||
+ | 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 | ||
+ | | ||
+ | | ||
+ | * @param readOK the carrier id read is valid. | ||
+ | * @param bypassReadId if this is true, the carrierID and readOK flags | ||
+ | | ||
+ | | ||
+ | * @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, | ||
+ | |||
+ | /** When the carrier arrives, the LoadPort may already be in the " | ||
+ | * This method will check the current state of the load port. If it is not in " | ||
+ | * 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 " | ||
+ | * This method will check the current state of the load port. If it is not in " | ||
+ | * 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. | ||
+ | * 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# | ||
+ | */ | ||
+ | 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# | ||
+ | */ | ||
+ | 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 | ||
+ | */ | ||
+ | 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 ); | ||
+ | |||
+ | } | ||
</ | </ | ||