示例#1
0
        private void FlowComponent_PreviewMouseUp(object sender, MouseButtonEventArgs e)
        {
            //// 마지막 클릭
            isDrag = false;

            if (endPoint == null)
            {
                endPoint = e.GetPosition(this);

                canvasArea.Children.Remove(hintLine);

                // 선 연결 하자.
                if (sender is FlowComponent flowComponent)
                {
                    if (startComponent != null)
                    {
                        endComponent = flowComponent;

                        ConnectLine(startComponent.FWSymbol, endComponent.FWSymbol);

                        startComponent = endComponent = null;
                    }
                }

                startPoint = endPoint = null;
            }

            FlowManager.Instance.FlowTool.Deselection();
        }
示例#2
0
 public ExecutionUnitDataBinding(FlowComponent myParent)
 {
     this.myParent  = myParent;
     InputRegex     = new ApplicationRegexOptions();
     OutputRegex    = new ApplicationRegexOptions();
     ConditionRegex = new ApplicationRegexOptions();
 }
示例#3
0
        public void Simple_Flow_Is_Deserialized()
        {
            TypeAbbreviationCache.RegisterFromAssembly(GetType().Assembly, failOnCollision: false);

            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true);

            var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder));

            flowBuilder.CreateFlow("TestFlow1")
            .AddRoot <IPipelineNode <object> >()
            .AddChild <ITestNode2>();

            var rootComponent = flowBuilder.RootComponent;

            var serializer = new JsonComponentSerializer();

            var definition = serializer.Serialize(rootComponent);

            FlowComponent <object> deserializedComponent = serializer.Deserialize <object>(definition);

            deserializedComponent.Should().NotBeNull();

            deserializedComponent.Children[0].Children.Count.Should().Be(1);
        }
        public void Flow_With_ShouldExecuteBlock_Is_Deserialized()
        {
            TypeAbbreviationCache.RegisterFromAssembly(GetType().Assembly, failOnCollision: false);

            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true);

            var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder));

            flowBuilder.CreateFlow("TestFlow1")
            .AddRoot <IPipelineNode <object> >().SetShouldExecuteBlock <ShouldNotExecuteTestBlock>()
            .AddChild <ITestJsNode>()
            .AddChild <ITestNode2>();

            var rootComponent = flowBuilder.RootComponent;

            var serializer = new JsonComponentSerializer();

            var definition = serializer.Serialize(rootComponent);

            FlowComponent <object> deserializedComponent = serializer.Deserialize <object>(definition);

            deserializedComponent.ShouldNotBeNull();

            deserializedComponent.Children[0].ShouldExecuteBlockType.ShouldEqual(typeof(ShouldNotExecuteTestBlock));
        }
示例#5
0
        public void Simple_Flow_With_ShouldExecuteJavaScript_Is_Deserialized()
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true);

            var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder));

            flowBuilder.CreateFlow("TestFlow1")
            .AddRoot <IPipelineNode <object> >()
            .AddChild <ITestJsNode>()
            .AddChild <ITestNode2>()
            .ForChild <ITestJsNode>()
            .SetShouldExecuteJavaScript("var x = 1;");

            var rootComponent = flowBuilder.RootComponent;

            var serializer = new JsonComponentSerializer();

            var definition = serializer.Serialize(rootComponent);

            FlowComponent <object> deserializedComponent = serializer.Deserialize <object>(definition);

            deserializedComponent.ShouldNotBeNull();

            var pipelineComponent = deserializedComponent.Children[0];

            pipelineComponent.Children.Count.ShouldEqual(2);

            var jsNode = pipelineComponent.Children[0];

            jsNode.GetShouldExecuteJavaScript().ShouldEqual("var x = 1;");
        }
