|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.langner.jmatic2.SxPLC
This class is used for communication with SIMATIC S5® and S7® PLCs utilizing
the S7Functions or the FETCH/WRITE
protocol over a TCP or ISO-On-TCP connection.
The behaviour of this class is to simplify the access to the data of a PLC.
SxPLC is a high-level counterpart to S7Functions of FetchWrite.
Data is accessed only through PLCAlias objects rather than binary buffers.
These PLCAlias objects are proxies for the real-world process variables.
To use this class, you have to do just a few simple steps:
1. Create an instance of a SxPLC class.
2. Create aconnection to be used by the SxPLC class.
If utilizing the S7Functions use the CreateConnection with an instance of a S7FunctionsSettings object.
If utilizing a TCP connection use the CreateConnection with an instance of a FetchWriteTCPSettings object.
If utilizing a ISO-On-TCP connection use the CreateConnection with an instance of a FetchWriteRFC1006Settings object.
3. Register one or more PLCAlias objects to this instance.
4. Register a SxPLCListener implementation to be informed about value changes.
4. Call the method start to roll the dices.
At this point, the SxPLC object will connect to the PLC and call your listener for all variables that have changed since last read.
At startup, all values will be initialized. SxPLC reads the data from the PLC in the interval specified with the pollrate
and takes care about changes of the values read.
If the connection is lost or dropped, the SxPLC object will try to reconnect to the PLC.
5. To write a variable on the PLC, just use the method setValue.
| Constructor Summary | |
SxPLC()
Creates a new instance of SxPLC |
|
| Method Summary | |
void |
addListener(SxPLCListener listener)
Adds a listener. |
void |
CreateConnection(FetchWriteRFC1006Settings settings,
PLCModel model)
Creats a connection using FetchWrite over ISO-on-TCP.
|
void |
CreateConnection(FetchWriteTCPSettings settings,
PLCModel model)
Creats a connection using FetchWrite over TCP.
|
void |
CreateConnection(S7FunctionsSettings settings)
Creats a connection using S7Functions.
|
PLCAlias |
getAlias(java.lang.String aliasName)
Get a previously registered PLCAlias object by name. |
PLCAlias[] |
getAliases()
Get all registered PLCAlias objects. |
long |
getPollrate()
Retrieves the pollrate of this SxPLC object. |
IPLCValue |
getValue(java.lang.String aliasName)
Gets the current value of an PLCAlias object. |
void |
registerAlias(PLCAlias alias)
Register a new PLCAlias object. |
void |
registerFromFile(java.lang.String filename)
RegisterFromFile uses an Excel CSV file to specify the PLC memory layout. |
void |
removeListener(SxPLCListener listener)
Remove a previously added Listener. |
void |
setPollrate(long ms)
Sets the pollrate for this SxPLC object. |
void |
setValue(java.lang.String aliasName,
byte[] value)
Sets a value into a PLCAlias object. |
void |
setValue(java.lang.String aliasName,
java.lang.Object value)
Sets a value into a PLCAlias object. |
void |
start()
This method starts the communication with the PLC. |
void |
stop()
This method stops the communication with the PLC. |
void |
unregisterAlias(java.lang.String aliasName)
Unregister a previous registered PLCAlias. |
void |
unregisterAllAliases()
Unregisters all previous registered PLCAliases. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public SxPLC()
| Method Detail |
public void CreateConnection(S7FunctionsSettings settings)
throws JMaticException
S7Functions.
This constructor initializes the properties with the supplied values.
settings - Object with the connection settings
JMaticException
public void CreateConnection(FetchWriteTCPSettings settings,
PLCModel model)
throws JMaticException
FetchWrite over TCP.
This constructor initializes the properties with the supplied values.
settings - Object with the connection settingsmodel - Specifies the model of the PLC to be connected to.
JMaticException
public void CreateConnection(FetchWriteRFC1006Settings settings,
PLCModel model)
throws JMaticException
FetchWrite over ISO-on-TCP.
This constructor initializes the properties with the supplied values.
settings - Object with the connection settingsmodel - Specifies the model of the PLC to be connected to.
JMaticExceptionpublic void addListener(SxPLCListener listener)
listener - The listener to be added.public void removeListener(SxPLCListener listener)
listener - The listener to be removed.public void setPollrate(long ms)
ms - The pollrate in milliseconds.public long getPollrate()
public void start()
throws JMaticException
JMaticException - in case of an unrecoverable error.
public void stop()
throws JMaticException
JMaticException - in case of an unrecoverable error.public PLCAlias getAlias(java.lang.String aliasName)
aliasName - The alias name of the object. See registerAlias
public PLCAlias[] getAliases()
public void registerFromFile(java.lang.String filename)
throws JMaticException
# Comment
Operand.Offset.[Count.]Data_type, Variable_name
| Operand | Meaning |
| DBn | Data block. "n" is the DB number |
| O | Output |
| I | Input |
| M | Memory Byte |
| C | Counter |
| T | Timer |
| Data type | Meaning | Possible operands |
| BOOL0-BOOL7 | Boolean with offset X.0-X.7 (X represents the byte offset) | DB, O, I |
| BYTE | Byte | DB, O, I |
| CHAR | ASCII character | DB, O, I |
| INT | Signed integer | DB, O, I |
| DINT | Signed long integer | DB, O, I |
| WORD | Unsigned short | DB, O, I |
| DWORD | Unsigned long integer | DB, O, I |
| REAL | Float | DB, O, I |
| S7STRING | String (only S7 plc) | DB |
| STRING | String | DB |
| DATE | IEC Date | DB |
| DATE_AND_TIME | Date and Time (8 Byte) | DB |
| TIME | IEC Time | DB |
| S5TIME | Time type of S5 plc | DB |
| TIME_OF_DAY | Daytime | DB |
| Created with text editor | Created with Excel |
|
![]() |
filename - The path and name of the csv file to be used as input.
JMaticException
public void registerAlias(PLCAlias alias)
throws JMaticException
alias - The PLCAlias object to register.
JMaticException - in case of an unrecoverable error.
public void unregisterAlias(java.lang.String aliasName)
throws JMaticException
aliasName - The name of the PLCAlias.
JMaticException
public void unregisterAllAliases()
throws JMaticException
JMaticExceptionpublic IPLCValue getValue(java.lang.String aliasName)
aliasName - The name of the PLCAlias.
public void setValue(java.lang.String aliasName,
byte[] value)
throws JMaticException
aliasName - The name of the PLCAlias object.value - The value to set/write.
JMaticException - in case of an error.
public void setValue(java.lang.String aliasName,
java.lang.Object value)
throws JMaticException
aliasName - The name of the PLCAlias object.value - The value to set/write.
JMaticException - in case of an error.
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||