Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COE-914 oee simulators modify unclear parameter definitions count maximum per hour and count minimum per hour #82

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions simulators/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Description OEE-Simulators

OEE-simulators offers these main features in [main](simulators/main):
OEE-simulators offers these main features in [main](main):
- the **oee-simulators microservice** which creates devices and sends data into Cumulocity.
- the **profile generator** to create/delete OEE calculation profiles from the command line.

There are extra features in [extras](simulators/extras):
There are extra features in [extras](extras):
- the **export profile data** to export Measurements or/and Alarms from OEE profiles into json data files.
- the **import data** to upload Measurements or/and Alarms from data json file to OEE profiles.

Expand All @@ -17,7 +17,7 @@ Detailed feature list:
- automatically creates devices and sends data
- identifies devices using a configurable `externalId`
- devices can be disabled to not send any events and measurements
- the number of events and measurements per hour can be configured as a random number in a range
- the number of **events** and **measurements** **per hour** can be configured as a random number in a range
```
"minimumPerHour": 5,
"maximumPerHour": 10
Expand All @@ -26,7 +26,7 @@ Detailed feature list:
```
"frequency": 20
```
- the availibility of machine is expressed as probability value with range from 0.0 to 1.0
- the availability of machine is expressed as probability value with range from 0.0 to 1.0
- the timestamp of the following `Piece_ok` event is the same as corresponding `Piece_Produced` event
- the expected quality of production is configurable.
```
Expand All @@ -38,6 +38,19 @@ Detailed feature list:
}
```
the expected quality would be 80% (*followedBy.frequency/frequency * 100%*)
- For the `Pieces_Produced`, the simulator produces multiple pieces at a time so the minimum (`piecesMinimumPerProduction`) and maximum pieces per production (`piecesMaximumPerProduction`) must be set
```
"type": "Pieces_Produced",
"frequency": 6,
"piecesMinimumPerProduction": 1,
"piecesMaximumPerProduction": 10,
"followedBy": {
"type": "Pieces_Ok",
"piecesMinimumPerProduction": 0,
"piecesMaximumPerProduction": 10,
"frequency": 6
}
```
- the kind of measurement that should be sent, can be defined by
```
"type": "PumpPressure",
Expand Down Expand Up @@ -66,7 +79,7 @@ cd oee-simulators/simulators
docker build -t oee-simulators .
docker save -o image.tar oee-simulators
```
In [cumulocity.json](oee-simulators/simulators/cumulocity.json), change "version" from "@project.version@" to version number you want in format xx.xx.xx (example: "version": "12.20.11"). If you want to use the same version for multiple uploads, "latest" can be used in the last position (example: "version": "12.20.latest").
In [cumulocity.json](cumulocity.json), change "version" from "@project.version@" to version number you want in format xx.xx.xx (example: "version": "12.20.11"). If you want to use the same version for multiple uploads, "latest" can be used in the last position (example: "version": "12.20.latest").
Then compress both the [cumulocity.json] and the newly created [image.tar] files into a ZIP file or execute the command below to create [oee-simulators.zip] file:
```
zip oee-simulators.zip image.tar cumulocity.json
Expand Down
18 changes: 10 additions & 8 deletions simulators/main/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ def get_production_speed_s(self) -> float:
return frequency / 3600.0
if event_type == "Pieces_Produced":
frequency = event_definition.get("frequency")
countMaximumPerHour = event_definition.get("countMaximumPerHour")
return frequency * countMaximumPerHour / 3600.0
piecesMaximumPerProduction = event_definition.get("piecesMaximumPerProduction")
return frequency * piecesMaximumPerProduction / 3600.0

return 0.0

Expand Down Expand Up @@ -138,12 +138,14 @@ def on_pieces_produced_event(self, event_definition, task):

self.produce_pieces()

countMaximumPerHour = event_definition.get("countMaximumPerHour") or 10
piecesMinimumPerProduction = event_definition.get("piecesMinimumPerProduction") or 1
piecesMaximumPerProduction = event_definition.get("piecesMaximumPerProduction") or 10
piecesPerProduction = randint(piecesMinimumPerProduction, piecesMaximumPerProduction)