示例#6
0
        private void DrawAction(Point point)
        {
            ActionTool actionTool = FlowManager.Instance.ActionTool;

            if (actionTool.SelectedAction != null)
            {
                Type          actionType    = actionTool.SelectedAction.GetType();
                FlowComponent flowComponent = null;
                FWProcess     fwProcess     = null;

                if (actionType.Equals(typeof(ActionInputValue)))
                {
                    fwProcess = new ActionInputValue();
                }
                else if (actionType.Equals(typeof(ActionCodeInjection)))
                {
                    fwProcess = new ActionCodeInjection();
                }
                else if (actionType.Equals(typeof(ActionMessageBox)))
                {
                    fwProcess = new ActionMessageBox();
                }
                else if (actionType.Equals(typeof(ActionListBoxAdd)))
                {
                    fwProcess = new ActionListBoxAdd();
                }
                else if (actionType.Equals(typeof(ActionListBoxRemove)))
                {
                    fwProcess = new ActionListBoxRemove();
                }
                // 앞으로 추가.
                else if (false)
                {
                }

                if (fwProcess != null)
                {
                    fwProcess.Left   = Math.Round(point.X);
                    fwProcess.Top    = Math.Round(point.Y);
                    fwProcess.Width  = 100;
                    fwProcess.Height = 30;

                    if (!FWSymbolList.Contains(fwProcess))
                    {
                        FWSymbolList.Add(fwProcess);
                    }

                    flowComponent = new FlowComponent(fwProcess, this);

                    flowComponent.PropertyChanged  += FlowComponent_PropertyChanged;
                    flowComponent.PreviewMouseDown += FlowComponent_PreviewMouseDown;
                    flowComponent.PreviewMouseUp   += FlowComponent_PreviewMouseUp;

                    canvasArea.Children.Add(flowComponent);

                    FlowManager.Instance.ActionTool.DeselectListBox();
                }
            }
        }
        public TestStandMapping()
        {
            PT_N2   = new PressureComponent(16, "PT_N2", "PT-N2", 400);
            PT_IPA  = new PressureComponent(17, "PT_IPA", "PT-IPA", 50);
            PT_N2O  = new PressureComponent(18, "PT_N2O", "PT-N2O", 50);
            PT_FUEL = new PressureComponent(19, "PT_FUEL", "PT-FUEL", 50);
            PT_OX   = new PressureComponent(20, "PT_OX", "PT-OX", 50);
            PT_CHAM = new PressureComponent(21, "PT_CHAM", "PT-CHAM", 50);

            TC_IPA = new TemperatureComponent(8, "TC_IPA", "TC-IPA", x => x);
            TC_N2O = new TemperatureComponent(9, "TC_N2O", "TC-N2O", x => x);
            TC_1   = new TemperatureComponent(10, "TC_1", "TC-1", x => x);
            TC_2   = new TemperatureComponent(11, "TC_2", "TC-2", x => x);
            TC_3   = new TemperatureComponent(12, "TC_3", "TC-3", x => x);
            TC_4   = new TemperatureComponent(13, "TC_4", "TC-4", x => x);
            TC_5   = new TemperatureComponent(14, "TC_5", "TC-5", x => x);
            TC_6   = new TemperatureComponent(15, "TC_6", "TC-6", x => x);

            LOAD = new LoadComponent(0, "LOAD", "Load cell");

            SV_IPA = new SolenoidComponent(4, "SV_IPA", "SV-IPA", "SV_IPA_SYMBOL");
            SV_N2O = new SolenoidComponent(5, "SV_N2O", "SV-N2O", "SV_N2O_SYMBOL");
            MV_IPA = new ServoComponent(6, "MV_IPA", "MV-IPA", "MV_IPA_SYMBOL");
            MV_N2O = new ServoComponent(7, "MV_N2O", "MV-N2O", "MV_N2O_SYMBOL");

            TARGET_MV_IPA = new SimpleComponent(25, 2, false, "TARGET-MV-IPA", "TARGET-MV-IPA [%]", x => ((float)x) / ushort.MaxValue * 100.0f);
            TARGET_MV_N2O = new SimpleComponent(26, 2, false, "TARGET-MV-N20", "TARGET-MV-N20 [%]", x => ((float)x) / ushort.MaxValue * 100.0f);

            SN_N2O_FILL = new SolenoidComponent(2, "SN_N2O_FILL", "SN-N2O-FILL", "SN_N2O_FILL_SYMBOL");
            SN_FLUSH    = new SolenoidComponent(3, "SN_FLUSH", "SN-FLUSH", "SN_FLUSH_SYMBOL");

            BATTERY = new VoltageComponent(22, "BATTERY", "BATTERY", 12.0f, 14.8f);

            FLO_IPA = new FlowComponent(100, "FLO_IPA", "FLO-IPA", ref PT_FUEL, ref PT_CHAM, () => PreferenceManager.Manager.Preferences.Fluid.Fuel);
            FLO_N2O = new FlowComponent(101, "FLO_N2O", "FLO-N2O", ref PT_N2O, ref PT_CHAM, () => PreferenceManager.Manager.Preferences.Fluid.Oxid);

            T_IPA = new TankComponent(24, "FUEL", "FUEL", "FUEL_GRADIENT", ref FLO_IPA, "Fuel");
            T_N2O = new LevelComponent(1, "OXID", "OXID", "OXID_GRADIENT", 20);

            STACK_HEALTH = new StackHealthComponent(23, "STACK_MAIN", "STACK_ACTUATOR", "STACK_SENSOR", "STACK-HEALTH");
            _states      = new List <State>
            {
                new State(0, "Idle"),
                new State(1, "Ignition"),
                new State(2, "Pre-Stage 1"),
                new State(3, "Pre-Stage 2"),
                new State(4, "Ramp up"),
                new State(5, "Regulated"),
                new State(6, "Shutdown 1"),
                new State(7, "Shutdown 2"),
                new State(8, "Flush")
            };
            EmergencyState = _states[6];

            PreferenceManager.Manager.Preferences.AutoSequenceComponentIDs.ChamberPressureID      = PT_CHAM.BoardID;
            PreferenceManager.Manager.Preferences.AutoSequenceComponentIDs.FuelLinePressureID     = PT_FUEL.BoardID;
            PreferenceManager.Manager.Preferences.AutoSequenceComponentIDs.OxidizerLinePressureID = PT_OX.BoardID;
        }
