Class ProcComm
- All Implemented Interfaces:
Runnable
ProcComm is a Runnable tool implementation allowing a user to read or write datapoint
values in a KNX network. It supports KNX network access using a KNXnet/IP, KNX IP, USB, FT1.2, or
TP-UART connection.
Group monitor mode:
When in group monitor mode, process communication lists group write, read, and read response
commands issued on the KNX network. Datapoint values in monitored group commands are decoded for
appropriate KNX datapoint types (DPT). In addition, a user can issue read and write commands on
the terminal. Commands have the the following syntax: cmd datapoint [DPT] [value],
with cmd = ("r"|"read") | ("w"|"write"). For example, r 1/0/3 will read
the current value of datapoint 1/0/3. The command w 1/0/3 1.002 true
will write the boolean value true for datapoint 1/0/3.
By default, this tool will show the decoded value of any matching datapoint type for received
datapoint data. Issuing a read or write command and specifying a datapoint type (DPT) will
override the default datapoint type translation behavior of this tool. For example,
read 1/0/3 1.005 will decode subsequent values of that datapoint using the DPT 1.005
"Alarm" and its value representations "alarm" and "no alarm". A subsequent write can then simply
issue w 1/0/3 alarm, setting datapoint 1/0/3 to "alarm" state.
When the tool exits and no user-supplied datapoints file was used, type information about any datapoint
that was monitored is stored in a file
on disk in the current working directory (if file creation/modification is permitted). That file
is named something like ".proccomm_dplist.xml" (hidden file on Unix-based systems). It allows the
tool to remember user-specific settings of datapoint types between tool invocations, important
for the appropriate decoding of datapoint values. The file uses the layout of
DatapointMap, and can be edited or used at any other place Calimero expects a
DatapointModel. Note that any actual datapoint values are not stored in that file.
Any user-supplied datapoints resource is not modified when the tool exits.
The tool implementation shows the necessary interaction with the Calimero-core library API for
the described tasks. The main part of the implementation is based on the library's
ProcessCommunicator, which offers high-level access for reading and writing process
values. It also shows creation of a KNXNetworkLink, which is supplied to the process
communicator, and serves as the link to the KNX network. For group monitoring, the tool uses
Datapoint and DatapointModel to persist datapoints between tool invocations.
When running this tool from the terminal, method main of this class is invoked;
otherwise, use this class in the context appropriate to a Runnable, or use
start(ProcessListener) and quit().
In console mode, datapoint values as well as occurring problems are written to
System.out.
Note that communication will use default settings if not specified otherwise using command line options. Since these settings might be system dependent (for example, the local host) and not always predictable, a user may want to specify particular settings using the available options.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected tuwien.auto.calimero.process.ProcessCommunicatorThe used process communicator. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringReturns a string translation of the datapoint data for the specified datapoint type, using the process event ASDU.protected StringdecodeLteFrame(tuwien.auto.calimero.process.LteProcessEvent e) protected voidissueCommand(String line) Issues a read, write, or info command.static voidEntry point for running ProcComm.protected voidonCompletion(Exception thrown, boolean canceled) Called by this tool on completion.protected voidonGroupEvent(tuwien.auto.calimero.process.ProcessEvent e) Called by this tool on receiving a process communication group event.protected voidonReadResponse(tuwien.auto.calimero.datapoint.Datapoint dp, String value) If this tool instance is executing a read command, notifies about the read response (if any).voidquit()Quits process communication.voidrun()voidstart(tuwien.auto.calimero.process.ProcessListener l) Starts the process communicator and returns.
-
Field Details
-
pc
protected tuwien.auto.calimero.process.ProcessCommunicator pcThe used process communicator.
-
-
Constructor Details
-
ProcComm
Creates a new ProcComm instance using the supplied options.Mandatory arguments are an IP host or a FT1.2 port identifier, depending on the type of connection to the KNX network. See
main(String[])for the list of options.- Parameters:
args- list with options- Throws:
tuwien.auto.calimero.KNXIllegalArgumentException- on unknown/invalid options
-
-
Method Details
-
main
Entry point for running ProcComm. The endpoint for KNX network access is either an IP host or port identifier for IP, USB, FT1.2 or TP-UART communication. Use the command line option--help(or-h) to show the usage of this tool.Command line options are treated case sensitive. Available options for communication:
--help -hshow help message--versionshow tool/library version and exit--compact -cshow incoming process communication data in compact format--localhostid local IP/host name--localportnumber local UDP port (default system assigned)--port -pnumber UDP port on host (default 3671)--nat -nenable Network Address Translation--ft12 -fuse FT1.2 serial communication--usb -uuse KNX USB communication--tpuartuse TP-UART communication--medium -mid KNX medium [tp1|p110|knxip|rf] (defaults to tp1)--domainaddress domain address on open KNX medium (PL or RF)--snnumber device serial number to use in RF multicasts & broadcasts--knx-address -kKNX address KNX device address of local endpoint
--knx-addressoption is only necessary if an access protocol is selected that directly communicates with the KNX network, i.e., KNX IP or TP-UART. The selected KNX individual address shall be unique in a network, and the subnetwork address (area and line) should be set to match the network configuration.Available commands for process communication:
readgroup-address [DPT] read from datapoint with the specified group address, using DPT value format (optional)writegroup-address [DPT] value write to datapoint with the specified group address, using DPT value formatmonitorenter group monitoring
cmd DP [DPT] [value], withcmd = ("r"|"read") | ("w"|"write").
Additionally, the tool will either create or load an existing datapoint list and maintain it with all datapoints being read or written. Hence, once the datapoint type of a datapoint is known, the DPT part can be omitted from the command. The datapoint list is saved to the current working directory.
Examples:write 1/0/1 switch off,w 1/0/1 off,r 1/0/1.For common datapoint types (DPTs) the following name aliases can be used instead of the general DPT number string:
switchfor DPT 1.001, with valuesoff,onboolfor DPT 1.002, with valuesfalse,truedimmerfor DPT 3.007, with valuesdecrease 0..7,increase 0..7blindsfor DPT 3.008, with valuesup 0..7,down 0..7percentfor DPT 5.001, with values0..100%for DPT 5.001, with values0..100anglefor DPT 5.003, with values0..360ucountfor DPT 5.010, with values0..255tempfor DPT 9.001, with values-273..+670760floatorfloat2for DPT 9.002float4for DPT 14.005intfor DPT 13.001stringfor DPT 16.001
- Parameters:
args- command line options for process communication
-
run
public void run() -
start
public void start(tuwien.auto.calimero.process.ProcessListener l) throws tuwien.auto.calimero.KNXException, InterruptedException Starts the process communicator and returns.This method immediately returns when this process communicator is already running. Call
quit()to quit process communication. Restarting a process communicator is not supported.- Parameters:
l- a process event listener, can benull- Throws:
tuwien.auto.calimero.KNXException- on problems creating network link or communicationInterruptedException- on interrupted thread
-
quit
public void quit()Quits process communication.Detaches the network link from the process communicator and closes the link.
-
issueCommand
protected void issueCommand(String line) throws tuwien.auto.calimero.KNXException, InterruptedException Issues a read, write, or info command.- Parameters:
line- line with command and arguments, e.g., "write 1/0/3 switch off"- Throws:
tuwien.auto.calimero.KNXExceptionInterruptedException- See Also:
-
onGroupEvent
protected void onGroupEvent(tuwien.auto.calimero.process.ProcessEvent e) Called by this tool on receiving a process communication group event.- Parameters:
e- the process event
-
onReadResponse
If this tool instance is executing a read command, notifies about the read response (if any).- Parameters:
dp- datapointvalue- formatted read response, or hexadecimal representation ifdphas noDPTset
-
onCompletion
Called by this tool on completion.- Parameters:
thrown- the thrown exception if operation completed due to a raised exception,nullotherwisecanceled- whether the operation got canceled before its planned end
-
asString
protected String asString(byte[] asdu, int dptMainNumber, String dptID) throws tuwien.auto.calimero.KNXException Returns a string translation of the datapoint data for the specified datapoint type, using the process event ASDU.- Parameters:
asdu- the process event ASDU with the datapoint datadptMainNumber- DPT main number ≥ 0, can be 0 if thedptIDis uniquedptID- datapoint type ID to lookup the translator- Returns:
- the datapoint value
- Throws:
tuwien.auto.calimero.KNXException- on failed creation of translator, or translator not available
-
decodeLteFrame
protected String decodeLteFrame(tuwien.auto.calimero.process.LteProcessEvent e) throws tuwien.auto.calimero.KNXFormatException - Throws:
tuwien.auto.calimero.KNXFormatException
-