コード例 #1
0
        public override void ProcessRunningDirectiveResult(DirectiveData data, CommunicationEventArgs comEventArgs)
        {
            var ret = data as RockerDirectiveData;

            if (CurrentStatus == DeviceStatusEnum.Startting)
            {
                //从tryStart变为running(真的开始)
                if (ret?.Speed > 0)
                {
                    CurrentStatus             = DeviceStatusEnum.Running;
                    comEventArgs.DeviceStatus = DeviceStatusEnum.Running;

                    StartEvent.TrySetResult(new DeviceIOResult(true));

                    OnCommunicationChange(comEventArgs);
                    StartRunningLoop();
                }
                else
                {
                    comEventArgs.DeviceStatus = CurrentStatus;
                    StartRunningLoop();
                }
            }
            else if (CurrentStatus == DeviceStatusEnum.Running)
            {
                comEventArgs.DeviceStatus = DeviceStatusEnum.Running;
                StartRunningLoop();
            }
            else
            {
                comEventArgs.DeviceStatus = DeviceStatusEnum.Error;
            }
        }
コード例 #2
0
        //传感器只收发普通轮询指令
        public override void ProcessRunningDirectiveResult(DirectiveData data, CommunicationEventArgs comEventArgs)
        {
            if (CurrentStatus == DeviceStatusEnum.Startting)
            {
                SetStatus(DeviceStatusEnum.Running);
                comEventArgs.DeviceStatus = DeviceStatusEnum.Running;

                StartEvent.TrySetResult(new DeviceIOResult(true));

                OnCommunicationChange(comEventArgs);
                StartRunningLoop();
            }
            else if (CurrentStatus == DeviceStatusEnum.Running)
            {
                comEventArgs.DeviceStatus = DeviceStatusEnum.Running;
                StartRunningLoop();
            }
        }
コード例 #3
0
        public override void ProcessRunningDirectiveResult(DirectiveData data, CommunicationEventArgs comEventArgs)
        {
            var ret = data as PumpDirectiveData;

            if (CurrentStatus == DeviceStatusEnum.Startting)
            {
                //从tryStart变为running(真的开始)
                if (ret?.FlowRate > 0)
                {
                    this.SetStatus(DeviceStatusEnum.Running);
                    comEventArgs.DeviceStatus = DeviceStatusEnum.Running;

                    StartEvent.TrySetResult(new DeviceIOResult(true));

                    OnCommunicationChange(comEventArgs);
                }
                else//泵收到开始命令 但还未运行
                {
                    comEventArgs.DeviceStatus = CurrentStatus;
                }

                StartRunningLoop();
            }
            else if (CurrentStatus == DeviceStatusEnum.Running)
            {
                //泵输入/输出指定流量后停止
                if (ret != null && ret.FlowRate <= 0)
                {
                    this.SetStatus(DeviceStatusEnum.Idle);
                    comEventArgs.DeviceStatus = DeviceStatusEnum.Idle;
                    comEventArgs.Description  = IdleDesc.Completed.ToString();
                    OnCommunicationChange(comEventArgs);
                }
                else//泵正在运行
                {
                    comEventArgs.DeviceStatus = DeviceStatusEnum.Running;
                    StartRunningLoop();
                }
            }
        }