示例#8
0
        /// <summary>
        /// Gets the components Executed JavaScript.
        /// </summary>
        /// <typeparam name="T">Subject type of the component builder.</typeparam>
        /// <param name="component">Component to query for the Executed JavaScript.</param>
        /// <returns>The requested script.</returns>
        public static string GetExecutedJavaScript <T>(this FlowComponent <T> component)
        {
            if (component.MetaData.ContainsKey(JavaScriptMetaDataBuilder.MetaDataKeys.ExecutedScript))
            {
                return((string)component.MetaData[JavaScriptMetaDataBuilder.MetaDataKeys.ExecutedScript]);
            }

            return(null);
        }
示例#9
0
        /// <summary>
        /// Gets the components Custom Data.
        /// </summary>
        /// <typeparam name="T">Subject type of the component builder.</typeparam>
        /// <param name="component">Component to query for the Custom Data.</param>
        /// <returns>The requested custom data.</returns>
        public static dynamic GetCustomData <T>(this FlowComponent <T> component)
        {
            if (component.MetaData.ContainsKey(CustomDataMetaDataBuilder.MetaDataKeys.CustomData))
            {
                return(component.MetaData[CustomDataMetaDataBuilder.MetaDataKeys.CustomData]);
            }

            return(null);
        }
示例#10
0
        public string Serialize <T>(FlowComponent <T> component)
        {
            using (var sw = new StringWriter())
                using (JsonWriter writer = new JsonTextWriter(sw))
                {
                    _serializer.Serialize(writer, component);

                    return(sw.ToString());
                }
        }
 /// <summary>
 /// Creates a list item containing this component.
 /// </summary>
 /// <param name="content"></param>
 /// <param name="displaySetup"></param>
 /// <param name="classes">The classes on the item.</param>
 /// <param name="visualOrderRank"></param>
 /// <param name="updateRegionSets">The intermediate-post-back update-region sets that this item will be a part of.</param>
 /// <param name="etherealContent"></param>
 public static ComponentListItem ToComponentListItem(
     this FlowComponent content, DisplaySetup displaySetup = null, ElementClassSet classes = null, int?visualOrderRank = null,
     IEnumerable <UpdateRegionSet> updateRegionSets        = null, IReadOnlyCollection <EtherealComponent> etherealContent = null) =>
 content.ToCollection()
 .ToComponentListItem(
     displaySetup: displaySetup,
     classes: classes,
     visualOrderRank: visualOrderRank,
     updateRegionSets: updateRegionSets,
     etherealContent: etherealContent);
        public bool Execute()
        {
            if (BaseApplication.MainInstance == null)
            {
                //ramane apoi sa le numaram sa fie ok
                BaseApplication.MainInstance = new BaseApplication(1000);
            }
            FlowComponent       current = StartNode.GetDefaultNextControl();
            ExecutionUnitOutput eo      = null;
            Object dataToken            = null;

            while ((current != null) && (!(current is FlowStop)))
            {
                //trecem la urmatorul nod si executam tot ce se poate:d
                //procesam datele
                if (current is FlowProcessing)
                {
                    //eo=(current as ProcessingBlock).ProcessData(dataToken, BaseApplication.MainInstance);
                    //dataToken = (current as ProcessingBlock).ProcessData(dataToken, BaseApplication.MainInstance);
                    //if (dataToken == null) return false;
                    eo        = (current as FlowProcessing).ExecutionUnit.Execute(dataToken);
                    dataToken = eo.ObjectOutput;
                    if (dataToken == null)
                    {
                        return(false);
                    }

                    current = current.GetDefaultNextControl();
                }
                else if (current is FlowDecision)
                {
                    eo        = (current as FlowDecision).ExecutionUnit.Execute(dataToken);
                    dataToken = eo.ObjectOutput;
                    bool cond = eo.DecisionOutput;
                    //bool cond = (current as DecisionBlock).EvaluateCondition(dataToken, BaseApplication.MainInstance);
                    //dataToken = (current as DecisionBlock).GetData(dataToken, BaseApplication.MainInstance);
                    if (dataToken == null)
                    {
                        return(false);
                    }
                    if (cond)
                    {
                        current = (current as FlowDecision).GetDefaultNextControl();
                    }
                    else
                    {
                        current = ((current as FlowDecision).GetNegationNextControl() as FlowComponent);
                    }
                }
            }
            return(true);
        }
