Skip to content

Commit

Permalink
Renaming for device simulator (#31)
Browse files Browse the repository at this point in the history
Rename device simulator to industrial data simulator.
  • Loading branch information
ethanperry1 authored Nov 15, 2023
1 parent 79e3ed8 commit 67a4328
Show file tree
Hide file tree
Showing 118 changed files with 281 additions and 277 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/device_simulator_test.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
name: device-simulator_build
name: industrial_data_simulator_build

on:
workflow_dispatch:
push:
tags:
- 'v*.*.*-device-simulator'
- 'v*.*.*-industrial-data-simulator'

jobs:
call-docker-build:
uses: ./.github/workflows/docker_build.yml
with:
registry: makocr.azurecr.io/device-simulator
file: samples/device-simulator/Dockerfile
registry: makocr.azurecr.io/industrial-data-simulator
file: samples/industrial-data-simulator/Dockerfile
context: .
secrets:
azureCredentials: ${{ secrets.AZURE_CREDENTIALS }}
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/industrial_data_simulator_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: industrial_data_simulator_test

on:
workflow_dispatch:
push:
paths:
- samples/industrial-data-simulator/**

jobs:
call-mage-test:
uses: ./.github/workflows/mage_tests.yml
with:
workdir: samples/industrial-data-simulator/
2 changes: 1 addition & 1 deletion docs/ORGANIZATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ Explore IoT Operations is a collection of tools and samples for customers of Azu

## Linting, Formatting, and Testing Requirements

Linting, formatting, and testing are not required but are highly recommended. The mage library under `./lib/mage` is provided for golang projects and offers some basic commands for linting, formatting, building, testing, and assuring test coverage bars. Comments describe each function within the library. See `./samples/device-simulation/mage.go` for an example of how this library is used.
Linting, formatting, and testing are not required but are highly recommended. The mage library under `./lib/mage` is provided for golang projects and offers some basic commands for linting, formatting, building, testing, and assuring test coverage bars. Comments describe each function within the library. See `./samples/industrial-data-simulator/mage.go` for an example of how this library is used.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ FROM mcr.microsoft.com/oss/go/microsoft/golang:1.21-cbl-mariner2.0 AS build

COPY ./lib /workdir/lib

COPY ./samples/device-simulator /workdir/samples/device-simulator
COPY ./samples/industrial-data-simulator /workdir/samples/industrial-data-simulator

WORKDIR /workdir/samples/device-simulator
WORKDIR /workdir/samples/industrial-data-simulator

RUN go mod download

RUN go install github.com/magefile/mage@latest

RUN mage ci

RUN go build -o ./bin/device-simulator ./cmd
RUN go build -o ./bin/industrial-data-simulator ./cmd

EXPOSE 2112

CMD [ "/bin/device-simulator" ]
CMD [ "/bin/industrial-data-simulator" ]
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
# Device Simulator
# Industrial Data Simulator

```
____ _ _____ _ _ _
| \ ___ _ _|_|___ ___ | __|_|_____ _ _| |___| |_ ___ ___
| | | -_| | | | _| -_| |__ | | | | | | .'| _| . | _|
|____/|___|\_/|_|___|___| |_____|_|_|_|_|___|_|__,|_| |___|_|
_____ ______ _____ _ _ _ _______ ______ _____ _ _____ _______ _ _____ ______ _ _ _ _______ _____ ______
(_____) ___ \(____ \ | | | | | | (_______|_____ \(_____) /\ | | (____ \ /\ (_______) /\ | | (_____) ___ \| | | | | /\ (_______) ___ \(_____ \
_ | | | |_ \ \| | | | \ \ _ _____) ) _ / \ | | _ \ \ / \ _ / \ \ \ _ | | _ | | | | | | / \ _ | | | |_____) )
| | | | | | | | | | | | \ \| | (_____ ( | | / /\ \| | | | | / /\ \| | / /\ \ \ \ | | | || || | | | | | / /\ \| | | | | (_____ (
_| |_| | | | |__/ /| |___| |_____) ) |_____ | |_| |_| |__| | |_____ | |__/ / |__| | |_____| |__| | _____) )| |_| || || | |___| | |_____| |__| | |____| |___| | | |
(_____)_| |_|_____/ \______(______/ \______) |_(_____)______|_______) |_____/|______|\______)______| (______(_____)_||_||_|\______|_______)______|\______)_____/ |_|
```

Device Simulator is a highly configurable MQTT asset simulator.
Industrial Data Simulator is a highly configurable MQTT asset simulator.

## Usage

### Device Simulator as K8s Pod
### Industrial Data Simulator as K8s Pod

```sh
# From the root of the device-simulator directory.
docker build ../.. -f Dockerfile -t <yourcrhere>.azurecr.io/device-simulator:latest
# From the root of the industrial-data-simulator directory.
docker build ../.. -f Dockerfile -t <yourcrhere>.azurecr.io/industrial-data-simulator:latest

# Or if running from the root of the explore-iot-operations repository.
# docker build . -f ./samples/device-simulator/Dockerfile -t <yourcrhere>.azurecr.io/device-simulator:latest
# docker build . -f ./samples/industrial-data-simulator/Dockerfile -t <yourcrhere>.azurecr.io/industrial-data-simulator:latest

# Push or load your newly built image into your cluster, depending on the k8s setup.
# docker push <yourcrhere>.azurecr.io/device-simulator:latest # Using AKS + Connected ACR
# minikube load <yourcrhere>.azurecr.io/device-simulator:latest # Using minikube
# docker save <yourcrhere>.azurecr.io/device-simulator:latest | k3s ctr images import - # Using K3s
# docker push <yourcrhere>.azurecr.io/industrial-data-simulator:latest # Using AKS + Connected ACR
# minikube load <yourcrhere>.azurecr.io/industrial-data-simulator:latest # Using minikube
# docker save <yourcrhere>.azurecr.io/industrial-data-simulator:latest | k3s ctr images import - # Using K3s

kubectl run device-simulator --image=<yourcrhere>.azurecr.io/device-simulator:latest --stdin < config.yml
kubectl run industrial-data-simulator --image=<yourcrhere>.azurecr.io/industrial-data-simulator:latest --stdin < config.yml
```

Device simulator runs as a pod within the desired cluster using the kubectl run command. The configuration of choice is provided via stdin of the simulator process within the pod, provided in the command above using `--stdin < config.yml`. Alternative names for a configuration file may be used -- the command simply uses stdin piping to provide simulator with an appropriate configuration.
Industrial Data simulator runs as a pod within the desired cluster using the kubectl run command. The configuration of choice is provided via stdin of the simulator process within the pod, provided in the command above using `--stdin < config.yml`. Alternative names for a configuration file may be used -- the command simply uses stdin piping to provide simulator with an appropriate configuration.

See the example YAML configuration below, with comments describing the various configurable fields.

Expand Down Expand Up @@ -93,12 +95,12 @@ simulation:

```

### Device Simulator on the Command Line
### Industrial Data Simulator on the Command Line

#### Method 1

```sh
# With Golang installed, the device simulator can be run from the cmd folder.
# With Golang installed, the simulator can be run from the cmd folder.
cd ./cmd
go run . < config.yml
# Or by reading in a file instead of stdin:
Expand All @@ -108,12 +110,12 @@ go run . < config.yml
#### Method 2

```sh
# With Golang installed, build a binary of the device simulator.
go build -o ./bin/device-simulator ./cmd
./device-simulator < config.yml
# With Golang installed, build a binary of the simulator.
go build -o ./bin/industrial-data-simulator ./cmd
./industrial-data-simulator < config.yml

# Or by reading in a file instead of stdin:
# ./device-simulator --stdin=false --config=config.yml
# ./industrial-data-simulator --stdin=false --config=config.yml
```

## Configuring a Simulation
Expand Down Expand Up @@ -207,5 +209,5 @@ Example Equations:

Prometheus metrics are provided by the simulator at the port specified in the metrics field of the configuration. The available metrics are:

1. `device_simulator_entity_gauge` - shows the count of each system entity.
1. `device_simulator_<siteName>_asset_publish_counter` - records the number of messages published, labeled by asset identifier.
1. `industrial_data_simulator_entity_gauge` - shows the count of each system entity.
1. `industrial_data_simulator_<siteName>_asset_publish_counter` - records the number of messages published, labeled by asset identifier.
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ import (

"github.com/explore-iot-ops/lib/env"
"github.com/explore-iot-ops/lib/logger"
"github.com/explore-iot-ops/samples/device-simulator/components/broker"
"github.com/explore-iot-ops/samples/device-simulator/components/client"
"github.com/explore-iot-ops/samples/device-simulator/components/edge"
"github.com/explore-iot-ops/samples/device-simulator/components/formatter"
"github.com/explore-iot-ops/samples/device-simulator/components/limiter"
"github.com/explore-iot-ops/samples/device-simulator/components/node"
"github.com/explore-iot-ops/samples/device-simulator/components/observer"
"github.com/explore-iot-ops/samples/device-simulator/components/outlet"
"github.com/explore-iot-ops/samples/device-simulator/components/provider"
"github.com/explore-iot-ops/samples/device-simulator/components/publisher"
"github.com/explore-iot-ops/samples/device-simulator/components/registry"
"github.com/explore-iot-ops/samples/device-simulator/components/renderer"
"github.com/explore-iot-ops/samples/device-simulator/components/site"
"github.com/explore-iot-ops/samples/device-simulator/components/subscriber"
"github.com/explore-iot-ops/samples/device-simulator/components/topic"
"github.com/explore-iot-ops/samples/device-simulator/components/tracer"
"github.com/explore-iot-ops/samples/device-simulator/lib/exporter"
"github.com/explore-iot-ops/samples/device-simulator/lib/external"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/broker"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/client"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/edge"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/formatter"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/limiter"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/node"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/observer"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/outlet"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/provider"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/publisher"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/registry"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/renderer"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/site"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/subscriber"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/topic"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/tracer"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/exporter"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/external"
"gopkg.in/yaml.v3"

"github.com/prometheus/client_golang/prometheus"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package broker
import (
"fmt"

"github.com/explore-iot-ops/samples/device-simulator/components/registry"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/registry"
)

type Source interface {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package broker

import (
"github.com/explore-iot-ops/samples/device-simulator/components/observer"
"github.com/explore-iot-ops/samples/device-simulator/components/registry"
"github.com/explore-iot-ops/samples/device-simulator/lib/component"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/observer"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/registry"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/component"
)

type Store component.Store[Source, component.ID]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ package broker
import (
"testing"

"github.com/explore-iot-ops/samples/device-simulator/components/observer"
"github.com/explore-iot-ops/samples/device-simulator/components/registry"
"github.com/explore-iot-ops/samples/device-simulator/lib/component"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/observer"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/registry"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/component"
"github.com/stretchr/testify/require"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"time"

"github.com/explore-iot-ops/lib/logger"
"github.com/explore-iot-ops/samples/device-simulator/components/registry"
"github.com/explore-iot-ops/samples/device-simulator/components/site"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/registry"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/site"

mqtt "github.com/eclipse/paho.mqtt.golang"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

mqttv5 "github.com/eclipse/paho.golang/paho"
mqtt "github.com/eclipse/paho.mqtt.golang"
"github.com/explore-iot-ops/samples/device-simulator/components/site"
"github.com/explore-iot-ops/samples/device-simulator/lib/errors"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/site"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/errors"
"github.com/stretchr/testify/require"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package client
import (
"fmt"

"github.com/explore-iot-ops/samples/device-simulator/lib/errors"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/errors"
)

type BrokerConnectionError struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"context"

"github.com/explore-iot-ops/lib/logger"
"github.com/explore-iot-ops/samples/device-simulator/components/broker"
"github.com/explore-iot-ops/samples/device-simulator/components/observer"
"github.com/explore-iot-ops/samples/device-simulator/components/registry"
"github.com/explore-iot-ops/samples/device-simulator/components/site"
"github.com/explore-iot-ops/samples/device-simulator/lib/component"
"github.com/explore-iot-ops/samples/device-simulator/lib/dialer"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/broker"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/observer"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/registry"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/site"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/component"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/dialer"

mqttv5 "github.com/eclipse/paho.golang/paho"
mqttv3 "github.com/eclipse/paho.mqtt.golang"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"net"
"testing"

"github.com/explore-iot-ops/samples/device-simulator/components/broker"
"github.com/explore-iot-ops/samples/device-simulator/components/registry"
"github.com/explore-iot-ops/samples/device-simulator/components/site"
"github.com/explore-iot-ops/samples/device-simulator/lib/component"
"github.com/explore-iot-ops/samples/device-simulator/lib/dialer"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/broker"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/registry"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/site"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/component"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/dialer"
"github.com/stretchr/testify/require"

mqttv5 "github.com/eclipse/paho.golang/paho"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package edge
import (
"testing"

"github.com/explore-iot-ops/samples/device-simulator/lib/component"
"github.com/explore-iot-ops/samples/device-simulator/lib/composition"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/component"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/composition"
"github.com/stretchr/testify/require"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ package edge
import (
"fmt"

"github.com/explore-iot-ops/samples/device-simulator/lib/component"
"github.com/explore-iot-ops/samples/device-simulator/lib/errors"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/component"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/errors"
)

type InvalidPositionError struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
package edge

import (
"github.com/explore-iot-ops/samples/device-simulator/components/node"
"github.com/explore-iot-ops/samples/device-simulator/lib/component"
"github.com/explore-iot-ops/samples/device-simulator/lib/composition"
"github.com/explore-iot-ops/samples/industrial-data-simulator/components/node"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/component"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/composition"
)

type Store component.Store[composition.Edge, component.ID]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package formatter
import (
"fmt"

"github.com/explore-iot-ops/samples/device-simulator/lib/errors"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/errors"
)

type InvalidTypeError struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"io"

protoEncoder "github.com/explore-iot-ops/lib/proto"
binaryEncoder "github.com/explore-iot-ops/samples/device-simulator/lib/binary"
"github.com/explore-iot-ops/samples/device-simulator/lib/flatten"
binaryEncoder "github.com/explore-iot-ops/samples/industrial-data-simulator/lib/binary"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/flatten"
"google.golang.org/protobuf/proto"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"testing"

"github.com/explore-iot-ops/lib/proto"
"github.com/explore-iot-ops/samples/device-simulator/lib/binary"
"github.com/explore-iot-ops/samples/device-simulator/lib/flatten"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/binary"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/flatten"
"github.com/stretchr/testify/require"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"encoding/binary"

"github.com/explore-iot-ops/lib/proto"
encoder "github.com/explore-iot-ops/samples/device-simulator/lib/binary"
"github.com/explore-iot-ops/samples/device-simulator/lib/component"
"github.com/explore-iot-ops/samples/device-simulator/lib/flatten"
encoder "github.com/explore-iot-ops/samples/industrial-data-simulator/lib/binary"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/component"
"github.com/explore-iot-ops/samples/industrial-data-simulator/lib/flatten"
)

type Store component.Store[Formatter, component.ID]
Expand Down
Loading

0 comments on commit 67a4328

Please sign in to comment.