Exemplo n.º 1
0
 public void EnsureStaticInitializerDoesNotThrowForValidType()
 {
     Assert.DoesNotThrow(
         () =>
         SimpleComponent.VerifyGenericParameters(typeof(ISimpleComponent),
                                                 typeof(IWriteableSimpleComponent)));
 }
Exemplo n.º 2
0
        public void ComponentThrowsWhenCopyingToDifferentComponentType()
        {
            IComponent c1 = new SimpleComponent();
            IComponent c2 = new OtherSimpleComponent();

            Should.Throw <ArgumentException>(() => { c1.CopyTo(c2); });
        }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        public void ComponentThrowsWhenCopyingToDifferentComponentType()
        {
            IComponent c1 = new SimpleComponent();
            IComponent c2 = new OtherSimpleComponent();

            Should.Throw<ArgumentException>(() =>
            {
                c1.CopyTo(c2);
            });
        }
Exemplo n.º 5
0
 private static void Main()
 {
     using (var component = new SimpleComponent())
     {
         for (int i = 0; i < 10; i++)
         {
             Console.WriteLine(component.Welcome("Stephanie"));
         }
     }
 }
Exemplo n.º 6
0
        public void SimpleContainment()
        {
            ContainerComponent cc = new ContainerComponent();

            cc.Add(new Component());
            SimpleComponent sc = new SimpleComponent();

            cc.Add(sc);

            Assert.IsTrue(sc.sited);
        }
Exemplo n.º 7
0
 static void Main(string[] args)
 {
     // using is used to release the object before GC performs the cleanup
     using (SimpleComponent obj = new SimpleComponent())
     {
         Console.WriteLine(obj.GetType().ToString());
         for (int i = 0; i < 10; i++)
         {
             Console.WriteLine(obj.Welcome("Vaibhav"));
         }
     }
 }
Exemplo n.º 8
0
        public async Task TestLoadAsync()
        {
            using (ISession s = OpenSession())
                using (ITransaction t = s.BeginTransaction())
                {
                    SimpleComponent simpleComp = (SimpleComponent)await(s.LoadAsync(typeof(SimpleComponent), 10L));

                    Assert.AreEqual(10L, simpleComp.Key);
                    Assert.AreEqual("TestCreated", simpleComp.Audit.CreatedUserId);
                    Assert.AreEqual("TestUpdated", simpleComp.Audit.UpdatedUserId);

                    await(t.CommitAsync());
                }
        }
Exemplo n.º 9
0
        public void TestLoad()
        {
            using (ISession s = OpenSession())
                using (ITransaction t = s.BeginTransaction())
                {
                    SimpleComponent simpleComp = (SimpleComponent)s.Load(typeof(SimpleComponent), 10L);

                    Assert.AreEqual(10L, simpleComp.Key);
                    Assert.AreEqual("TestCreated", simpleComp.Audit.CreatedUserId);
                    Assert.AreEqual("TestUpdated", simpleComp.Audit.UpdatedUserId);

                    t.Commit();
                }
        }
Exemplo n.º 10
0
 public void AddComponent(SimpleComponent component)
 {
     _components.Add(component);
     if (component is ISimpleUpdateable)
     {
         _updateableComponents.Add(component as ISimpleUpdateable);
     }
     if (component is ISimpleDrawable)
     {
         _drawableComponents.Add(component as ISimpleDrawable);
     }
     if (component is ISimpleNetworking)
     {
         _networkingComponents.Add(component as ISimpleNetworking);
     }
     component.SetOwner(this);
 }
Exemplo n.º 11
0
        public void ServiceContainment()
        {
            ServiceContainer parent = new ServiceContainer();

            parent.AddService(typeof(ContainerComponentTests), this);

            ContainerComponent child = new ContainerComponent();
            SimpleComponent    sc    = new SimpleComponent();

            child.Add(sc);

            Assert.IsNull(((IServiceProvider)child).GetService(
                              typeof(ContainerComponentTests)));

            parent.Add(child);

            Assert.AreSame(this, ((IServiceProvider)parent).GetService(
                               typeof(ContainerComponentTests)));
        }