示例#13
0
        public PageTree(
            PageComponent rootComponent, Action <string> idSetter,
            Func <string, ErrorSourceSet, ImmutableDictionary <EwfValidation, IReadOnlyCollection <string> > > modificationErrorGetter, FlowComponent etherealContainer,
            FlowComponent jsInitElement, StringBuilder elementJsInitStatements)
        {
            this.idSetter = idSetter;
            this.modificationErrorGetter = modificationErrorGetter;
            this.etherealContainer       = etherealContainer;
            this.jsInitElement           = jsInitElement;
            this.elementJsInitStatements = elementJsInitStatements;

            rootNode = buildNode(rootComponent, new IdGenerator(), false, false);

            AllNodes = new List <PageNode>(nodeCount);
            addTreeToAllNodes(rootNode);
        }
示例#14
0
        public async void Deserialized_Flow_Component_Can_Be_Built_And_Run()
        {
            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true);
            containerBuilder.RegisterBanzaiNodes(typeof(JavaScriptMetaDataBuilder).Assembly, true);

            var flowBuilder = new FlowBuilder <TestObjectA>(new AutofacFlowRegistrar(containerBuilder));

            flowBuilder.CreateFlow("TestFlow1")
            .AddRoot <IPipelineNode <TestObjectA> >()
            .AddChild <ITestJsNode2>()
            .AddChild <ITestNode2>()
            .ForChild <ITestJsNode2>()
            .SetExecutedJavaScript("context.Subject.TestValueString = 'Hello JavaScript';");

            var rootComponent = flowBuilder.RootComponent;

            var serializer = new JsonComponentSerializer();

            var definition = serializer.Serialize(rootComponent);

            Console.WriteLine(definition);

            FlowComponent <TestObjectA> deserializedComponent = serializer.Deserialize <TestObjectA>(definition);

            deserializedComponent.ShouldNotBeNull();

            flowBuilder.RootComponent = deserializedComponent;

            flowBuilder.Register();

            var container = containerBuilder.Build();

            var factory = container.Resolve <INodeFactory <TestObjectA> >();

            var flowRootNode = factory.BuildFlow("TestFlow1");

            NodeResult result = await flowRootNode.ExecuteAsync(new TestObjectA());

            result.Status.ShouldEqual(NodeResultStatus.Succeeded);

            var subject = result.GetSubjectAs <TestObjectA>();

            subject.TestValueString.ShouldEqual("Hello JavaScript");
        }
