public PLCResponse GetDriverStatus() { if (Visible == false || bMouseIn || bTimeOut) { return(PLCResponse.SUCCESS); } m_plcRes = PLC.GetWord(m_strDriverName, m_strDriverAddr, plcDataType, ref strValue); return(m_plcRes); }
public void TestPing() { PLCService service = new PLCService(); { PLCRequest request = new PLCRequest { Command = PLCRequest.CommandPing }; PLCResponse response = service.Handle(request); Assert.Null(response.Error); } }
public PLCResponse GetDriverStatus() { if (Visible == false || bTimeOut) { return(PLCResponse.SUCCESS); } lock (objlock) { m_plcRes = PLC.GetBit(m_strDriverName, m_strDriverAddrMonitor, ref bCurrentStatus); } return(m_plcRes); }
public void TestReadWriteBulk() { PLCService service = new PLCService(); { PLCRequest request = new PLCRequest { Command = PLCRequest.CommandRead }; PLCResponse response = service.Handle(request); Assert.Null(response.Error); Assert.Null(response.Values); } { PLCRequest request = new PLCRequest { Command = PLCRequest.CommandRead, Keys = new string[] { "test1", "test2", "test3" } }; PLCResponse response = service.Handle(request); Assert.Null(response.Error); Assert.NotNull(response.Values); Assert.Equal(response.Values.Count, 0); } { Dictionary <string, object> values = new Dictionary <string, object>(); values["test1"] = "hello"; values["test3"] = true; PLCRequest request = new PLCRequest { Command = PLCRequest.CommandWrite, Values = values }; PLCResponse response = service.Handle(request); Assert.Null(response.Error); } { PLCRequest request = new PLCRequest { Command = PLCRequest.CommandRead, Keys = new string[] { "test1", "test2", "test3" } }; PLCResponse response = service.Handle(request); Assert.Null(response.Error); Assert.NotNull(response.Values); Assert.Equal(response.Values.Count, 2); Assert.Equal(response.Values["test1"], "hello"); Assert.Equal(response.Values["test3"], true); } }
public void TestReadWrite() { PLCService service = new PLCService(); { PLCRequest request = new PLCRequest { Command = PLCRequest.CommandRead }; PLCResponse response = service.Handle(request); Assert.Null(response.Error); Assert.Null(response.Values); } { PLCRequest request = new PLCRequest { Command = PLCRequest.CommandRead, Keys = new string[] { "test" } }; PLCResponse response = service.Handle(request); Assert.Null(response.Error); Assert.NotNull(response.Values); Assert.Equal(response.Values.Count, 0); } { Dictionary <string, object> values = new Dictionary <string, object>(); values["test"] = 3.1415926535; PLCRequest request = new PLCRequest { Command = PLCRequest.CommandWrite, Values = values }; PLCResponse response = service.Handle(request); Assert.Null(response.Error); } { PLCRequest request = new PLCRequest { Command = PLCRequest.CommandRead, Keys = new string[] { "test" } }; PLCResponse response = service.Handle(request); Assert.Null(response.Error); Assert.NotNull(response.Values); Assert.Equal(response.Values.Count, 1); Assert.Equal(response.Values["test"], 3.1415926535); } }