Skip to content

Commit

Permalink
Ethanperry/change machine status casing (#51)
Browse files Browse the repository at this point in the history
## Purpose
<!-- Describe the intention of the changes being proposed. What problem
does it solve or functionality does it add? -->
* ...

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.
  • Loading branch information
ethanperry1 committed Jan 16, 2024
1 parent a90f609 commit cc0aafb
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 16 deletions.
24 changes: 24 additions & 0 deletions samples/anomaly-detection/cmd/config.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions samples/anomaly-detection/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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,
Expand Down
32 changes: 19 additions & 13 deletions samples/anomaly-detection/lib/payload/payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,31 @@
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 {
Payload T `json:"payload"`
}

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 {
Expand All @@ -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"`
Expand Down
9 changes: 9 additions & 0 deletions samples/http-grpc-shift-calculation/cmd/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

logger:
level: 0
server:
httpPort: 3333
grpcPort: 3334
calculator:
shifts: 3
initialTime: 2023-11-16T00:00:00-08:00
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions samples/industrial-data-simulator/manifests/oee/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data:
sites:
- name: RLine1_1
assetCount: 1
mqttVersion: v5
tags:
- id: assembly_lastcycletime
configuration: rand(4900,5000)
Expand Down Expand Up @@ -66,6 +67,7 @@ data:
- name: RLine1_2
assetCount: 1
mqttVersion: v5
tags:
- id: test_lastcycletime
configuration: rand(4900,5000)
Expand Down Expand Up @@ -100,6 +102,7 @@ data:
- name: RLine1_3
assetCount: 1
mqttVersion: v5
tags:
- id: packaging_lastcycletime
configuration: rand(4900,5000)
Expand Down Expand Up @@ -134,6 +137,7 @@ data:
- name: RLine2_1
assetCount: 1
mqttVersion: v5
tags:
- id: assembly_lastcycletime
configuration: rand(4900,5000)
Expand Down Expand Up @@ -189,6 +193,7 @@ data:
- name: RLine2_2
assetCount: 1
mqttVersion: v5
tags:
- id: test_lastcycletime
configuration: rand(4900,5000)
Expand Down Expand Up @@ -226,6 +231,7 @@ data:
- name: RLine2_3
assetCount: 1
mqttVersion: v5
tags:
- id: packaging_lastcycletime
configuration: rand(4900,5000)
Expand Down Expand Up @@ -263,6 +269,7 @@ data:
- name: SLine1_1
assetCount: 1
mqttVersion: v5
tags:
- id: assembly_lastcycletime
configuration: rand(4900,5000)
Expand Down Expand Up @@ -318,6 +325,7 @@ data:
- name: SLine1_2
assetCount: 1
mqttVersion: v5
tags:
- id: test_lastcycletime
configuration: rand(4900,5000)
Expand Down Expand Up @@ -355,6 +363,7 @@ data:
- name: SLine1_3
assetCount: 1
mqttVersion: v5
tags:
- id: packaging_lastcycletime
configuration: rand(4900,5000)
Expand Down Expand Up @@ -392,6 +401,7 @@ data:
- name: SLine2_1
assetCount: 1
mqttVersion: v5
tags:
- id: assembly_lastcycletime
configuration: rand(4900,5000)
Expand Down Expand Up @@ -447,6 +457,7 @@ data:
- name: SLine2_2
assetCount: 1
mqttVersion: v5
tags:
- id: test_lastcycletime
configuration: rand(4900,5000)
Expand Down Expand Up @@ -484,6 +495,7 @@ data:
- name: SLine2_3
assetCount: 1
mqttVersion: v5
tags:
- id: packaging_lastcycletime
configuration: rand(4900,5000)
Expand Down

0 comments on commit cc0aafb

Please sign in to comment.