示例#15
0
        private void DrawSymbol(Type type, Point point)
        {
            FlowComponent flowComponent = null;
            FWSymbol      fwSymbol      = null;

            if (type.Equals(typeof(FWTerminal)))
            {
                fwSymbol = new FWTerminal();
            }
            else if (type.Equals(typeof(FWReady)))
            {
                fwSymbol = new FWReady();
            }
            else if (type.Equals(typeof(FWProcess)))
            {
                fwSymbol = new FWProcess();
            }
            else if (type.Equals(typeof(FWDecision)))
            {
                fwSymbol = new FWDecision();
            }

            if (fwSymbol != null)
            {
                fwSymbol.Left   = Math.Round(point.X);
                fwSymbol.Top    = Math.Round(point.Y);
                fwSymbol.Width  = 100;
                fwSymbol.Height = 30;

                if (!FWSymbolList.Contains(fwSymbol))
                {
                    FWSymbolList.Add(fwSymbol);
                }

                flowComponent = new FlowComponent(fwSymbol, this);

                flowComponent.PropertyChanged  += FlowComponent_PropertyChanged;
                flowComponent.PreviewMouseDown += FlowComponent_PreviewMouseDown;
                flowComponent.PreviewMouseUp   += FlowComponent_PreviewMouseUp;

                canvasArea.Children.Add(flowComponent);

                FlowManager.Instance.FlowTool.Deselection();
            }
        }
示例#16
0
        private void Grid_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (isDrag)
            {
                isDrag = false;

                startPoint = endPoint = null;

                startComponent = null;
                endComponent   = null;

                canvasArea.Children.Remove(hintLine);

                FlowManager.Instance.FlowTool.Deselection();

                Deselect();
            }
        }
示例#17
0
        public void DeleteSymbol(FlowComponent flowComponent)
        {
            FWSymbol fwSymbol = flowComponent.FWSymbol;

            if (fwSymbol.StartConnector != null)
            {
                fwSymbol.StartConnector.EndConnector = null;
            }

            if (fwSymbol.EndConnector != null)
            {
                fwSymbol.EndConnector.StartConnector = null;
            }

            FWSymbolList.Remove(fwSymbol);

            canvasArea.Children.Remove(flowComponent);
        }
        private void newToolStripButton_Click(object sender, EventArgs e)
        {
            FlowComponents.Clear();
            this.pnlMain.Controls.Clear();
            this.FlowConnectors.Clear();

            FlowStart fs = new FlowStart();

            StartNode = fs;
            this.SuspendLayout();
            this.pnlMain.Controls.Add(fs);
            fs.SetComponentContainer(this);
            fs.Left = (this.pnlMain.Width - fs.Width) / 2;
            fs.Top  = 50;
            FlowComponents.Add(fs);
            this.AddFlowComponent(fs);
            this.ResumeLayout();
        }
