示例#1
0
 private bool RegButtonCheckNotification(NetTcpDuplexWcfClientService <ITLAutoDevicePushService> wcfService, MachineButtonItem buttonItem, TLAutoDevicePushCallback callback)
 {
     callback.Notify += (s, e) => { Callback_Notify(s, e, buttonItem.DeviceNumber); };
     try
     {
         wcfService = new NetTcpDuplexWcfClientService <ITLAutoDevicePushService>(callback, buttonItem.ServiceAddress);
         var result = wcfService.Send(proxy =>
         {
             proxy.RegistControlDeviceEx(CookingMachinePluginsProvider.SignKey + buttonItem.DeviceNumber,
                                         new ControlInfo
             {
                 ServiceKey = CommonConfigHelper.PLCServiceKey,
                 Data       = new PLCControlServiceData
                 {
                     ControlPLCType = ControlPLCType.QueryDiaitalSwitchWithAutoUpload,
                     DeviceNumber   = buttonItem.DeviceNumber,
                     PortSignName   = buttonItem.SignName
                 }.ToBytes()
             });
         });
         return(result);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
示例#2
0
 private bool RegButtonCheckNotification()
 {
     try
     {
         if (_callback != null)
         {
             _callback.Notify -= Callback_Notify;
         }
         _callback         = new TLAutoDevicePushCallback();
         _callback.Notify += Callback_Notify;
         var buttonItem = ButtonItems[0];
         _wcfService = new NetTcpDuplexWcfClientService <ITLAutoDevicePushService>(_callback, buttonItem.ServiceAddress);
         var result = _wcfService.Send(proxy =>
         {
             proxy.RegistControlDeviceEx(SignKey,
                                         new ControlInfo
             {
                 ServiceKey = CommonConfigHelper.PLCServiceKey,
                 Data       = new PLCControlServiceData
                 {
                     ControlPLCType = ControlPLCType.QueryDiaitalSwitchWithAutoUpload,
                     DeviceNumber   = buttonItem.DeviceNumber,
                     PortSignName   = buttonItem.SignName
                 }.ToBytes()
             });
         });
         return(result);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
示例#3
0
 public bool Reg()
 {
     try
     {
         _callback         = new TLAutoDevicePushCallback();
         _callback.Notify += Callback_Notify;
         _wcfClientService = new NetTcpDuplexWcfClientService <ITLAutoDevicePushService>(_callback, _serviceAddress, TimeSpan.FromMilliseconds(_sendTimeout));
         var result = _wcfClientService.Send(proxy =>
         {
             proxy.RegistControlDeviceEx(_regKey,
                                         new ControlInfo
             {
                 ServiceKey = CommonConfigHelper.PLCServiceKey,
                 Data       = new PLCControlServiceData
                 {
                     ControlPLCType = ControlPLCType.QueryDiaitalSwitchWithAutoUpload,
                     DeviceNumber   = _deviceNumber,
                     PortSignName   = _signName
                 }.ToBytes()
             });
         });
         IsReg = result;
         return(result);
     }
     catch (Exception ex)
     {
         IsReg = false;
         return(false);
     }
 }
示例#4
0
        protected override void Invoke()
        {
            var item = _allCheckButtonItems[0];

            try
            {
                _wcfClientService = new NetTcpDuplexWcfClientService <ITLAutoDevicePushService>(_callback, item.ServiceAddress);
                var result = _wcfClientService.Send(proxy =>
                {
                    proxy.RegistControlDeviceEx(RegKey,
                                                new ControlInfo
                    {
                        ServiceKey = CommonConfigHelper.PLCServiceKey,
                        Data       = new PLCControlServiceData
                        {
                            ControlPLCType = ControlPLCType.QueryDiaitalSwitchWithAutoUpload,
                            DeviceNumber   = item.DeviceNumber,
                            PortSignName   = item.SignName
                        }.ToBytes()
                    });
                });
                if (!result)
                {
                    PostResult(false);
                }
            }
            catch (Exception ex)
            {
                PostResult(false);
            }
        }
示例#5
0
 protected override void Dispose(bool disposing)
 {
     try
     {
         lock (_lockObj)
         {
             try
             {
                 _wcfClientService.Close();
                 var service = new NetTcpDuplexWcfClientService <ITLAutoDevicePushService>(_callback,
                                                                                           _allCheckButtonItems[0].ServiceAddress);
                 service.Send(proxy => { proxy.UnRegistControlDeviceEx(RegKey, CommonConfigHelper.PLCServiceKey); });
                 service.Close();
             }
             catch (Exception ex)
             {
                 _log.Critical(ex.Message);
             }
             _allCheckButtonItems = null;
             _raiseButtonItems.Clear();
             _callback.Notify -= Callback_Notify;
             _callback         = null;
         }
     }
     catch (Exception ex)
     {
         _log.Critical(ex.Message);
     }
 }
示例#6
0
 private static bool RegButtonCheckNotification(List <MachineButtonItem> checkLightButtonItems, TLAutoDevicePushCallback callback)
 {
     try
     {
         _wcfService = new NetTcpDuplexWcfClientService <ITLAutoDevicePushService>(callback, checkLightButtonItems[0].ServiceAddress);
         var result = _wcfService.Send(proxy =>
         {
             proxy.RegistControlDeviceEx(HitMouseMachinePluginsProvider.SignKey + checkLightButtonItems[0].DeviceNumber,
                                         new ControlInfo
             {
                 ServiceKey = CommonConfigHelper.PLCServiceKey,
                 Data       = new PLCControlServiceData
                 {
                     ControlPLCType = ControlPLCType.QueryDiaitalSwitchWithAutoUpload,
                     DeviceNumber   = checkLightButtonItems[0].DeviceNumber,
                     PortSignName   = checkLightButtonItems[0].SignName
                 }.ToBytes()
             });
         });
         return(result);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
示例#7
0
 private void UnregButtonCheckNotification(NetTcpDuplexWcfClientService <ITLAutoDevicePushService> wcfService, int deviceNumber, TLAutoDevicePushCallback callback)
 {
     try
     {
         wcfService.Close();
         var service = new NetTcpDuplexWcfClientService <ITLAutoDevicePushService>(callback, _speedButtonItem.ServiceAddress);
         service.Send(proxy => { proxy.UnRegistControlDeviceEx(CookingMachinePluginsProvider.SignKey + deviceNumber, CommonConfigHelper.PLCServiceKey); });
         service.Close();
     }
     catch (Exception ex) { }
 }
示例#8
0
 private void UnregButtonCheckNotification()
 {
     try
     {
         _wcfService.Close();
         var service = new NetTcpDuplexWcfClientService <ITLAutoDevicePushService>(_callback, ButtonItems[0].ServiceAddress);
         service.Send(proxy => { proxy.UnRegistControlDeviceEx(SignKey, CommonConfigHelper.PLCServiceKey); });
         service.Close();
     }
     catch (Exception ex) { }
 }
示例#9
0
 private void UnregButtonCheckNotification(int deviceNumber, string serviceAddress, TLAutoDevicePushCallback callback)
 {
     try
     {
         _wcfService.Close();
         var service = new NetTcpDuplexWcfClientService <ITLAutoDevicePushService>(callback, serviceAddress);
         service.Send(proxy => { proxy.UnRegistControlDeviceEx(SignKey + deviceNumber, CommonConfigHelper.PLCServiceKey); });
         service.Close();
     }
     catch (Exception ex) { }
 }
示例#10
0
 public bool Unreg()
 {
     try
     {
         if (_callback != null)
         {
             _callback.Notify -= Callback_Notify;
         }
         _wcfClientService.Close();
         var service = new NetTcpDuplexWcfClientService <ITLAutoDevicePushService>(_callback, _serviceAddress);
         service.Send(proxy => { proxy.UnRegistControlDeviceEx(_regKey, CommonConfigHelper.PLCServiceKey); });
         service.Close();
         IsReg = true;
         return(true);
     }
     catch (Exception ex)
     {
         IsReg = false;
         return(false);
     }
 }
示例#11
0
 private bool RegButtonCheckNotification(int deviceNumber, string signName)
 {
     try
     {
         var callback = new TLAutoDevicePushCallback();
         callback.Notify += (sen, eve) =>
         {
             if (!eve.IsError)
             {
                 var switchItem = eve.Data.ToObject <SwitchItem>();
                 var main       = (Main)View;
                 main.Dispatcher.BeginInvoke(new Action(() =>
                 {
                     main.TxtInfo.Text += $"{DateTime.Now} 开关号:{switchItem.SwitchNumber} 设备号:{deviceNumber} \r\n";
                     main.TxtInfo.ScrollToEnd();
                 }));
             }
         };
         _wcfService = new NetTcpDuplexWcfClientService <ITLAutoDevicePushService>(callback, _plcServiceAddress, TimeSpan.FromMinutes(99));
         var result = _wcfService.Send(proxy =>
         {
             proxy.RegistControlDeviceEx(SignKey,
                                         new ControlInfo
             {
                 ServiceKey = CommonConfigHelper.PLCServiceKey,
                 Data       = new PLCControlServiceData
                 {
                     ControlPLCType = ControlPLCType.QueryDiaitalSwitchWithAutoUpload,
                     DeviceNumber   = deviceNumber,
                     PortSignName   = signName
                 }.ToBytes()
             });
         });
         return(result);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }