Skip to content

Commit

Permalink
comments .. type and explicit string manip
Browse files Browse the repository at this point in the history
  • Loading branch information
noursaidi committed Jun 9, 2022
1 parent 900d940 commit 237ec8a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
8 changes: 3 additions & 5 deletions bin/pubber
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,15 @@ else
for option in $*; do
if [[ $option == *"="* ]]; then
k=$(echo $option | cut -d'=' -f1)
v=$(echo $option | cut -d'=' -f2)
if ! [[ $v =~ ^[0-9]+([.][0-9]+)?$ ]]; then
v="\"$v\""
fi
v="\"$(echo $option | cut -d'=' -f2)\""
else
k=$option
v=true
fi
printf -v options_json '%s"%s":%s,' "$options_json" "$k" "$v"
done
options_json="{${options_json%?}}"
options_json="{${options_json%,}}"

cloud_region=`jq -r .cloud_region $site_path/cloud_iot_config.json`

cat <<EOF > /tmp/pubber_config.json
Expand Down
4 changes: 2 additions & 2 deletions pubber/src/main/java/daq/pubber/ConfigurationOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
public class ConfigurationOptions {
public Boolean noHardware = false;
public Boolean extraPoint = false;
public Boolean extraField = false;
public String extraPoint = "";
public String extraField = "";

}
10 changes: 4 additions & 6 deletions pubber/src/main/java/daq/pubber/Pubber.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static java.util.stream.Collectors.toMap;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
Expand Down Expand Up @@ -77,7 +76,6 @@ public class Pubber {
private static final String UDMI_VERSION = "1.3.14";
private static final Logger LOG = LoggerFactory.getLogger(Pubber.class);
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper()
.disable(MapperFeature.ALLOW_COERCION_OF_SCALARS)
.enable(SerializationFeature.INDENT_OUTPUT)
.setDateFormat(new ISO8601DateFormat())
.setSerializationInclusion(JsonInclude.Include.NON_NULL);
Expand Down Expand Up @@ -375,12 +373,12 @@ private void initializeDevice() {
deviceState.system.last_config = new Date(0);

// Pubber runtime options
if (configuration.options.extraField) {
devicePoints.extraField = "extra_field";
if (!configuration.options.extraField.isEmpty()) {
devicePoints.extraField = configuration.options.extraField;
}

if (configuration.options.extraPoint) {
addPoint(makePoint("extra_point",
if (!configuration.options.extraPoint.isEmpty()) {
addPoint(makePoint(configuration.options.extraPoint,
makePointPointsetModel(true, 50, 50, "Celsius")));
}

Expand Down

0 comments on commit 237ec8a

Please sign in to comment.