private static TransportProcess CreateSampleProcess() { TransportProcess process = new TransportProcess(); WaitStep stepA; DeliverStepDummy stepB; process.Add(stepA = new WaitStep() { Duration = 12.0 }); process.Add(stepB = new DeliverStepDummy()); process.Add(new Edge() { Source = stepA, Destination = stepB, SourceExit = ExitPointDefinition.Default }); process.Add(new Edge() { Source = stepB, Destination = stepA, SourceExit = stepB.Done.Definition }); process.Add(new Edge() { Source = stepB, Destination = stepB, SourceExit = stepB.Failed.Definition }); process.InitialState = stepA; return(process); }
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); } }