frequency = event_definition.get("frequency") or 1

event = self.type_fragment(event_definition)
pieces_produced = self.pick_pieces(frequency * countMaximumPerHour / 3600.0)
pieces_produced = self.pick_pieces(frequency * piecesPerProduction / 3600.0)
event.update({"count": pieces_produced})
event.update(self.get_production_info())

Expand All @@ -164,15 +166,15 @@ def on_piece_ok_event(self, event_definition, task):
def on_pieces_ok_event(self, event_definition, task):
event = self.type_fragment(event_definition)

countMinimumPerHour = event_definition.get("countMinimumPerHour") or 0
countMaximumPerHour = event_definition.get("countMaximumPerHour") or 10
piecesMinimumPerProduction = event_definition.get("piecesMinimumPerProduction") or 0
piecesMaximumPerProduction = event_definition.get("piecesMaximumPerProduction") or 10

piece_produced_timestamp = None
if hasattr(task, 'extra'):
piece_produced_timestamp = task.extra["timestamp"]
countMaximumPerHour = task.extra.get("pieces_produced") or countMaximumPerHour
piecesMaximumPerProduction = task.extra.get("pieces_produced") or piecesMaximumPerProduction

event.update({"count": randint(min(countMinimumPerHour, countMaximumPerHour), countMaximumPerHour)})
event.update({"count": randint(min(piecesMinimumPerProduction, piecesMaximumPerProduction), piecesMaximumPerProduction)})

self.send_event(event, piece_produced_timestamp)

Expand Down
2 changes: 1 addition & 1 deletion simulators/main/profile_templates/sim_010_profile.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"shortShutdowns": null,
"version": "2.0.0",
"amountUnit": "",
"name": "Simulator Ideal Producer A90 - ${counter}",
"name": "Simulator Ideal Producer A80 - ${counter}",
"tenantId": "${tenantId}",
"locationId": "",
"external": false,
Expand Down
28 changes: 14 additions & 14 deletions simulators/main/simulator.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
{
"type": "Pieces_Produced",
"frequency": 6,
"countMinimumPerHour": 1,
"countMaximumPerHour": 10,
"piecesMinimumPerProduction": 1,
"piecesMaximumPerProduction": 10,
"followedBy": {
"type": "Pieces_Ok",
"countMinimumPerHour": 0,
"countMaximumPerHour": 10,
"piecesMinimumPerProduction": 0,
"piecesMaximumPerProduction": 10,
"frequency": 6
}
}
Expand All @@ -71,8 +71,8 @@
{
"type": "Pieces_Produced",
"frequency": 6,
"countMinimumPerHour": 0,
"countMaximumPerHour": 10
"piecesMinimumPerProduction": 0,
"piecesMaximumPerProduction": 10
},
{
"type": "Piece_Quality",
Expand Down Expand Up @@ -256,12 +256,12 @@
{
"type": "Pieces_Produced",
"frequency": 60,
"countMinimumPerHour": 5,
"countMaximumPerHour": 5,
"piecesMinimumPerProduction": 5,
"piecesMaximumPerProduction": 5,
"followedBy": {
"type": "Pieces_Ok",
"countMinimumPerHour": 5,
"countMaximumPerHour": 5,
"piecesMinimumPerProduction": 5,
"piecesMaximumPerProduction": 5,
"frequency": 60
}
}
Expand All @@ -285,12 +285,12 @@
{
"type": "Pieces_Produced",
"frequency": 60,
"countMinimumPerHour": 5,
"countMaximumPerHour": 5,
"piecesMinimumPerProduction": 5,
"piecesMaximumPerProduction": 5,
"followedBy": {
"type": "Pieces_Ok",
"countMinimumPerHour": 5,
"countMaximumPerHour": 5,
"piecesMinimumPerProduction": 5,
"piecesMaximumPerProduction": 5,
"frequency": 60
}
}
Expand Down