Exemplo n.º 1
0
 void MoniDatareader_NotifySettingCompletedEvent(object sender, NotifySettingCompletedEventArgs e)
 {
     //Value:,显示屏ID|设置结果
     if (e.SettingType == HWSettingType.GlobalBright)
     {
         SendData(CmdResult.CMD_SetBrightness.ToString(), _cmdSource + "|" + +Convert.ToInt32(e.Result));
     }
     Interlocked.Exchange(ref _isRunningMetux, 0);
 }
 private void WriteDataCompleteRequest(object sender, CompletePackageRequestEventArgs e)
 {
     if (GetClassNameFromTag(e.Request.Tag) != ClassName)
     {
         NotifySettingCompletedEventArgs args = null;
         if (e.Request.Tag == SetPowerStatusTagStart)
         {
             args = new NotifySettingCompletedEventArgs()
             {
                 SettingType = HWSettingType.OpenDevice,
                 Result = false
             };
         }
         else
         {
             args = new NotifySettingCompletedEventArgs()
             {
                 SettingType = HWSettingType.CloseDevice,
                 Result = false
             };
         }
         OnNotifySettingCompletedEvent(this, args);
         Interlocked.Exchange(ref _isHwRunningMetux, 0);
         return;
     }
     if (e.Request.PackResult == PackageResults.ok
        && e.Request.CommResult == Nova.IO.Port.CommResults.ok
        && e.Request.AckCode == (byte)AckResults.ok)
     {
         if (e.Request.Tag == SetPowerStatusTagStart)
         {
             lock (_setOnePowerStatusObj)
             {
                 NotifySettingCompletedEventArgs args = new NotifySettingCompletedEventArgs()
                 {
                     SettingType = HWSettingType.OpenDevice,
                     Result = true
                 };
                 OnNotifySettingCompletedEvent(this, args);
                 _fLogService.Info(e.Request.CurPartIndex + " 某一路电源的打开状态成功,Pulse控制一路电源的锁");
                 System.Threading.Monitor.Pulse(_setOnePowerStatusObj);
             }
         }
         else if (e.Request.Tag == SetPowerStatusTagClose)
         {
             lock (_setOnePowerStatusObj)
             {
                 NotifySettingCompletedEventArgs args = new NotifySettingCompletedEventArgs()
                 {
                     SettingType = HWSettingType.CloseDevice,
                     Result = true
                 };
                 OnNotifySettingCompletedEvent(this, args);
                 _fLogService.Info(e.Request.CurPartIndex + " 某一路电源的关闭状态成功,Pulse控制一路电源的锁");
                 System.Threading.Monitor.Pulse(_setOnePowerStatusObj);
             }
         }
     }
     else
     {
         if (e.Request.Tag == SetPowerStatusTagStart)
         {
             lock (_setOnePowerStatusObj)
             {
                 NotifySettingCompletedEventArgs args = new NotifySettingCompletedEventArgs()
                 {
                     SettingType = HWSettingType.OpenDevice,
                     Result = false
                 };
                 OnNotifySettingCompletedEvent(this, args);
                 _fLogService.Error(e.Request.CurPartIndex + " 某一路电源的打开状态失败,Pulse控制一路电源的锁");
                 System.Threading.Monitor.Pulse(_setOnePowerStatusObj);
             }
         }
         else if (e.Request.Tag == SetPowerStatusTagClose)
         {
             lock (_setOnePowerStatusObj)
             {
                 NotifySettingCompletedEventArgs args = new NotifySettingCompletedEventArgs()
                 {
                     SettingType = HWSettingType.CloseDevice,
                     Result = false
                 };
                 OnNotifySettingCompletedEvent(this, args);
                 _fLogService.Error(e.Request.CurPartIndex + " 某一路电源的关闭状态失败,Pulse控制一路电源的锁");
                 System.Threading.Monitor.Pulse(_setOnePowerStatusObj);
             }
         }
     }
     Interlocked.Exchange(ref _isHwRunningMetux, 0);
 }
        private void CompletedSetBrightness(object sender, CompletePackageRequestEventArgs e)
        {
            if (e.Request.PackResult != PackageResults.ok
                || e.Request.CommResult != Nova.IO.Port.CommResults.ok
                || e.Request.AckCode != (int)AckResults.ok)
            {
                if (e.Request.Tag == "SendBrightToHW_Complete")
                {
                    NotifySettingCompletedEventArgs args = new NotifySettingCompletedEventArgs()
                    {
                        SettingType = HWSettingType.GlobalBright,
                        Result = false
                    };
                    OnNotifySettingCompletedEvent(this, args);
                }
                else
                {
                    _isWrightDataOK = false;
                }
            }
            else
            {
                if (e.Request.Tag == "SendBrightToHW_Complete")
                {
                    NotifySettingCompletedEventArgs args = new NotifySettingCompletedEventArgs()
                    {
                        SettingType = HWSettingType.GlobalBright,
                        Result = false
                    };

                    if (_isWrightDataOK)
                    {
                        args.Result = true;
                    }
                    OnNotifySettingCompletedEvent(this, args);
                }
            }
        }
 private void OnNotifySettingCompletedEvent(object sender, NotifySettingCompletedEventArgs e)
 {
     if (NotifySettingCompletedEvent != null)
     {
         NotifySettingCompletedEvent(sender, e);
     }
 }