File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ import org.junit.jupiter.api.Test
2
+ import org.junit.jupiter.api.assertThrows
3
+ import kotlin.test.assertEquals
4
+
5
+ class PlcMemoryTest {
6
+
7
+ @Test
8
+ fun `PlcMemory must be initialized with configured holding registers symbols` () {
9
+ val configuration = ConfigurationParser ()
10
+ configuration.setReadFromResources(true )
11
+ configuration.setFileName(" configuration_init.xml" )
12
+ val plcMemory = PlcMemory (configuration)
13
+ val values = plcMemory.readHoldingRegister(14 , 1 )
14
+ assertEquals(1 , values.size, )
15
+ assertEquals( values[0 ], 500 )
16
+ }
17
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" US-ASCII" ?>
2
+ <device ip =" 0.0.0.0" port =" 502" >
3
+ <parameters >
4
+ <parameter symbol =" PARAM_INT16" datatype =" INT16" >15</parameter >
5
+ <parameter symbol =" PARAM_FLOAT32" datatype =" FLOAT32" >5.45</parameter >
6
+ <parameter symbol =" PARAM_BOOL" datatype =" BOOL" >1</parameter >
7
+ </parameters >
8
+ <configuration initializeUndefinedRegisters =" true" initialValue =" 0" >
9
+ <registers >
10
+ <register addressType =" HOLDING_REGISTER" address =" 14" symbol =" RPM_MOTOR" >500</register >
11
+ </registers >
12
+ </configuration >
13
+ <simulation plcScanTime =" 1000" >
14
+ <delay >500</delay >
15
+ </simulation >
16
+ </device >
You can’t perform that action at this time.
0 commit comments