calimero-project / introduction

Code examples and additional documentation for using Calimero
20 stars 15 forks source link

How to know a datapointType that read must be done to read/write? #2

Closed rafaelkan closed 7 years ago

rafaelkan commented 7 years ago

For example how do I know how to read/write 'DPST-1-3' or 'DPST-5-1'

calimero-project commented 7 years ago

Datapoint types are translated using subtypes of tuwien.auto.calimero.dptxlator.DPTXlator. For example, DPST-1-3 is main number 1 and subtype 3, and corresponds to DPTXlatorBoolean.DPT_ENABLE. Its ID is "1.003". You can do either of the following:

... = new DPTXlatorBoolean(DPTXlatorBoolean.DPT_ENABLE);
... = TranslatorTypes.createTranslator(DPTXlatorBoolean.DPT_ENABLE);
... = TranslatorTypes.createTranslator(1, "1.003");

Note that the DPST notation is not directly supported.

Calimero cannot automatically know the exact datapoint types you require. If you want to keep a list of your datapoints, you can use a DatapointMap with StateDPs.

rafaelkan commented 7 years ago

OK, DPTXlatorBoolean dptx = new DPTXlatorBoolean(DPTXlatorBoolean.DPT_ENABLE); and now how do I get the value of a group and read it?

calimero-project commented 7 years ago

Take a look at the methods of tuwien.auto.calimero.process.ProcessCommunicator/Impl. If you add a process event listener, a ProcessEvent provides a method getASDU(). The ASDU you can also pass to a matching DPT translator.