Пример #1
0
        public virtual void ComponentStateRequestOccurred(ComponentStateRequest <PidState> stateRequest)
        {
            if (stateRequest.Location == Location)
            {
                PriorState   = CurrentState;
                CurrentState = stateRequest.UpdateState(CurrentState.Clone());

                if (!PriorState.IsEngaged && CurrentState.IsEngaged && _publishPidDisengageRequest != null)
                {
                    foreach (var location in LocationHelper.PidLocations.Where(loc => loc != Location))
                    {
                        _publishPidDisengageRequest(new ComponentStateRequest <PidState> {
                            Location = location,
                            Updates  = (disengageState) => {
                                disengageState.IsEngaged = false;
                            }
                        });
                    }
                }

                //TODO: Determine if this needs to be published at all.
                _publishPidStateChanged(CreateComponentStateChange());

                Refresh();
            }
        }
Пример #2
0
        public void DisablingPidDisablesSsrs()
        {
            var Utils = CreateUtils(Location.HLT, new PidState {
                IsEngaged   = true,
                SetPoint    = Temperature.BoilingTemp,
                Temperature = Temperature.BoilingTemp
            });

            ComponentStateRequest <SsrState> ssrRequest = null;

            Utils.MockHub.Setup(hb => hb.Publish <ComponentStateRequest <SsrState> >(It.IsAny <ComponentStateRequest <SsrState> >()))
            .Callback <ComponentStateRequest <SsrState> >((req) => ssrRequest = req);

            Utils.Pid.ComponentStateRequestPublisher(Utils.Hub.Publish <ComponentStateRequest <SsrState> >);

            Utils.Pid.ComponentStateRequestOccurred(new ComponentStateRequest <PidState> {
                Location = Location.HLT,
                Updates  = (state) => {
                    state.IsEngaged = false;
                }
            });

            Assert.True(ssrRequest != null, "ComponentStateRequest<SsrState> was never published");
            var ssrState = ssrRequest.UpdateState(new SsrState());

            Assert.True(ssrState.IsEngaged == false, "Ssr request wasn't to disengage");
        }
Пример #3
0
        public void ThermoChangeTriggersSsrRequest()
        {
            var Utils = CreateUtils(Location.HLT, new PidState {
                IsEngaged   = true,
                SetPoint    = 140,
                Temperature = Temperature.RoomTemp
            });

            ComponentStateRequest <SsrState> ssrRequest = null;

            Utils.MockHub.Setup(hb => hb.Publish <ComponentStateRequest <SsrState> >(It.IsAny <ComponentStateRequest <SsrState> >()))
            .Callback <ComponentStateRequest <SsrState> >((req) => ssrRequest = req);

            Utils.Pid.ComponentStateRequestPublisher(Utils.Hub.Publish <ComponentStateRequest <SsrState> >);

            Utils.Pid.ComponentStateChangeOccurred(new ComponentStateChange <ThermocoupleState> {
                Location     = Location.HLT,
                CurrentState = new ThermocoupleState {
                    Temperature = Temperature.RoomTemp + 10
                }
            });

            Assert.True(ssrRequest != null, "ComponentStateRequest<SsrState> was never published");

            var updatedSsrState = ssrRequest.UpdateState(new SsrState());

            Assert.True(updatedSsrState.Percentage == 100, "Requested Ssr Percentage was not equal to 100");

            // This is no longer needed but lets keep it so we know how to do it next time.
            //Utils.MockHub.Verify(hb => hb.Publish(It.Is<ComponentStateRequest<SsrState>>(req => req.Location == Location.HLT)));
        }
Пример #4
0
        public virtual void ComponentStateRequestOccurred(ComponentStateRequest <SsrState> stateRequest)
        {
            if (stateRequest.Location == Location)
            {
                PriorState   = CurrentState;
                CurrentState = stateRequest.UpdateState(CurrentState.Clone());

                var publishChanges = false;
                if (PriorState.Percentage != CurrentState.Percentage)
                {
                    CalculateDurations();
                    publishChanges = true;
                }

                if (!PriorState.IsEngaged && CurrentState.IsEngaged)
                {
                    Start();
                    publishChanges = true;
                }

                if (publishChanges)
                {
                    _publishSsrStateChanged(CreateComponentStateChange());
                }
            }
        }