private void OnSubmachineDone(IActivityMachine machine)
 {
     if (SubmachineDone != null)
     {
         SubmachineDone(this, new SubmachineEventArgs()
         {
             Machine = machine
         });
     }
 }
示例#2
0
 public override void Build(IActivityMachine machine)
 {
     //if (activityMachine is WasteProcessingActivityMachine)
     //{
     //    AssembleMachineForRecurringWastePurge(activityMachine as WasteProcessingActivityMachine);
     //}
     //else
     //{
     //    LogService.Log(LogType.System, LogMessageType.Warning, GetType().Name, "Attempted to build a RepeatableActivityMachine for an unknown purpose.");
     //}
 }
 /// <summary>
 /// Create a new PausableNode that, as its Entry behavior, will pause the given machine if the PreventExit value is true.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="containerName"></param>
 /// <param name="machine"></param>
 public PausableNode(string name, string containerName, IActivityMachine machine)
     : base(name, containerName, new EmptyConstraint())
 {
     // Use the base method because the override is empty on purpose.
     base.SetEnterBehavior(null, new DynamicActivity("Pause " + containerName, () =>
     {
         if (PauseParentMachine)
         {
             machine.Pause();
         }
     }));
 }
示例#4
0
        private void RemoveMachineFromDelayedList(IActivityMachine machine)
        {
            if (!_delayedMachines.Contains(machine))
            {
                return;
            }

            LogService.Log(LogType.System, LogMessageType.Debug, GetType().Name,
                           string.Format(CultureInfo.InvariantCulture, "Removing IActivityMachine '{0}' from the delayed IExecutable list.", machine.Name));
            machine.ExecuteRequested -= HandleExecuteRequested;

            _delayedMachines.Remove(machine);
        }
示例#5
0
 /// <summary>
 /// adds an activity machine to its machines list and listens for
 /// notification from the machine that it is ready to execute
 /// </summary>
 /// <param name="activityMachine">machine to add</param>
 public void Add(IActivityMachine activityMachine)
 {
     if (activityMachine == null)
     {
         return;
     }
     lock (_updateLock)
     {
         _delayedMachines.Add(activityMachine);
         GetTotalMachineCount();
         activityMachine.ExecuteRequested += HandleExecuteRequested;
     }
 }
        private const int MachineExpirationInMinutes = 10;  //TODO: change this time.

        public override void Build(IActivityMachine machine)
        {
            var e            = machine.Configuration.Data.Exception as AtlasException;
            var errorMachine = machine as ErrorHandlingActivityMachine;

            if (e != null && errorMachine != null)
            {
                errorMachine.ExpirationTimespan = TimeSpan.FromMinutes(MachineExpirationInMinutes);
                errorMachine.Instrument         = machine.Configuration.Data.Instrument as IInstrument;
                errorMachine.InstrumentManager  = machine.Configuration.Data.InstrumentManager as IInstrumentManager;
                errorMachine.Engine             = machine.Configuration.Data.Engine as IExecutableEngine;

                AssembleMachineForTrayProcessor(e, errorMachine);
            }
        }
示例#7
0
        private IActivityMachine CreateMachine(IConfiguration configuration)
        {
            if (!IsRunning)
            {
                return(null);
            }

            Guid machineId = Guid.NewGuid();

            IActivityMachine activityMachine = ActivityMachineFactory.Create(configuration as DynamicConfiguration);

            if (activityMachine != null)
            {
                activityMachine.Id = machineId;
            }

            return(activityMachine);
        }
        public override void Build(IActivityMachine machine)
        {
            var ex             = machine.Configuration.Data.Exception as AtlasException;
            var stationMachine = machine as ErrorHandlingActivityMachine;

            if (ex != null && stationMachine != null)
            {
                var station = machine.Configuration.Data.Station as IStation;
                if (station != null)
                {
                    //// Don't assemble machines for PortalBays or GarageBays.
                    //if (station.Type != StationType.PortalBay && station.Type != StationType.GarageBay)
                    //{
                    //    return;
                    //}

                    stationMachine.SetStationAndTrayReferences(station);
                }

                //TODO: change this time.
                stationMachine.ExpirationTimespan = TimeSpan.FromMinutes(45);
                stationMachine.Instrument         = machine.Configuration.Data.Instrument as IInstrument;
                stationMachine.InstrumentManager  = machine.Configuration.Data.InstrumentManager as IInstrumentManager;
                stationMachine.Engine             = machine.Configuration.Data.Engine as IExecutableEngine;

                if (stationMachine.TrayProcessor != null)
                {
                    stationMachine.UseRuntimeTrigger(new PropertyChangedTrigger("StationStateChanged", stationMachine.TrayProcessor,
                                                                                stationMachine.TrayProcessor.PropertyToString(() => stationMachine.TrayProcessor.State)));
                }

                //Raise error dialog
                SetNotificationActivities(stationMachine, ex);

                if (!(ex.Station is ITrayProcessor))
                {
                    LogService.Log(LogType.System, LogMessageType.Error, GetType().Name,
                                   string.Format(CultureInfo.InvariantCulture, "Cannot perform {0} {1} exception handling without a station.", ex.Severity, ex.Code));
                    return;
                }

                AssembleMachineForTrayProcessor(ex, stationMachine);
            }
        }
