Skip to content

Commit

Permalink
Apply factory pattern on Teltonika payloads
Browse files Browse the repository at this point in the history
Apply the factory design pattern on Teltonika payloads to allow for easier and nicer look and feel of the code. Ideally, should be expanded to be used by all Telematics devices to be added to OpenRemote. Would be cool if we could use that interface to autocreate MQTT handlers for different device manufacturers.
  • Loading branch information
pankalog committed Feb 2, 2024
1 parent b4f4eda commit 8521adb
Show file tree
Hide file tree
Showing 11 changed files with 486 additions and 488 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package org.openremote.manager.custom.telematics.processors.teltonika;

import com.fasterxml.jackson.core.JsonProcessingException;
import org.openremote.container.timer.TimerService;
import org.openremote.manager.custom.telematics.processors.teltonika.helpers.TeltonikaParameterData;
import org.openremote.model.asset.Asset;
import org.openremote.model.attribute.Attribute;
import org.openremote.model.attribute.AttributeMap;
import org.openremote.model.teltonika.TeltonikaConfiguration;
import org.openremote.model.teltonika.TeltonikaParameter;

import java.util.Map;
import java.util.logging.Logger;
Expand All @@ -16,11 +17,9 @@ public interface ITeltonikaPayload {
* Returns list of attributes depending on the Teltonika JSON Payload.
* Uses the logic and results from parsing the Teltonika Parameter IDs.
*
* @param payloadContent Payload coming from Teltonika device
* @return Map of {@link Attribute}s to be assigned to the {@link Asset}.
*/
AttributeMap getAttributesFromPayload(TeltonikaConfiguration config, TimerService timerService);

AttributeMap getAttributes(Map<Map.Entry<String, TeltonikaParameter>, Object> payloadMap, Logger logger);
Map<TeltonikaParameterData, Object> getAttributesFromPayload(TeltonikaConfiguration config, TimerService timerService) throws JsonProcessingException;

AttributeMap getAttributes(Map<TeltonikaParameterData, Object> payloadMap, TeltonikaConfiguration config, Logger logger);
}
Loading

0 comments on commit 8521adb

Please sign in to comment.