示例#19
0
        private void ConnectLine(FWSymbol startConnector, FWSymbol endConnector)
        {
            if (startConnector.EndConnector != null)
            {
                return;
            }

            FWLine fwLine = new FWLine
            {
                StartConnector = startConnector,
                EndConnector   = endConnector
            };

            if (startConnector is FWDecision fwDecision)
            {
                if (fwDecision.EndConnector[0] == null)
                {
                    fwDecision.EndConnector[0] = fwLine;
                }
                else if (fwDecision.EndConnector[1] == null)
                {
                    fwDecision.EndConnector[1] = fwLine;
                }
                else
                {
                    return;
                }

                endConnector.StartConnector = fwLine;
            }
            else
            {
                startConnector.EndConnector = fwLine;
                endConnector.StartConnector = fwLine;
            }

            FWSymbolList.Add(fwLine);

            DrawFlowPath(fwLine, startConnector, endConnector);

            FlowComponent flowComponent = new FlowComponent(fwLine, this);

            canvasArea.Children.Add(flowComponent);
        }
 public FlowComponentXML(FlowComponent fc)
 {
     this.left = (fc as Control).Left;
     this.top  = (fc as Control).Top;
     this.data = (ExecutionUnitDataBinding)fc.GetDataBinding();
     if (fc is FlowStart)
     {
         this.type = 1;
     }
     if (fc is FlowStop)
     {
         this.type = 2;
     }
     if (fc is FlowProcessing)
     {
         this.type = 3;
     }
     if (fc is FlowDecision)
     {
         this.type = 4;
     }
     if (this.type == 4)
     {
         //avem doi copii
         if (fc.GetDefaultNextControl() != null)
         {
             next1 = new FlowComponentXML(fc.GetDefaultNextControl());
         }
         if ((fc as FlowDecision).GetNegationNextControl() != null)
         {
             next2 = new FlowComponentXML((fc as FlowDecision).GetNegationNextControl() as FlowComponent);
         }
     }
     else
     {
         //avem un singur copil
         if (fc.GetDefaultNextControl() != null)
         {
             next1 = new FlowComponentXML(fc.GetDefaultNextControl());
         }
     }
 }
        public FlowDiagram()
        {
            InitializeComponent();
            sg.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
            bg.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
            sg.Width     = 1;
            bg.Width     = 1;
            //incarcam o diagrama de start
            FlowStart fs = new FlowStart();

            StartNode = fs;
            this.SuspendLayout();
            this.pnlMain.Controls.Add(fs);
            fs.SetComponentContainer(this);
            fs.Left = (this.pnlMain.Width - fs.Width) / 2;
            fs.Top  = 50;
            FlowComponents.Add(fs);
            this.AddFlowComponent(fs);
            this.ResumeLayout();
        }
        private object RebuildUI(FlowComponentXML fcx)
        {
            //throw new NotImplementedException();
            //FlowComponentXML current = fdx.FlowTree;
            //while (
            FlowComponent fc = null;

            if (fcx.type == 1)
            {
                fc             = new FlowStart();
                this.StartNode = fc;
            }
            else if (fcx.type == 2)
            {
                fc = new FlowStop();
            }
            else if (fcx.type == 3)
            {
                fc = new FlowProcessing();
            }
            else if (fcx.type == 4)
            {
                fc = new FlowDecision();
            }
            fc.SetComponentContainer(this);
            this.flowComponents.Add(fc as Control);
            this.pnlMain.Controls.Add(fc as Control);
            fc.SetDataBinding(fcx.data);
            fc.SetName(fcx.data.Name);
            (fc as Control).Left = fcx.left;
            (fc as Control).Top  = fcx.top;
            if (fcx.next1 != null)
            {
                fc.SetDefaultNextControl(RebuildUI(fcx.next1) as Control);
            }
            if (fcx.next2 != null)
            {
                (fc as FlowDecision).SetNegationNextControl(RebuildUI(fcx.next2) as Control);
            }
            return(fc);
        }
示例#23
0
        private void FlowComponent_PreviewMouseDown(object sender, MouseButtonEventArgs e)
        {
            Type type = FlowManager.Instance.FlowTool.SelectedFWSymbol;

            if (type != null)
            {
                if (type.Equals(typeof(FWLine)))
                {
                    if (e.ChangedButton == MouseButton.Left)
                    {
                        isDrag = true;

                        if (startPoint == null)
                        {
                            startPoint = e.GetPosition(this);
                            Point pt = startPoint.Value;

                            hintLine = new Line
                            {
                                Stroke          = Brushes.Black,
                                StrokeThickness = 4,
                                X1 = pt.X,
                                Y1 = pt.Y,
                                X2 = pt.X,
                                Y2 = pt.Y
                            };

                            canvasArea.Children.Add(hintLine);

                            if (sender is FlowComponent flowComponent)
                            {
                                if (startComponent == null)
                                {
                                    startComponent = flowComponent;
                                }
                            }
                        }
                    }
                }
            }
        }
示例#24
0
        public void Validate_Correct_Volume_Calculation()
        {
            TestStandMapping mapping = new TestStandMapping();
            Session          session = new Session(mapping);

            float fuelCV   = 0.0738f;
            float fuelDens = 786;

            PressureComponent p1 = (mapping.ComponentsByID()[19] as PressureComponent);
            PressureComponent p2 = (mapping.ComponentsByID()[21] as PressureComponent);
            FlowComponent     fl = (mapping.ComponentsByID()[100] as FlowComponent);
            TankComponent     tc = (mapping.ComponentsByID()[24] as TankComponent);

            tc.SetInputVolume(0, 4);
            p2.Set(0);

            p1.Set(670); // 670.2545453 = 10 bar
            fl.Compute();
            tc.Compute(0);

            p1.Set(730); // 729.8327273 = 12 bar
            fl.Compute();
            tc.Compute(750);

            p1.Set(789); // 789.4109090 = 14 bar
            fl.Compute();
            tc.Compute(1500);

            p1.Set(849); // 848.9890910 = 16 bar
            fl.Compute();
            tc.Compute(2250);

            p1.Set(909); // 908.5672727 = 18 bar
            fl.Compute();
            tc.Compute(3000);

            float volume = tc.CurrentVolume;

            Assert.AreEqual(3.832606742, volume, 0.1);
        }
