[Project] PlcAddressGenerator uses SubTypes Pin, DevPin and DevPin0
This commit is contained in:
parent
70369fe85d
commit
4e07fe99a0
|
@ -0,0 +1,69 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<StrolchModel xmlns="https://strolch.li/xsd/StrolchModel-1.6.xsd">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
PLC to store connection state to server
|
||||||
|
-->
|
||||||
|
<Resource Id="plc-01" Name="PLC" Type="Plc">
|
||||||
|
<ParameterBag Id="parameters" Name="Parameters" Type="Parameters">
|
||||||
|
<Parameter Id="connectionState" Name="Connection State" Type="String" Interpretation="Enumeration" Uom="ConnectionState" Value="Disconnected"/>
|
||||||
|
<Parameter Id="connectionStateMsg" Name="Connection State Msg" Type="String" Interpretation="Enumeration" Uom="ConnectionState"
|
||||||
|
Value=""/>
|
||||||
|
</ParameterBag>
|
||||||
|
</Resource>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
PLC State
|
||||||
|
-->
|
||||||
|
<Resource Id="plcLogicalDevice" Name="PLC" Type="PlcLogicalDevice">
|
||||||
|
<ParameterBag Id="parameters" Name="Parameters" Type="Parameters">
|
||||||
|
<Parameter Id="group" Name="Group" Type="String" Value="99 Startup"/>
|
||||||
|
<Parameter Id="index" Name="Index" Type="Integer" Value="999999"/>
|
||||||
|
</ParameterBag>
|
||||||
|
<ParameterBag Id="relations" Name="Relations" Type="Relations">
|
||||||
|
<Parameter Id="addresses" Name="Addresses" Type="StringList" Interpretation="Resource-Ref" Uom="PlcAddress"
|
||||||
|
Value="addrPlcStarted, addrPlcConnected"/>
|
||||||
|
<Parameter Id="telegrams" Name="Telegrams" Type="StringList" Interpretation="Resource-Ref" Uom="PlcTelegram"
|
||||||
|
Value="telPlcStarted, telPlcStopped"/>
|
||||||
|
</ParameterBag>
|
||||||
|
</Resource>
|
||||||
|
<Resource Id="addrPlcConnected" Name="PLC - Connected" Type="PlcAddress">
|
||||||
|
<ParameterBag Id="parameters" Name="Parameters" Type="Parameters">
|
||||||
|
<Parameter Id="address" Name="HW Address" Type="String" Interpretation="PlcConnection" Value="virtualString.plcServerConnected"/>
|
||||||
|
<Parameter Id="resource" Name="Resource ID for PlcAddress" Type="String" Value="PLC"/>
|
||||||
|
<Parameter Id="action" Name="Action ID for PlcAddress" Type="String" Value="ServerConnected"/>
|
||||||
|
<Parameter Id="valueType" Name="Value Type" Type="String" Interpretation="Interpretation" Uom="PlcValueType" Value="String"/>
|
||||||
|
<Parameter Id="value" Name="Value" Type="String" Value="false"/>
|
||||||
|
<Parameter Id="index" Name="Index" Type="Integer" Value="5"/>
|
||||||
|
</ParameterBag>
|
||||||
|
</Resource>
|
||||||
|
<Resource Id="addrPlcStarted" Name="PLC - Started" Type="PlcAddress">
|
||||||
|
<ParameterBag Id="parameters" Name="Parameters" Type="Parameters">
|
||||||
|
<Parameter Id="address" Name="HW Address" Type="String" Interpretation="PlcConnection" Value="virtualBoolean.plcStarted"/>
|
||||||
|
<Parameter Id="resource" Name="Resource ID for PlcAddress" Type="String" Value="PLC"/>
|
||||||
|
<Parameter Id="action" Name="Action ID for PlcAddress" Type="String" Value="Started"/>
|
||||||
|
<Parameter Id="value" Name="Value" Type="Boolean" Value="false"/>
|
||||||
|
<Parameter Id="inverted" Name="Inverted" Type="Boolean" Value="false"/>
|
||||||
|
<Parameter Id="index" Name="Index" Type="Integer" Value="10"/>
|
||||||
|
</ParameterBag>
|
||||||
|
</Resource>
|
||||||
|
<Resource Id="telPlcStarted" Name="PLC - Started" Type="PlcTelegram">
|
||||||
|
<ParameterBag Id="parameters" Name="Parameters" Type="Parameters">
|
||||||
|
<Parameter Id="address" Name="HW Address" Type="String" Interpretation="PlcConnection" Value="virtualBoolean.plcStarted"/>
|
||||||
|
<Parameter Id="resource" Name="Resource ID for PlcAddress" Type="String" Value="PLC"/>
|
||||||
|
<Parameter Id="action" Name="Action ID for PlcAddress" Type="String" Value="Started"/>
|
||||||
|
<Parameter Id="value" Name="Value" Type="Boolean" Value="true"/>
|
||||||
|
<Parameter Id="index" Name="Index" Type="Integer" Value="10"/>
|
||||||
|
</ParameterBag>
|
||||||
|
</Resource>
|
||||||
|
<Resource Id="telPlcStopped" Name="PLC - Stopped" Type="PlcTelegram">
|
||||||
|
<ParameterBag Id="parameters" Name="Parameters" Type="Parameters">
|
||||||
|
<Parameter Id="address" Name="HW Address" Type="String" Interpretation="PlcConnection" Value="virtualBoolean.plcStarted"/>
|
||||||
|
<Parameter Id="resource" Name="Resource ID for PlcAddress" Type="String" Value="PLC"/>
|
||||||
|
<Parameter Id="action" Name="Action ID for PlcAddress" Type="String" Value="Stopped"/>
|
||||||
|
<Parameter Id="value" Name="Value" Type="Boolean" Value="false"/>
|
||||||
|
<Parameter Id="index" Name="Index" Type="Integer" Value="20"/>
|
||||||
|
</ParameterBag>
|
||||||
|
</Resource>
|
||||||
|
|
||||||
|
</StrolchModel>
|
|
@ -1,11 +1,11 @@
|
||||||
Description,Type,SubType,Device,Pin,Resource,Action1,Action2,Connection,DeviceId
|
Description,Type,SubType,Device,Pin,Resource,Action1,Action2,Connection,DeviceId
|
||||||
Material Flow,Group,,,,,,,,MaterialFlow
|
Material Flow,Group,,,,,,,,MaterialFlow
|
||||||
Conveyor 1,Input,PCF8574,1,1,Conveyor01,Occupied,,i2cInput.dev01
|
Conveyor 1,Input,DevPin0,1,1,Conveyor01,Occupied,,i2cInput.dev01,
|
||||||
Conveyor 2,Input,PCF8574,1,2,Conveyor02,Occupied,,i2cInput.dev01
|
Conveyor 2,Input,DevPin0,1,2,Conveyor02,Occupied,,i2cInput.dev01,
|
||||||
Conveyor 3,Input,PCF8574,1,3,Conveyor03,Occupied,,i2cInput.dev01
|
Conveyor 3,Input,DevPin0,1,3,Conveyor03,Occupied,,i2cInput.dev01,
|
||||||
Conveyor 4,Input,PCF8574,1,4,Conveyor04,Occupied,,i2cInput.dev01
|
Conveyor 4,Input,DevPin0,1,4,Conveyor04,Occupied,,i2cInput.dev01,
|
||||||
Conveyor 1,Output,PCF8574,1,1,Conveyor01,MotorOn,MotorOff,i2cOutput.dev01
|
Conveyor 1,Output,DevPin0,1,1,Conveyor01,MotorOn,MotorOff,i2cOutput.dev01,
|
||||||
Conveyor 2,Output,PCF8574,1,2,Conveyor02,MotorOn,MotorOff,i2cOutput.dev01
|
Conveyor 2,Output,DevPin0,1,2,Conveyor02,MotorOn,MotorOff,i2cOutput.dev01,
|
||||||
Conveyor 3,Output,PCF8574,1,3,Conveyor03,MotorOn,MotorOff,i2cOutput.dev01
|
Conveyor 3,Output,DevPin0,1,3,Conveyor03,MotorOn,MotorOff,i2cOutput.dev01,
|
||||||
Conveyor 4,Output,PCF8574,1,4,Conveyor04,MotorOn,MotorOff,i2cOutput.dev01
|
Conveyor 4,Output,DevPin0,1,4,Conveyor04,MotorOn,MotorOff,i2cOutput.dev01,
|
||||||
DataLogicScanner,DataLogicScanner,,,,Conveyor03,,,dataLogicScanner
|
DataLogicScanner,DataLogicScanner,,,,Conveyor03,,,dataLogicScanner,
|
|
|
@ -1,5 +1,5 @@
|
||||||
Description,Type,SubType,Device,Pin,Resource,Action1,Action2,Connection,DeviceId
|
Description,Type,SubType,Device,Pin,Resource,Action1,Action2,Connection,DeviceId
|
||||||
Material Flow,Group,,,,,,,,MaterialFlow
|
Material Flow,Group,,,,,,,,MaterialFlow
|
||||||
Conveyor 1,Input,GPIO,,4,Conveyor,Occupied,,raspiBcmGpioInput
|
Conveyor 1,Input,Pin,,4,Conveyor,Occupied,,raspiBcmGpioInput
|
||||||
Conveyor 1,Input,GPIO,,17,Conveyor,BoxDetected,,raspiBcmGpioInput
|
Conveyor 1,Input,Pin,,17,Conveyor,BoxDetected,,raspiBcmGpioInput
|
||||||
Conveyor 1,Output,GPIO,,18,Conveyor,MotorOn,MotorOff,raspiBcmGpioOutput
|
Conveyor 1,Output,Pin,,18,Conveyor,MotorOn,MotorOff,raspiBcmGpioOutput
|
||||||
|
|
|
|
@ -571,13 +571,13 @@ public class PlcAddressGenerator {
|
||||||
throw new IllegalStateException("Pin missing for: " + record);
|
throw new IllegalStateException("Pin missing for: " + record);
|
||||||
|
|
||||||
String address;
|
String address;
|
||||||
if (subType.equals("GPIO")) {
|
if (subType.equals("Pin")) {
|
||||||
int io = Integer.parseInt(pin);
|
int io = Integer.parseInt(pin);
|
||||||
address = connection + "." + io;
|
address = connection + "." + io;
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subType.equals("PCF8574")) {
|
if (subType.equals("DevPin0") || subType.equals("DevPin")) {
|
||||||
|
|
||||||
String device = record.get("Device");
|
String device = record.get("Device");
|
||||||
if (isEmpty(device))
|
if (isEmpty(device))
|
||||||
|
@ -586,11 +586,11 @@ public class PlcAddressGenerator {
|
||||||
int card = Integer.parseInt(device);
|
int card = Integer.parseInt(device);
|
||||||
int io = Integer.parseInt(pin);
|
int io = Integer.parseInt(pin);
|
||||||
|
|
||||||
// the device ID must be subtracted, as this defines the actual card
|
if (subType.equals("DevPin0")) {
|
||||||
int dev = Integer.parseInt(connection.substring(connection.length() - 2));
|
int dev = Integer.parseInt(connection.substring(connection.length() - 2));
|
||||||
card -= dev;
|
card -= dev;
|
||||||
// decrement, because pin 1 is actually 0
|
io -= 1;
|
||||||
io -= 1;
|
}
|
||||||
|
|
||||||
address = connection + "." + card + "." + io;
|
address = connection + "." + card + "." + io;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue