-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import operations.SetOperation | ||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertTrue | ||
|
||
class SetOperationTest { | ||
@Test | ||
fun `Set must set a value to a coil variable`() { | ||
val configuration = ConfigurationParser() | ||
configuration.setReadFromResources(true) | ||
configuration.setFileName("set_operation.xml") | ||
val plcMemory = PlcMemory(configuration) | ||
val setOperation = SetOperation(configuration.getConfiguredDevice().configuration, plcMemory, EnvironmentVariables(listOf<EnvParameter>(),ConfigurationParser() )) | ||
assertTrue(configuration.getConfiguredDevice().simulation.randomElements[0] is Set) | ||
assertEquals(plcMemory.readCoilStatus(configuration.getConfiguredDevice().configuration.registers.register.first().address.toInt(), 1).first(), false) | ||
setOperation.setOperation(configuration.getConfiguredDevice().simulation.randomElements[0] as Set) | ||
assertEquals(plcMemory.readCoilStatus(configuration.getConfiguredDevice().configuration.registers.register.first().address.toInt(), 1).first(), true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="US-ASCII" ?> | ||
<device ip="0.0.0.0" port="502"> | ||
<configuration initializeUndefinedRegisters="true" initialValue="0"> | ||
<registers> | ||
<register addressType="COIL" address="0" symbol="RELAYON">0</register> | ||
</registers> | ||
</configuration> | ||
<simulation plcScanTime="1000"> | ||
<set symbol="RELAYON">1</set> | ||
</simulation> | ||
</device> |