public override bool Execute()
        {
            var outputFiles = new List <string>();

            foreach (var item in ModelInputs.OrEmpty())
            {
                ExecuteInstance(item, outputFiles);
            }
            OutputFiles = outputFiles.ToArray();
            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the given <see cref="ModelAction"/> input.
        /// </summary>
        public void HandleModelInput(ModelAction modelInput)
        {
            lock (locker)
            {
                // Pre-filter incompatible types.
                if (modelInput is null)
                {
                    throw new ArgumentNullException(nameof(modelInput));
                }
                if (!ModelInputs.Contains(modelInput.GetType()))
                {
                    return;
                }

                Log.Debug(this, nameof(HandleModelInput) + ": " + modelInput);
                inputs.Enqueue(modelInput);

                // This must now be called manually from the thread that should perform the operations.
                //CheckSystems();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Indexes the <see cref="ModelInputs"/> and <see cref="SystemEvents"/>,
        /// plus <see cref="ModelOutputs"/> and <see cref="SystemCommands"/>,
        /// whenever a <see cref="TransitionSystem"/> is added or removed.
        /// </summary>
        private void IndexSystems()
        {
            ModelInputs.Clear();
            ModelOutputs.Clear();
            SystemCommands.Clear();
            SystemEvents.Clear();

            foreach (TransitionSystem system in Systems)
            {
                foreach (Transition transition in system.Transitions)
                {
                    if (transition is ReactiveTransition reactive)
                    {
                        if (typeof(ModelAction).IsAssignableFrom(reactive.Action))
                        {
                            ModelInputs.Add(reactive.Action);
                        }
                        else if (typeof(ISystemAction).IsAssignableFrom(reactive.Action))
                        {
                            SystemEvents.Add(reactive.Action);
                        }
                    }
                    else if (transition is ProactiveTransition proactive)
                    {
                        if (typeof(ModelAction).IsAssignableFrom(proactive.Action))
                        {
                            ModelOutputs.Add(proactive.Action);
                        }
                        else if (typeof(ISystemAction).IsAssignableFrom(proactive.Action))
                        {
                            SystemCommands.Add(proactive.Action);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
 /// <summary><see cref="object.ToString"/></summary>
 public override string ToString()
 {
     return(GetType().Name
            + "\n" + nameof(Connector) + ": " + Connector
            + "\n" + nameof(Systems) + " (" + Systems.Count + "): " + string.Join(", ", Systems.Select(x => x.ModelAction.Name).ToArray())
            + "\n" + nameof(CurrentSystem) + ": " + CurrentSystem
            + "\n" + nameof(ModelInputs) + " (" + ModelInputs.Count + "): " + string.Join(", ", ModelInputs.Select(x => x.Name).ToArray())
            + "\n" + nameof(ModelOutputs) + " (" + ModelOutputs.Count + "): " + string.Join(", ", ModelOutputs.Select(x => x.Name).ToArray())
            + "\n" + nameof(SystemCommands) + " (" + SystemCommands.Count + "): " + string.Join(", ", SystemCommands.Select(x => x.Name).ToArray())
            + "\n" + nameof(SystemEvents) + " (" + SystemEvents.Count + "): " + string.Join(", ", SystemEvents.Select(x => x.Name).ToArray()));
 }