protected override object OnRun(EngineSession session)
 {
     return(session
            .DataStack
            .GetRelative(this.StackIndex)
            .Value);
 }
예제 #2
0
 protected override object OnRun(EngineSession session)
 {
     if ((bool)this.Condition.Run(session))
     {
         return(this.BodyThen.Run(session));
     }
     else
     {
         return(this.BodyElse.Run(session));
     }
 }
예제 #3
0
        protected override object OnRun(EngineSession session)
        {
            EngineVariableSurrogate vs = session
                                         .DataStack
                                         .GetRelative(this.TargetField.StackIndex);

            vs.Value = this
                       .SourceValue
                       .Run(session);

            return(vs.Value);
        }
예제 #4
0
        public static void Main()
        {
            //create the device context to expose to the engine
            var DeviceContext = new MyDC();

            DeviceContext.OnboardLed = new OutputPort(Pins.ONBOARD_LED, false);

            DeviceContext.OutputPorts[0] = new OutputPort(Pins.GPIO_PIN_D0, false);
            DeviceContext.OutputPorts[1] = new OutputPort(Pins.GPIO_PIN_D1, false);
            DeviceContext.OutputPorts[2] = new OutputPort(Pins.GPIO_PIN_D2, false);
            DeviceContext.OutputPorts[3] = new OutputPort(Pins.GPIO_PIN_D3, false);
            DeviceContext.OutputPorts[4] = new OutputPort(Pins.GPIO_PIN_D4, false);
            DeviceContext.OutputPorts[5] = new OutputPort(Pins.GPIO_PIN_D5, false);
            DeviceContext.OutputPorts[6] = new OutputPort(Pins.GPIO_PIN_D6, false);
            DeviceContext.OutputPorts[7] = new OutputPort(Pins.GPIO_PIN_D7, false);

            DeviceContext.InputPorts[0] = new InputPort(Pins.GPIO_PIN_D8, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[1] = new InputPort(Pins.GPIO_PIN_D9, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[2] = new InputPort(Pins.GPIO_PIN_D10, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[3] = new InputPort(Pins.GPIO_PIN_D11, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[4] = new InputPort(Pins.GPIO_PIN_D12, true, Port.ResistorMode.PullUp);
            DeviceContext.InputPorts[5] = new InputPort(Pins.GPIO_PIN_D13, true, Port.ResistorMode.PullUp);

            DeviceContext.AnalogPorts[0] = new AnalogInput(Pins.GPIO_PIN_A0);
            DeviceContext.AnalogPorts[1] = new AnalogInput(Pins.GPIO_PIN_A1);
            DeviceContext.AnalogPorts[2] = new AnalogInput(Pins.GPIO_PIN_A2);
            DeviceContext.AnalogPorts[3] = new AnalogInput(Pins.GPIO_PIN_A3);
            DeviceContext.AnalogPorts[4] = new AnalogInput(Pins.GPIO_PIN_A4);
            DeviceContext.AnalogPorts[5] = new AnalogInput(Pins.GPIO_PIN_A5);


            //a string representing the compiled version of the "basic" workflow
            //this string could be read from any non-volatile medium (e.g. SD, EEProm, etc)
            var data = @"uWRSWKB""1""SSvB000SAl000F059K4""2""F057l000zz";

            //decompile the string creating an activities tree
            var root = EngineContextRoot.Create(
                MicroWorkflowLookup.FunctionTable,
                data);

            //create a session holding the data of the task
            var session = new EngineSession(DeviceContext);

            //invoke the activities tree against the session
            root.Run(session);

            /**
             * NOTE: this example is minimal, with no threading, and no mutation of the running task.
             * That assumes the task will run forever, because there's no code for manage the engine.
             **/
        }
예제 #5
0
        protected override object OnRun(EngineSession session)
        {
            while ((bool)this.Condition.Run(session))
            {
                if (session.AbortReq)
                {
                    break;
                }

                object result = this.Body.Run(session);
            }

            return(null);
        }
예제 #6
0
        public object Run(EngineSession session)
        {
            int localCount = 0;

            if (this.Declarations != null &&
                (localCount = this.Declarations.Length) > 0)
            {
                for (int i = 0; i < localCount; i++)
                {
                    session.DataStack.Push(this.Declarations[i].CreateSurrogate());
                }
            }

            object result = this.OnRun(session);

            for (int i = 0; i < localCount; i++)
            {
                session.DataStack.Pop();
            }

            return(result);
        }
예제 #7
0
        /// <summary>
        /// Worker for a single instance of the workflow task
        /// </summary>
        private static void Logic()
        {
            Debug.Print("logic start");

            //create a session holding the data of the task
            _session = new EngineSession(DeviceContext);

            //worst way to catch errors, but...TODO
            try
            {
                //invoke the activities tree against the session
                object result = _root.Run(_session);
            }
            catch (Exception)
            {
                //do nothing
            }
            finally
            {
                _session = null;
            }

            Debug.Print("logic stop");
        }
예제 #8
0
 protected override object OnRun(EngineSession session)
 {
     return(null);
 }
예제 #9
0
 protected abstract object OnRun(EngineSession session);