示例#25
0
        public async void Deserialized_Flow_Component_Can_Be_Built_And_Run()
        {
            TypeAbbreviationCache.RegisterFromAssembly(GetType().Assembly, failOnCollision: false);

            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true);

            var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder));

            flowBuilder.CreateFlow("TestFlow1")
            .AddRoot <IPipelineNode <object> >()
            .AddChild <ITestNode2>();

            var rootComponent = flowBuilder.RootComponent;

            var serializer = new JsonComponentSerializer();

            string definition = serializer.Serialize(rootComponent);

            Console.WriteLine(definition);

            FlowComponent <object> deserializedComponent = serializer.Deserialize <object>(definition);

            flowBuilder.RootComponent = deserializedComponent;

            flowBuilder.Register();

            var container = containerBuilder.Build();

            var factory = container.Resolve <INodeFactory <object> >();

            var flowRootNode = factory.BuildFlow("TestFlow1");

            NodeResult result = await flowRootNode.ExecuteAsync(new object());

            result.Status.ShouldEqual(NodeResultStatus.Succeeded);
        }
示例#26
0
        public async Task Deserialized_Flow_Component_With_ShouldExecuteBlock_Can_Be_Built_And_Attempted()
        {
            TypeAbbreviationCache.RegisterFromAssembly(GetType().Assembly, failOnCollision: false);

            var containerBuilder = new ContainerBuilder();

            containerBuilder.RegisterBanzaiNodes(GetType().Assembly, true);

            var flowBuilder = new FlowBuilder <object>(new AutofacFlowRegistrar(containerBuilder));

            flowBuilder.CreateFlow("TestFlowDeserializeShouldExecute")
            .AddRoot <IPipelineNode <object> >().SetShouldExecuteBlock <ShouldNotExecuteTestBlock>()
            .AddChild <ITestNode2>();

            var rootComponent = flowBuilder.RootComponent;

            var serializer = new JsonComponentSerializer();

            string definition = serializer.Serialize(rootComponent);

            FlowComponent <object> deserializedComponent = serializer.Deserialize <object>(definition);

            flowBuilder.RootComponent = deserializedComponent;

            flowBuilder.Register();

            var container = containerBuilder.Build();

            var factory = container.Resolve <INodeFactory <object> >();

            var flowRootNode = factory.BuildFlow("TestFlowDeserializeShouldExecute");

            NodeResult result = await flowRootNode.ExecuteAsync(new object());

            result.Status.Should().Be(NodeResultStatus.NotRun);
        }
示例#27
0
 /// <summary>
 /// Creates a form item with this component.
 /// </summary>
 /// <param name="content">Do not pass null.</param>
 /// <param name="setup"></param>
 /// <param name="label">The form-item label.</param>
 /// <param name="validation"></param>
 public static FormItem ToFormItem(
     this FlowComponent content, FormItemSetup setup = null, IReadOnlyCollection <PhrasingComponent> label = null, EwfValidation validation = null) =>
 content.ToCollection().ToFormItem(setup: setup, label: label, validation: validation);
示例#28
0
 public UiPageContent Add(FlowComponent component)
 {
     content.Add(component);
     return(this);
 }
示例#29
0
 /// <summary>
 ///     Registers the constructed flow with Ninject.
 /// </summary>
 /// <typeparam name="T">Type of the flows subject.</typeparam>
 /// <param name="flowRoot">Root of the flow to register.</param>
 public void RegisterFlow <T>(FlowComponent <T> flowRoot)
 {
     _kernel.Bind <FlowComponent <T> >().ToConstant(flowRoot)
     .Named(flowRoot.Name);
 }
 public frmChooseNextComponent(FlowComponent fc)
 {
     InitializeComponent();
     this.fc = fc;
 }