Exemplo n.º 12
0
        protected override void OnSetUp()
        {
            using (ISession s = OpenSession())
                using (ITransaction t = s.BeginTransaction())
                {
                    // create a new
                    SimpleComponent simpleComp = new SimpleComponent();
                    simpleComp.Name                = "Simple 1";
                    simpleComp.Address             = "Street 12";
                    simpleComp.Date                = testDateTime;
                    simpleComp.Count               = 99;
                    simpleComp.Audit.CreatedDate   = DateTime.Now;
                    simpleComp.Audit.CreatedUserId = "TestCreated";
                    simpleComp.Audit.UpdatedDate   = DateTime.Now;
                    simpleComp.Audit.UpdatedUserId = "TestUpdated";

                    s.Save(simpleComp, 10L);

                    t.Commit();
                }
        }
Exemplo n.º 13
0
        public void AddComponentState(SimpleComponent component, string enableState, string disableState)
        {
            var state = new StateString(component, enableState, disableState);

            States.Add(state);
        }
Exemplo n.º 14
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter != null)
            {
                OfflineMode = true;
                cache.Fill  = (SolidColorBrush)Application.Current.Resources["AcrylicMessageBackground"];
            }
            grid.Opacity         = 0;
            grid.Visibility      = Visibility.Collapsed;
            LoadingRing.IsActive = true;
            base.OnNavigatedTo(e);

            LoadingRing.Visibility = Visibility.Visible;
            status = await StatusPage.GetStatus();

            if (status == null)
            {
                FailedToLoad.Visibility = Visibility.Visible;
                return;
            }
            else
            {
                FailedToLoad.Visibility = Visibility.Collapsed;
            }
            if (status.Incidents != null)
            {
                foreach (var incident in status.Incidents)
                {
                    if (incident.Status != "resolved")
                    {
                        List <SimpleComponent> updates = new List <SimpleComponent>();
                        for (int i = 0; i < incident.IncidentUpdates.Length; i++)
                        {
                            updates.Add(new SimpleComponent()
                            {
                                Status      = incident.IncidentUpdates[i].Status,
                                Description = incident.IncidentUpdates[i].Body,
                                Name        = incident.IncidentUpdates[i].UpdatedAt.ToString("t")
                            });
                        }
                        ComplexComponent sc = new ComplexComponent()
                        {
                            Name   = incident.Name,
                            Status = incident.Status,
                            Color  = ColorFromStatus(incident.Status),
                            Items  = updates
                        };

                        if (!string.IsNullOrWhiteSpace(sc.Name))
                        {
                            IncidentsPanel.Items.Add(sc);
                        }
                    }
                }
            }

            if (IncidentsPanel.Items.Count > 0)
            {
                IncidentsPanel.Visibility    = Visibility.Visible;
                IncidentsScroller.Visibility = Visibility.Visible;
            }
            else
            {
                IncidentsPanel.Visibility    = Visibility.Collapsed;
                IncidentsScroller.Visibility = Visibility.Collapsed;
            }

            if (status.Status != null)
            {
                var statusBrush = ColorFromStatus(status.Status.Indicator);
                statusColor = statusBrush.Color;
                statusContainer.Background = statusBrush;
                border.BorderBrush         = statusBrush;
                //dayDuration.Foreground = statusBrush;
                //weekDuration.Foreground = statusBrush;
                //monthDuration.Foreground = statusBrush;
                IncidentsScroller.Background = new SolidColorBrush(statusBrush.Color)
                {
                    Opacity = 0.25
                };
                statusDescription.Text     = status.Status.Description;
                statusContainer.Visibility = Visibility.Visible;
            }
            if (status.Components != null)
            {
                foreach (var component in status.Components)
                {
                    SimpleComponent sc = new SimpleComponent()
                    {
                        Name        = component.Name,
                        Status      = component.Status.Replace("_", " "),
                        Color       = ColorFromStatus(component.Status),
                        Description = component.Description
                    };
                    ComponentsPanel.Items.Add(sc);
                }
            }
            grid.Visibility = Visibility.Visible;
            scale2.CenterY  = grid.ActualHeight / 2;
            scale2.CenterX  = grid.ActualWidth / 2;
            LoadIn.Begin();
            ShowMetrics("day");
        }
Exemplo n.º 15
0
 public StateString(SimpleComponent component, string enableState, string disableState)
 {
     Component    = component;
     EnableState  = enableState;
     DisableState = disableState;
 }
Exemplo n.º 16
0
 public void EnsureStaticInitalizerThrowsForInvalidWriteableComponentInterface()
 {
     Assert.Throws <NotSupportedException>(
         () => SimpleComponent.VerifyGenericParameters(typeof(ISimpleComponent), typeof(IWriteableComponent)));
 }
Exemplo n.º 17
0
 public void AddComponentState(SimpleComponent component, IStateComponent stateComponent)
 {
     States.Add(component, stateComponent);
 }