public void T07_ReadAndWriteLongClass() { Assert.IsTrue(plc.IsConnected, "Before executing this test, the plc must be connected. Check constructor."); TestLongClass tc = new TestLongClass(); tc.IntVariable0 = 0; tc.IntVariable1 = 1; tc.IntVariable10 = 10; tc.IntVariable11 = 11; tc.IntVariable20 = 20; tc.IntVariable21 = 21; tc.IntVariable30 = 30; tc.IntVariable31 = 31; tc.IntVariable40 = 40; tc.IntVariable41 = 41; tc.IntVariable50 = 50; tc.IntVariable51 = 51; tc.IntVariable60 = 60; tc.IntVariable61 = 61; tc.IntVariable70 = 70; tc.IntVariable71 = 71; tc.IntVariable80 = 80; tc.IntVariable81 = 81; tc.IntVariable90 = 90; tc.IntVariable91 = 91; tc.IntVariable100 = 100; tc.IntVariable101 = 101; tc.IntVariable110 = 200; tc.IntVariable111 = 201; plc.WriteClass(tc, DB2); // Values that are read from a struct are stored in a new struct, returned by the funcion ReadStruct TestLongClass tc2 = new TestLongClass(); plc.ReadClass(tc2, DB2); Assert.AreEqual(tc.IntVariable0, tc2.IntVariable0); Assert.AreEqual(tc.IntVariable1, tc2.IntVariable1); Assert.AreEqual(tc.IntVariable10, tc2.IntVariable10); Assert.AreEqual(tc.IntVariable11, tc2.IntVariable11); Assert.AreEqual(tc.IntVariable20, tc2.IntVariable20); Assert.AreEqual(tc.IntVariable21, tc2.IntVariable21); Assert.AreEqual(tc.IntVariable30, tc2.IntVariable30); Assert.AreEqual(tc.IntVariable31, tc2.IntVariable31); Assert.AreEqual(tc.IntVariable40, tc2.IntVariable40); Assert.AreEqual(tc.IntVariable41, tc2.IntVariable41); Assert.AreEqual(tc.IntVariable50, tc2.IntVariable50); Assert.AreEqual(tc.IntVariable51, tc2.IntVariable51); Assert.AreEqual(tc.IntVariable60, tc2.IntVariable60); Assert.AreEqual(tc.IntVariable61, tc2.IntVariable61); Assert.AreEqual(tc.IntVariable70, tc2.IntVariable70); Assert.AreEqual(tc.IntVariable71, tc2.IntVariable71); Assert.AreEqual(tc.IntVariable80, tc2.IntVariable80); Assert.AreEqual(tc.IntVariable81, tc2.IntVariable81); Assert.AreEqual(tc.IntVariable90, tc2.IntVariable90); Assert.AreEqual(tc.IntVariable91, tc2.IntVariable91); Assert.AreEqual(tc.IntVariable100, tc2.IntVariable100); Assert.AreEqual(tc.IntVariable101, tc2.IntVariable101); Assert.AreEqual(tc.IntVariable110, tc2.IntVariable110); Assert.AreEqual(tc.IntVariable111, tc2.IntVariable111); }
public async Task Test_Async_ReadAndWriteLongClass() { Assert.IsTrue(plc.IsConnected, "Before executing this test, the plc must be connected. Check constructor."); TestLongClass tc = new TestLongClass { IntVariable0 = 0, IntVariable1 = 1, IntVariable10 = 10, IntVariable11 = 11, IntVariable20 = 20, IntVariable21 = 21, IntVariable30 = 30, IntVariable31 = 31, IntVariable40 = 40, IntVariable41 = 41, IntVariable50 = 50, IntVariable51 = 51, IntVariable60 = 60, IntVariable61 = 61, IntVariable70 = 70, IntVariable71 = 71, IntVariable80 = 80, IntVariable81 = 81, IntVariable90 = 90, IntVariable91 = 91, IntVariable100 = 100, IntVariable101 = 101, IntVariable110 = 200, IntVariable111 = 201 }; await plc.WriteClassAsync(tc, DB2); Assert.AreEqual(ErrorCode.NoError, plc.LastErrorCode); // Values that are read from a struct are stored in a new struct, returned by the funcion ReadStruct TestLongClass tc2 = new TestLongClass(); await plc.ReadClassAsync(tc2, DB2); Assert.AreEqual(ErrorCode.NoError, plc.LastErrorCode); Assert.AreEqual(tc.IntVariable0, tc2.IntVariable0); Assert.AreEqual(tc.IntVariable1, tc2.IntVariable1); Assert.AreEqual(tc.IntVariable10, tc2.IntVariable10); Assert.AreEqual(tc.IntVariable11, tc2.IntVariable11); Assert.AreEqual(tc.IntVariable20, tc2.IntVariable20); Assert.AreEqual(tc.IntVariable21, tc2.IntVariable21); Assert.AreEqual(tc.IntVariable30, tc2.IntVariable30); Assert.AreEqual(tc.IntVariable31, tc2.IntVariable31); Assert.AreEqual(tc.IntVariable40, tc2.IntVariable40); Assert.AreEqual(tc.IntVariable41, tc2.IntVariable41); Assert.AreEqual(tc.IntVariable50, tc2.IntVariable50); Assert.AreEqual(tc.IntVariable51, tc2.IntVariable51); Assert.AreEqual(tc.IntVariable60, tc2.IntVariable60); Assert.AreEqual(tc.IntVariable61, tc2.IntVariable61); Assert.AreEqual(tc.IntVariable70, tc2.IntVariable70); Assert.AreEqual(tc.IntVariable71, tc2.IntVariable71); Assert.AreEqual(tc.IntVariable80, tc2.IntVariable80); Assert.AreEqual(tc.IntVariable81, tc2.IntVariable81); Assert.AreEqual(tc.IntVariable90, tc2.IntVariable90); Assert.AreEqual(tc.IntVariable91, tc2.IntVariable91); Assert.AreEqual(tc.IntVariable100, tc2.IntVariable100); Assert.AreEqual(tc.IntVariable101, tc2.IntVariable101); Assert.AreEqual(tc.IntVariable110, tc2.IntVariable110); Assert.AreEqual(tc.IntVariable111, tc2.IntVariable111); }