From cc0aafb9ea4409debe3cb099dec3501c62420e80 Mon Sep 17 00:00:00 2001 From: ethanperry1 <107274017+ethanperry1@users.noreply.github.com> Date: Tue, 16 Jan 2024 10:51:11 -0800 Subject: [PATCH] Ethanperry/change machine status casing (#51) ## Purpose * ... No breaking changes, added mqtt v5 version to all site configs for the industrial data simulator. Changed the input casing of anomaly detection machine status to snake case on the input and camel case on the output. --- samples/anomaly-detection/cmd/config.yml | 24 ++++++++++++++ samples/anomaly-detection/cmd/main.go | 7 ++-- .../anomaly-detection/lib/payload/payload.go | 32 +++++++++++-------- .../cmd/config.yml | 9 ++++++ .../manifests/anomaly-detection/manifest.yml | 9 ++++++ .../manifests/oee/manifest.yml | 12 +++++++ 6 files changed, 77 insertions(+), 16 deletions(-) create mode 100644 samples/anomaly-detection/cmd/config.yml create mode 100644 samples/http-grpc-shift-calculation/cmd/config.yml diff --git a/samples/anomaly-detection/cmd/config.yml b/samples/anomaly-detection/cmd/config.yml new file mode 100644 index 0000000..abf8017 --- /dev/null +++ b/samples/anomaly-detection/cmd/config.yml @@ -0,0 +1,24 @@ +logger: + level: 0 +server: + route: /anomaly + port: 3333 +algorithm: + temperature: + lambda: 0.25 + lFactor: 3 + controlT: 90 + controlS: 20 + controlN: 10 + vibration: + lambda: 0.25 + lFactor: 3 + controlT: 50 + controlS: 20 + controlN: 10 + humidity: + lambda: 0.25 + lFactor: 3 + controlT: 80 + controlS: 20 + controlN: 10 \ No newline at end of file diff --git a/samples/anomaly-detection/cmd/main.go b/samples/anomaly-detection/cmd/main.go index 1943830..570fa79 100644 --- a/samples/anomaly-detection/cmd/main.go +++ b/samples/anomaly-detection/cmd/main.go @@ -15,9 +15,9 @@ import ( "github.com/explore-iot-ops/samples/anomaly-detection/lib/ewma" "github.com/explore-iot-ops/samples/anomaly-detection/lib/payload" + "github.com/gofiber/fiber/v2" "github.com/rs/zerolog/log" "gopkg.in/yaml.v3" - "github.com/gofiber/fiber/v2" ) func main() { @@ -152,7 +152,7 @@ func run() error { With("humidity", fmt.Sprintf("%0.2f", input.Payload.Payload.Humidity)). With("asset_id", input.Payload.Payload.AssetID). With("asset_name", input.Payload.Payload.AssetName). - With("status", input.Payload.Payload.MaintainenceStatus). + With("status", input.Payload.Payload.MaintenanceStatus). With("name", input.Payload.Payload.Name). With("serial_number", input.Payload.Payload.SerialNumber). With("site", input.Payload.Payload.SerialNumber). @@ -180,7 +180,8 @@ func run() error { output := payload.Payload[payload.OutputPayload]{ Payload: payload.OutputPayload{ Payload: payload.OutputInnerPayload{ - CommonPayload: input.Payload.Payload, + CommonPayload: input.Payload.Payload.CommonPayload, + MachineStatus: input.Payload.Payload.MachineStatus, HumidityAnomalyFactor: humEwma, HumidityAnomaly: humAnomaly, TemperatureAnomalyFactor: tempEwma, diff --git a/samples/anomaly-detection/lib/payload/payload.go b/samples/anomaly-detection/lib/payload/payload.go index 806ce39..edf8a69 100644 --- a/samples/anomaly-detection/lib/payload/payload.go +++ b/samples/anomaly-detection/lib/payload/payload.go @@ -4,7 +4,12 @@ package payload type InputPayload struct { - Payload CommonPayload `json:"payload"` + Payload InputInnerPayload `json:"payload"` +} + +type InputInnerPayload struct { + CommonPayload + MaintenanceStatus string `json:"maintenanceStatus"` } type Payload[T any] struct { @@ -12,18 +17,18 @@ type Payload[T any] struct { } type CommonPayload struct { - AssetID string `json:"assetId"` - AssetName string `json:"assetName"` - MaintainenceStatus string `json:"maintainenceStatus"` - Name string `json:"name"` - SerialNumber string `json:"serialNumber"` - Site string `json:"site"` - SourceTimestamp string `json:"sourceTimestamp"` - OperatingTime int `json:"operatingTime"` - MachineStatus int `json:"machineStatus"` - Humidity float64 `json:"humidity"` - Temperature float64 `json:"temperature"` - Vibration float64 `json:"vibration"` + AssetID string `json:"assetId"` + AssetName string `json:"assetName"` + MaintenanceStatus string `json:"maintenanceStatus"` + Name string `json:"name"` + SerialNumber string `json:"serialNumber"` + Site string `json:"site"` + SourceTimestamp string `json:"sourceTimestamp"` + OperatingTime int `json:"operatingTime"` + MachineStatus int `json:"machine_status"` + Humidity float64 `json:"humidity"` + Temperature float64 `json:"temperature"` + Vibration float64 `json:"vibration"` } type OutputPayload struct { @@ -32,6 +37,7 @@ type OutputPayload struct { type OutputInnerPayload struct { CommonPayload + MachineStatus int `json:"machineStatus"` HumidityAnomalyFactor float64 `json:"humidityAnomalyFactor"` HumidityAnomaly bool `json:"humidityAnomaly"` TemperatureAnomalyFactor float64 `json:"temperatureAnomalyFactor"` diff --git a/samples/http-grpc-shift-calculation/cmd/config.yml b/samples/http-grpc-shift-calculation/cmd/config.yml new file mode 100644 index 0000000..dde1e23 --- /dev/null +++ b/samples/http-grpc-shift-calculation/cmd/config.yml @@ -0,0 +1,9 @@ + + logger: + level: 0 + server: + httpPort: 3333 + grpcPort: 3334 + calculator: + shifts: 3 + initialTime: 2023-11-16T00:00:00-08:00 \ No newline at end of file diff --git a/samples/industrial-data-simulator/manifests/anomaly-detection/manifest.yml b/samples/industrial-data-simulator/manifests/anomaly-detection/manifest.yml index 56180bc..5895cec 100644 --- a/samples/industrial-data-simulator/manifests/anomaly-detection/manifest.yml +++ b/samples/industrial-data-simulator/manifests/anomaly-detection/manifest.yml @@ -24,6 +24,7 @@ data: sites: - name: Seattle_Oven assetCount: 1 + mqttVersion: v5 tags: - id: oven_operating_time configuration: delta(now(), start)/1000 #Increase by 1 per second @@ -54,6 +55,7 @@ data: topicFormat: ContosoLLC/Seattle/Oven/{{.TagName}} - name: Seattle_Mixer assetCount: 1 + mqttVersion: v5 tags: - id: mixer_operating_time configuration: delta(now(), start)/1000 #Increase by 1 per second @@ -84,6 +86,7 @@ data: topicFormat: ContosoLLC/Seattle/Mixer/{{.TagName}} - name: Seattle_Slicer assetCount: 1 + mqttVersion: v5 tags: - id: slicer_operating_time configuration: delta(now(), start)/1000 #Increase by 1 per second @@ -111,6 +114,7 @@ data: topicFormat: ContosoLLC/Seattle/Slicer/{{.TagName}} - name: Redmond_Oven assetCount: 1 + mqttVersion: v5 tags: - id: oven_operating_time configuration: delta(now(), start)/1000 #Increase by 1 per second @@ -141,6 +145,7 @@ data: topicFormat: ContosoLLC/Redmond/Oven/{{.TagName}} - name: Redmond_Mixer assetCount: 1 + mqttVersion: v5 tags: - id: mixer_operating_time configuration: delta(now(), start)/1000 #Increase by 1 per second @@ -171,6 +176,7 @@ data: topicFormat: ContosoLLC/Redmond/Mixer/{{.TagName}} - name: Redmond_Slicer assetCount: 1 + mqttVersion: v5 tags: - id: slicer_operating_time configuration: delta(now(), start)/1000 #Increase by 1 per second @@ -198,6 +204,7 @@ data: topicFormat: ContosoLLC/Redmond/Slicer/{{.TagName}} - name: Tacoma_Oven assetCount: 1 + mqttVersion: v5 tags: - id: oven_operating_time configuration: delta(now(), start)/1000 #Increase by 1 per second @@ -228,6 +235,7 @@ data: topicFormat: ContosoLLC/Tacoma/Oven/{{.TagName}} - name: Tacoma_Mixer assetCount: 1 + mqttVersion: v5 tags: - id: mixer_operating_time configuration: delta(now(), start)/1000 #Increase by 1 per second @@ -258,6 +266,7 @@ data: topicFormat: ContosoLLC/Tacoma/Mixer/{{.TagName}} - name: Tacoma_Slicer assetCount: 1 + mqttVersion: v5 tags: - id: slicer_operating_time configuration: delta(now(), start)/1000 #Increase by 1 per second diff --git a/samples/industrial-data-simulator/manifests/oee/manifest.yml b/samples/industrial-data-simulator/manifests/oee/manifest.yml index 82aefcc..cb7a58d 100644 --- a/samples/industrial-data-simulator/manifests/oee/manifest.yml +++ b/samples/industrial-data-simulator/manifests/oee/manifest.yml @@ -17,6 +17,7 @@ data: sites: - name: RLine1_1 assetCount: 1 + mqttVersion: v5 tags: - id: assembly_lastcycletime configuration: rand(4900,5000) @@ -66,6 +67,7 @@ data: - name: RLine1_2 assetCount: 1 + mqttVersion: v5 tags: - id: test_lastcycletime configuration: rand(4900,5000) @@ -100,6 +102,7 @@ data: - name: RLine1_3 assetCount: 1 + mqttVersion: v5 tags: - id: packaging_lastcycletime configuration: rand(4900,5000) @@ -134,6 +137,7 @@ data: - name: RLine2_1 assetCount: 1 + mqttVersion: v5 tags: - id: assembly_lastcycletime configuration: rand(4900,5000) @@ -189,6 +193,7 @@ data: - name: RLine2_2 assetCount: 1 + mqttVersion: v5 tags: - id: test_lastcycletime configuration: rand(4900,5000) @@ -226,6 +231,7 @@ data: - name: RLine2_3 assetCount: 1 + mqttVersion: v5 tags: - id: packaging_lastcycletime configuration: rand(4900,5000) @@ -263,6 +269,7 @@ data: - name: SLine1_1 assetCount: 1 + mqttVersion: v5 tags: - id: assembly_lastcycletime configuration: rand(4900,5000) @@ -318,6 +325,7 @@ data: - name: SLine1_2 assetCount: 1 + mqttVersion: v5 tags: - id: test_lastcycletime configuration: rand(4900,5000) @@ -355,6 +363,7 @@ data: - name: SLine1_3 assetCount: 1 + mqttVersion: v5 tags: - id: packaging_lastcycletime configuration: rand(4900,5000) @@ -392,6 +401,7 @@ data: - name: SLine2_1 assetCount: 1 + mqttVersion: v5 tags: - id: assembly_lastcycletime configuration: rand(4900,5000) @@ -447,6 +457,7 @@ data: - name: SLine2_2 assetCount: 1 + mqttVersion: v5 tags: - id: test_lastcycletime configuration: rand(4900,5000) @@ -484,6 +495,7 @@ data: - name: SLine2_3 assetCount: 1 + mqttVersion: v5 tags: - id: packaging_lastcycletime configuration: rand(4900,5000)