示例#9
0
 protected void SubscribeToMachine(IActivityMachine machine, bool subscribe)
 {
     if (machine != null)
     {
         var activityMachine = machine as ActivityMachine;
         var commandMachine  = machine as CommandExecutingMachine;
         if (subscribe)
         {
             machine.Finished    += HandleMachineFinished;
             machine.Expired     += HandleMachineExpired;
             machine.Interrupted += HandleMachineInterrupted;
             machine.Faulted     += HandleMachineFaulted;
             if (activityMachine != null)
             {
                 activityMachine.Paused  += HandleMachinePaused;
                 activityMachine.Resumed += HandleMachineResumed;
             }
             if (commandMachine != null)
             {
                 commandMachine.PausableNodeEntered += HandlePausableNodeEntered;
             }
         }
         else
         {
             machine.Finished    -= HandleMachineFinished;
             machine.Expired     -= HandleMachineExpired;
             machine.Interrupted -= HandleMachineInterrupted;
             machine.Faulted     -= HandleMachineFaulted;
             if (activityMachine != null)
             {
                 activityMachine.Paused  -= HandleMachinePaused;
                 activityMachine.Resumed -= HandleMachineResumed;
             }
             if (commandMachine != null)
             {
                 commandMachine.PausableNodeEntered -= HandlePausableNodeEntered;
             }
         }
     }
 }
        public static IActivityMachine Create(DynamicConfiguration config)
        {
            try
            {
                IActivityMachine machine = null;
                if (BuilderTypes.StationErrorHandlingMachineBuilder == config.ResourceSelector ||
                    BuilderTypes.SystemErrorHandlingMachineBuilder == config.ResourceSelector ||
                    BuilderTypes.SystemEmergencyHandlingMachineBuilder == config.ResourceSelector)
                {
                    machine = CreateMachineForTrayProcessorErrorHandling(config);
                }
                else if (config.ResourceSelector == BuilderTypes.MotionSystemErrorHandlingBuilder)
                {
                    machine = CreateMachineForMotionErrorHandling(config);
                }
                else if (BuilderTypes.CommandExecutingMachineBuilder.EndsWith(config.ResourceSelector, StringComparison.OrdinalIgnoreCase))
                {
                    machine = CreateMachineForCommandExecuting(config);
                }
                else if (config.ResourceSelector == BuilderTypes.TrayMovingMachineBuilder)
                {
                    machine = CreateMachineForTrayMoving(config);
                }
                else if (config.ResourceSelector == BuilderTypes.TransportOperationMachineBuilder)
                {
                    machine = CreateMachineForTransportOperation(config);
                }

                machine.Configuration = config;

                return(machine);
            }
            catch (Exception ex)
            {
                //TODO: throw custom exception
                LogService.Log(LogType.System, LogMessageType.Error, "ActivityMachineFactory",
                               String.Format(CultureInfo.InvariantCulture, "Machine creation failed for selector '{0}': {1}", config != null ? config.ResourceSelector : "unknown", ex.Message), ex);
            }
            return(null);
        }
示例#11
0
        public override void Build(IActivityMachine machine)
        {
            //var station = MachineConfiguration.Data.Stations[0];

            //var funkyMachine = activityMachine as TestFunctionActivityMachine;
            //if (funkyMachine != null)
            //{
            //    // Let all machines force quit if the instrument stops.
            //    funkyMachine.SetQuitOnInstrumentState(InstrumentState.Stopped);

            //    switch (MachineConfiguration.TestFunctionType)
            //    {
            //        case TestFunctionType.ScriptExecuter:
            //            AssembleScriptExecutingTestFunction(activityMachine as TestFunctionActivityMachine, MachineConfiguration.Executive, MachineConfiguration.StandardHandler, MachineConfiguration.Instrument, station, MachineConfiguration.ScriptNames);
            //            break;

            //        default:
            //            LogService.Log(LogType.System, LogMessageType.Warning, GetType().Name, "Attempted to build a TestFunctionActivityMachine for unknown function type.");
            //            break;
            //    }
            //}
        }
示例#12
0
        public override void Build(IActivityMachine machine)
        {
            var transportMachine = machine as TransportOperationMachine;

            if (transportMachine != null)
            {
                transportMachine.Instrument         = machine.Configuration.Data.Instrument as IInstrument;
                transportMachine.Transport          = machine.Configuration.Data.Transport as ITransport;
                transportMachine.Operation          = machine.Configuration.Data.TransportOperation;
                transportMachine.Station            = machine.Configuration.Data.Station as ITrayDetector;
                transportMachine.ExpirationTimespan = machine.Configuration.Data.ExpirationTimespan;
                // Assigning the tray at build time ensures that the stations are locked while also
                // letting the tray be used for runtime triggers.
                transportMachine.Tray = transportMachine.Station.Tray;

                var statefulSource = transportMachine.Station as IStatefulModel <StationState>;

                // Hold a reference to the transport's tray, if the station didn't have a tray.
                if (transportMachine.Tray == null)
                {
                    transportMachine.Tray = transportMachine.Transport.Tray;
                }

                // Setup the triggers that each machine will use.
                if (transportMachine.Tray != null)
                {
                    transportMachine.UseRuntimeTrigger(new PropertyChangedTrigger("Tray State Changed", transportMachine.Tray, transportMachine.Tray.PropertyToString(() => transportMachine.Tray.State)));
                }
                if (statefulSource != null)
                {
                    transportMachine.UseRuntimeTrigger(new PropertyChangedTrigger("Station State Changed", statefulSource, statefulSource.PropertyToString(() => statefulSource.State)));
                }
                var stationTrayDetectTrigger = new PropertyChangedTrigger("Station IsTrayDetected Changed", statefulSource,
                                                                          transportMachine.Station.PropertyToString(() => transportMachine.Station.IsTrayDetected));
                transportMachine.UseRuntimeTrigger(stationTrayDetectTrigger);

                var station = transportMachine.Station as IStation;
                if (station != null)
                {
                    // This will trigger if either Error or Severity property notifies of a change.
                    transportMachine.UseRuntimeTrigger(new PropertyChangedTrigger("Station Error Severity Changed", station,
                                                                                  station.PropertyToString(() => station.Error) + "." + station.PropertyToString(() => station.Error.Severity)));
                }

                var transportTrayDetectTrigger = new PropertyChangedTrigger("Transportation IsTrayDetected Changed", transportMachine.Transport,
                                                                            transportMachine.Transport.PropertyToString(() => transportMachine.Transport.IsTrayDetected));
                transportMachine.UseRuntimeTrigger(new PropertyChangedTrigger("Instrument State Changed", transportMachine.Instrument,
                                                                              transportMachine.Instrument.PropertyToString(() => transportMachine.Instrument.State)));
                transportMachine.UseRuntimeTrigger(new PropertyChangedTrigger("Transportation State Changed", transportMachine.Transport,
                                                                              transportMachine.Transport.PropertyToString(() => transportMachine.Transport.State)));
                transportMachine.UseRuntimeTrigger(transportTrayDetectTrigger);
                var transportStation = transportMachine.Transport as IStation;
                transportMachine.UseRuntimeTrigger(new PropertyChangedTrigger("Transportation HasErred Changed", transportStation,
                                                                              transportStation.PropertyToString(() => transportStation.HasErred)));
                transportMachine.UseRuntimeTrigger(new PropertyChangedTrigger("Transportation XPosition Changed", transportMachine.Transport,
                                                                              transportMachine.Transport.PropertyToString(() => transportMachine.Transport.XPosition)));
                transportMachine.UseRuntimeTrigger(new PropertyChangedTrigger("Transportation ZPosition Changed", transportMachine.Transport,
                                                                              transportMachine.Transport.PropertyToString(() => transportMachine.Transport.ZPosition)));

                // Tell the machine to quit acting if the tray is lost.
                transportMachine.SetQuitOnTrayState(TrayState.Lost);
                // Tell the machine to quit if Transport station has erred.
                transportMachine.SetQuitOnTransportHasErred();
                // Tell the machine to quit if the source/dest (depending on move type) acquires a critical error.
                transportMachine.SetQuitOnCriticalStationError();
                // Tell the machine to quit if the source/dest (depending on move type) goes to disabling or disabled state.
                transportMachine.SetQuitOnStationState(StationState.Disabling);
                transportMachine.SetQuitOnStationState(StationState.Disabled);
                // Tell machine to finish if transport is stopped.
                transportMachine.SetFinishOnTransportState(StationState.Stopped);

                switch (transportMachine.Operation)
                {
                case TransportOperation.BeginPickup:
                    AssembleMachineForBeginTrayPickup(transportMachine);
                    break;

                case TransportOperation.CompletePickup:
                    AssembleMachineForCompleteTrayPickup(transportMachine, machine.Configuration.Data.SourceLockOwner);
                    break;

                case TransportOperation.BeginDropoff:
                    AssembleMachineForBeginTrayDropoff(transportMachine);
                    break;

                case TransportOperation.CompleteDropoff:
                    AssembleMachineForCompleteTrayDropoff(transportMachine);
                    break;

                default:
                    LogService.Log(LogType.System, LogMessageType.Warning, GetType().Name, "Attempted to build a TransportActivityMachine for an unknown purpose.");
                    break;
                }
            }
            else
            {
                LogService.Log(LogType.System, LogMessageType.Error, GetType().Name, "Attempted to build a TransportActivityMachine using a null reference.");
            }
        }
 public abstract void Build(IActivityMachine machine);