Ejemplo n.º 1
0
        private void AssembleMachineForCompleteTrayPickup(TransportOperationMachine machine, object sourceLockOwner)
        {
            // In this case, Station is the source of the tray.
            var station     = machine.Station as IStation;
            var dockStation = machine.Station as ITransportDock;

            if (station != null && dockStation != null)
            {
                // This machine doesn't know if Transport is safe yet or not.
                machine.AddActivity(new DynamicActivity("Set machine HaltOnError", () => machine.HaltOnError = true));

                // Wait for transportation to stop moving.
                machine.AddContinueCondition(new DynamicConstraint <ITransport>("Transport Detects Tray?", machine.Transport,
                                                                                (td) => IsTransportParkedWithTray(machine.Transport)));

                if (station.Type != StationType.Stainer)
                {
                    // This machine knows it is above the station and in elevator now, so no need for transport error.
                    machine.AddActivity(new DynamicActivity("Set machine HaltOnError", () => machine.HaltOnError = false));
                }

                // Wait for the source station IsTrayDetected trigger.
                // Slide id does not have a tray present sensor, so it should always be faking it.
                machine.AddContinueCondition(
                    new DynamicConstraint <ITrayDetector>("Tray Not Detected At Source?", machine.Station, (td) => !td.IsTrayDetected));

                // Complete the handoff.  Quit this machine if the CompleteHandoff fails.
                machine.SetActivityTrayHandlerCompleteHandoff();

                // If we just picked up from a stainer and the destination is below it, wait for CompleteHandoff to finish.
                if (station.Type == StationType.Stainer)
                {
                    var destinationZ = machine.Configuration.Data.DestinationZLocation;
                    // If the destination is below the source stainer,
                    // wait until the stainer's handoff is completed.  Otherwise, transport can move on safely.
                    if (dockStation.DockZ > destinationZ)
                    {
                        // Pause until source station has completed its handoff.
                        machine.SetPauseUntilConditionOfStation("IsStationNotHandoffPrepared", IsStationNotHandoffPrepared);
                    }
                }

                // Assuming the station is no longer HandoffPrepared, TrayMover does not need to halt movements anymore.
                machine.AddActivity(new DynamicActivity("Set machine HaltOnError", () => machine.HaltOnError = true));

                // Reassign the tray from source to transport.
                machine.SetActivityReassignTray(machine.Station, machine.Transport);

                // Special activity needed only for this machine to release the lock on the source station early.
                machine.SetActivityReleaseDockLock(sourceLockOwner);
            }
            else
            {
                throw new Exception("Complete tray pick-up failed to build: no source station.");
            }
        }
Ejemplo n.º 2
0
        public void AssembleMachineForCompleteTrayDropoff(TransportOperationMachine machine)
        {
            var station = machine.Station as IStation;

            if (station != null)
            {
                // This machine doesn't know if Transport is safe or not.
                machine.AddActivity(new DynamicActivity("Set machine HaltOnError", () => machine.HaltOnError = true));

                // If the prior machine was stopped, skip tray reassignment.
                if (!machine.IsStopped)
                {
                    //TODO: change this to go by interfaces once SlideId is refactored.
                    if (station.Type != StationType.SlideId)
                    {
                        // Wait for transportation to stop moving
                        machine.AddContinueCondition(new DynamicConstraint <ITransport>("Transport Missing Tray?", machine.Transport,
                                                                                        (td) => IsTransportParkedWithoutTray(machine.Transport)));
                    }

                    // Wait for the destination station IsTrayDetected trigger.
                    // Slide id does not have a tray present sensor, so it should always be faking it.
                    machine.AddContinueCondition(new DynamicConstraint <ITrayDetector>("Tray Detected At Destination?", machine.Station,
                                                                                       (td) => td.IsTrayDetected));

                    // Reassign the tray from transport to destination.
                    // Needed to reassign the Tray before performing complete handoff to ensure the tray cooling is performed.
                    machine.SetActivityReassignTray(machine.Transport, machine.Station);
                }

                if (station.Type != StationType.Stainer)
                {
                    // This machine knows it is below the station and in elevator now, so no need for transport error.
                    machine.AddActivity(new DynamicActivity("Set machine HaltOnError", () => machine.HaltOnError = false));
                }

                // Complete the handoff.  Quit this machine if the CompleteHandoff fails.
                machine.SetActivityTrayHandlerCompleteHandoff();

                // Pause until destination station has completed its handoff, which indicates the overall tray move is done.
                machine.SetPauseUntilConditionOfStation("IsStationNotHandoffPrepared?", IsStationNotHandoffPrepared);

                // If neither the destination nor the transport detect a tray when the machine exits, set tray to Lost state.
                machine.UseFinalExitBehavior(new ActOnResultActivity <bool>("Set Tray Lost",
                                                                            () => IsTrayLost(machine.Transport, machine.Station) && machine.Tray != null, true,
                                                                            () => machine.Tray.OnDetectionLost()));
            }
            else
            {
                throw new Exception("Complete tray drop-off failed to build: no destination station.");
            }
        }