kchief

package
v0.0.0-...-64332c0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

README

Kchief simulator

This package contains 4 tools:

Each respective package are described below.

protoencoder

Flags:

  -inJsonFile string
    specify the full path of the json file to take as input
  -outFile string
    specify the filename of the output file (default "myfile.bin")

protoencoder let's you generate a Khief proto file based on a JSON file describing tags and values. Example of JSON file below.

{
    "dataPoints": [{
            "tagName": "MAN-TAGER-HVA-MAN-HAVER",
            "value": 1.1
        },
        {
            "tagName": "ANTAGER",
            "value": -2.2
        },
        {
            "tagName": "SINNATAG",
            "value": 1
        }
    ]
}

The output will be a binary file containing protobuf data.

protodecoder

Flags:

  -fileName string
    The full path with the filename of the Kchief protobuf data file (default "./sample/sample2.bin")

protodecode will let you decode a binary protobuf, unmarshal it from protobuf format into ascii key/values, and print the output to console.

mqttpublish

Flags:

  -broker string
    The ip address of the MQTT broker (default "10.0.0.26")
  -clientID string
    The client ID to use with MQTT (default "btclient1")
  -delay int
    The number of milliseconds to wait between each mqtt publish (default 300)
  -inFile value
    specify the files to use as input comma separated
  -port string
    The port where the MQTT broker listens (default "1883")
  -protocol string
    The protocol to use when connecting to the MQTT broker (default "tcp")
  -repetitions int
    specify how many repetitions to run (default 1)
  -topic string
    The name of the MQTT topic (default "CloudBoundContainer")

mqttpublish will let you publish data like for example protobuf binary data to a MQTT broker. The package let's you specify more infiles by repeating the use of the --inFile flag. Repetitions and delay between each send can be tuned with flags. Example below.

go run main.go --inFile=./ship1.bin --inFile=./ship2.bin --repetitions=1000 --delay=1

mqttsubscribe

Flags:

  -broker string
    The ip address of the MQTT broker (default "10.0.0.26")
  -clientID string
    The client ID to use with MQTT (default "btclient2")
  -port string
    The port where the MQTT broker listens (default "1883")
  -protocol string
    The protocol to use when connecting to the MQTT broker (default "tcp")
  -topic string
    The name of the MQTT topic (default "CloudBoundContainer")

mqttsubscribe will let you subscribe to a MQTT topic on a specified broker. The messages received will be saved in it's binary format and the naming will be numbered incrementally for each package received.

protodecoder can then be used to decode the files of the received messages to verify their correctness.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunProtoEncode

func RunProtoEncode(fileName string, inJsonFile string) error

RunProtoEncode will loop over the TagDataPoints specified in the JSON file given as input, and create TagDataPoints for each of them, put them in a Payload struct, and add each one to the Payloads slice.

func RunProtoReader

func RunProtoReader(filename string) error

RunProtoReader will start the process, and read the protobuf binary file from disk, unmarshall the Message struct from the proto spesification, unzip the Data, then iterate through the structure described above to get the TAG, Timestamp and value fields.

Types

This section is empty.

Directories

Path Synopsis
cmd
tmp

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL