예제 #1
0
        static void Main(string[] args)
        {
            //==========================================================================
            // Option 1: Load the process configuration as raw data, i.e. from the database
            // Then register the known process steps and construct an instance of the runtime.
            // First register the known process steps
            LoadProcessStepDefinitions();

            // Load the process configuration from the database and instanciate it
            ProcessInstanceData data          = LoadProcessDescriptionFromDatabase();
            TransportProcess    loadedProcess = TransportProcess.Instanciate(data);

            //==========================================================================
            // Option 2: Instanciate a new executable process directly at runtime.
            var sampleProcess = CreateSampleProcess();

            // We set the parameters for the transport process before we can run it.
            // These parameters are equivalent to those passed in the current TPM implementation via CustomOrder.NewOrder() method.
            // We can infer the parameters we will need for the process from the used steps.
            var inferredParameters = ProcessStepDefinition.GetInferredParameters(loadedProcess.Steps.Select(step => step.Definition));

            loadedProcess.Parameters[inferredParameters.FirstOrDefault().Name] = 10001010;

            // Run the state machine.
            while (true)
            {
                loadedProcess.Update();
                Thread.Sleep(100);
            }
        }
예제 #2
0
        private static void LoadProcessStepDefinitions()
        {
            Assembly runtimeLibrary = typeof(WaitStep).Assembly;

            foreach (var processStepType in runtimeLibrary
                     .GetTypes()
                     .Where(t => typeof(ProcessStep).IsAssignableFrom(t)))
            {
                ProcessStepDefinition.Register(processStepType);
            }
        }