| | |
| | | using HMI.UI; |
| | | using HMI.UI.Util; |
| | | using log4net; |
| | | using OPCConnection; |
| | | using Panuon.WPF.UI; |
| | | using Plugin.DOControl.Entity; |
| | | using System; |
| | |
| | | /// <summary> |
| | | /// 实例化服务器接口函数 |
| | | /// </summary> |
| | | //private OpcInterface.OpcInterface lTSCADAApi = new OpcInterface.OpcInterface(); |
| | | private PipeClient pipeClient = new PipeClient("DAService"); |
| | | private SCADAApi lTSCADAApi = new OPCClient(); |
| | | //private PipeClient pipeClient = new PipeClient("DAService"); |
| | | |
| | | private ObservableCollection<string> groups; |
| | | public ObservableCollection<string> Groups |
| | |
| | | |
| | | public override void DoClose(object sender, EventArgs e) |
| | | { |
| | | motorMonitorTimer.Enabled = false; |
| | | base.DoClose(sender, e); |
| | | try |
| | | { |
| | | |
| | | motorMonitorTimer.Enabled = false; |
| | | base.DoClose(sender, e); |
| | | } |
| | | catch { |
| | | } |
| | | } |
| | | |
| | | public static string FilePath { get; private set; } |
| | |
| | | /// <param name="value">值</param> |
| | | private void SetPlcValue(string key, string value) |
| | | { |
| | | //if (!lTSCADAApi.DoFctWriteSingle(key, value, out string errMsg)) |
| | | //{ |
| | | // ToastHelper.Error(this, errMsg); |
| | | //} |
| | | if (!lTSCADAApi.DoFctWriteSingle(key, value, out string errMsg)) |
| | | { |
| | | ToastHelper.Error(this, errMsg); |
| | | } |
| | | |
| | | pipeClient.SendMessage("asdsadasda", out _); |
| | | //lTSCADAApi.SendMessage("asdsadasda", out _); |
| | | } |
| | | |
| | | private string GetPlcValue(string key) |
| | | { |
| | | //if (lTSCADAApi.DoFctReadSingle(key, out string Val, out string errMsg)) |
| | | //{ |
| | | // return Val; |
| | | //} |
| | | //else |
| | | //{ |
| | | // return null; |
| | | //} |
| | | if (lTSCADAApi.DoFctReadSingle(key, out string Val, out string errMsg)) |
| | | { |
| | | return Val; |
| | | } |
| | | else |
| | | { |
| | | return null; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | |
| | | LoadData(); |
| | | if (SystemSetting.Instance.PlcEnabled) |
| | | { |
| | | //if (lTSCADAApi.Connect2("127.0.0.1", 6543, 18888, out string errMsg)) |
| | | //{ |
| | | // motorMonitorTimer.Enabled = true; |
| | | // RefreshControl(); |
| | | //} |
| | | //else |
| | | //{ |
| | | // MsgBoxHelper2.Error(errMsg); |
| | | //} |
| | | try |
| | | if (lTSCADAApi.Connect2("127.0.0.1", 6543, 28888, out string errMsg)) |
| | | { |
| | | pipeClient.OnConnected += PipeClient_OnConnected; |
| | | motorMonitorTimer.Enabled = true; |
| | | RefreshControl(); |
| | | } |
| | | else |
| | | { |
| | | MsgBoxHelper2.Error(errMsg); |
| | | } |
| | | //try |
| | | //{ |
| | | // pipeClient.OnConnected += PipeClient_OnConnected; |
| | | |
| | | pipeClient.Connect(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MsgBoxHelper.Error(this, ex.Message); |
| | | } |
| | | // pipeClient.Connect(); |
| | | //} |
| | | //catch (Exception ex) |
| | | //{ |
| | | // MsgBoxHelper.Error(this, ex.Message); |
| | | //} |
| | | } |
| | | Loaded -= UserControl_Loaded; |
| | | } |