public void CreatePlcS7AccessInvalidIpTest() { String badIp = "0.0.0.0"; IPlcDataAccess s7Access = new PlcS7Access(badIp, PORT_PLC, RACK_PLC, SLOT_PLC, TIMEOUT_PLC); }
public void CreatePlcS7AccessTest() { IPlcDataAccess s7Access = new PlcS7Access(IP_PLC, PORT_PLC, RACK_PLC, SLOT_PLC, TIMEOUT_PLC); Assert.AreEqual(PlcConnectionState.Disconnect, s7Access.State); }
public void DisconnectPlcS7AccessTest() { IPlcDataAccess s7Access = new PlcS7Access(IP_PLC, PORT_PLC, RACK_PLC, SLOT_PLC, TIMEOUT_PLC); if (s7Access.State == PlcConnectionState.Disconnect) { s7Access.Connect(); } else { Assert.Fail("S7Access not initialize"); } if (s7Access.State == PlcConnectionState.Error) { Assert.Fail("S7Access not connect"); } s7Access.Disconnect(); Assert.AreEqual(PlcConnectionState.Disconnect, s7Access.State); }
public void InitS7Access() { _s7Access = new PlcS7Access(IP_PLC, PORT_PLC, RACK_PLC, SLOT_PLC, TIMEOUT_PLC); }
public void CreatePlcAccessInvalidSlotTest() { Int32 badSlot = 9; IPlcDataAccess s7Access = new PlcS7Access(IP_PLC, PORT_PLC, RACK_PLC, badSlot, TIMEOUT_PLC); }
public void CreatePlcS7AccessInvalidRackTest() { Int32 badRack = 1; IPlcDataAccess s7Access = new PlcS7Access(IP_PLC, PORT_PLC, badRack, SLOT_PLC, TIMEOUT_PLC); }
public void GetDateTimeS7Access() { Int32 blockNum = 30; Int32 addressByte = 18; IPlcDataAccess s7Access = new PlcS7Access(IP_PLC, PORT_PLC, RACK_PLC, SLOT_PLC, TIMEOUT_PLC); if (s7Access == null) { Assert.Fail("s7Access not initialize"); } s7Access.Connect(); DateTime res = DateTime.MinValue; if (s7Access.State == PlcConnectionState.Connect) { try { res = s7Access.GetDateTime(MemoryTypes.DataBlock, blockNum, addressByte); } catch (Exception ex) { Assert.Fail(ex.Message); } finally { s7Access.Disconnect(); } } DateTime expt = new DateTime(2016, 1, 12, 11, 22, 00); Assert.AreEqual(expt, res); }
public void GetSingleS7AccessTest() { Int32 blockNum = 30; Int32 addressByte = 14; IPlcDataAccess s7Access = new PlcS7Access(IP_PLC, PORT_PLC, RACK_PLC, SLOT_PLC, TIMEOUT_PLC); if (s7Access == null) { Assert.Fail("s7Access not initialize"); } s7Access.Connect(); Single res = 0; if (s7Access.State == PlcConnectionState.Connect) { try { res = s7Access.GetFloat(MemoryTypes.DataBlock, blockNum, addressByte); } catch (Exception ex) { Assert.Fail(ex.Message); } finally { s7Access.Disconnect(); } } Single expt = 3.1415f; Assert.AreEqual(expt, res); }
public void CreatePlcS7AccessInvalidPortTest() { Int32 badPort = -1; IPlcDataAccess s7Access = new PlcS7Access(IP_PLC, badPort, RACK_PLC, SLOT_PLC, TIMEOUT_PLC); }
public void GetFalseBitS7AccessTest() { Int32 blockNum = 30; Int32 addressByte = 0; Int32 addressBit = 1; IPlcDataAccess s7Access = new PlcS7Access(IP_PLC, PORT_PLC, RACK_PLC, SLOT_PLC, TIMEOUT_PLC); if (s7Access == null) { Assert.Fail("s7Access not initialize"); } s7Access.Connect(); Boolean res = true; if (s7Access.State == PlcConnectionState.Connect) { try { res = s7Access.GetBit(MemoryTypes.DataBlock, blockNum, addressByte, addressBit); } catch (Exception ex) { Assert.Fail(ex.Message); } finally { s7Access.Disconnect(); } } Assert.IsFalse(res); }
public void DisconnectPlcS7AccessDisconnectStateTest() { IPlcDataAccess s7Access = new PlcS7Access(IP_PLC, PORT_PLC, RACK_PLC, SLOT_PLC, TIMEOUT_PLC); s7Access.Disconnect(); }