Пример #1
0
 private void InitMouseLeftButtonDownCommand()
 {
     MouseLeftButtonDownCommand = new RelayCommand(async() =>
     {
         var plcDeviceInfo = PLCDeviceService.GetPLCDeviceInfo(PortName, DeviceNumber);
         await plcDeviceInfo.RaiseDigitalSwitchStatus(ControlNumber);
     });
 }
Пример #2
0
        private void AddNewSerialPortInfoWithSave(SerialPortSettingsInfo serialPortSettingsInfo, PLCSettingsInfo plcSettingsInfo)
        {
            var plcSerialPortInfo = new PLCSerialPortInfo(serialPortSettingsInfo.Current.Item1);

            PLCSerialPortInfos.Add(plcSerialPortInfo);
            var deviceSettings = PLCDeviceSettings.GetPLCDeviceSettings();

            deviceSettings.SerialPortSettings.Add(new PLCSerialPortSettings(serialPortSettingsInfo.Current.Item1));
            if (PLCDeviceService.SaveSettings())
            {
                plcSerialPortInfo.AddPLCDeviceInfoWithSave(plcSettingsInfo.Current);
            }
        }
Пример #3
0
 private void InitRemoveSerialPortCommand()
 {
     RemoveSerialPortCommand = new RelayCommand(() =>
     {
         var dialog = new RemoveItemsView("删除通信串口", PLCSerialPortInfos.Select(s => s.PortName).ToList());
         if (dialog.ShowDialog() == true)
         {
             var removePortNames = dialog.SelectedItems;
             foreach (var portName in removePortNames)
             {
                 var serialPortInfo = PLCSerialPortInfos.FirstOrDefault(s => s.PortName == portName);
                 if (serialPortInfo != null)
                 {
                     serialPortInfo.Cleanup();
                     PLCSerialPortInfos.Remove(serialPortInfo);
                 }
             }
             PLCDeviceService.SaveSettings();
         }
     });
 }
Пример #4
0
 public static PLCDeviceSettings GetPLCDeviceSettings()
 {
     return((PLCDeviceSettings)PLCDeviceService.GetPLCDeviceService().DeviceSettings);
 }