Skip to content

Commit c16fad8

Browse files
authored
Merge pull request #19 from SoftwareAG/sim-with-categories
Sim with categories
2 parents 4325a07 + a9cad90 commit c16fad8

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

event-based-simulators/cumulocity.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"apiVersion": "1",
3-
"version": "1.0.27",
3+
"version": "1.0.28",
44
"provider": {
55
"name": "Viktor Tymoshenko (event-based simulators)"
66
},

event-based-simulators/main/categories.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
{
55
"categoryInput": "Availability Loss (Time)",
66
"name": "Planned maintenance",
7-
"id": "1",
7+
"id": "10001",
88
"status": "ACTIVE"
99
},
1010
{
1111
"categoryInput": "Availability Loss (Time)",
1212
"name": "Manual stops",
13-
"id": "2",
13+
"id": "10002",
1414
"status": "ACTIVE"
1515
}
1616
]

event-based-simulators/main/profile_generator.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,14 @@ def delete_profiles():
108108
c8y_api.create_managed_object(categories)
109109
elif (c8y_api.count_all_categories()) == 1:
110110
log.info('Update category managed object')
111-
c8y_category = c8y_api.get_calculation_categories()[0]
112-
c8y_api.update_managed_object(c8y_category['id'], categories)
111+
categories_by_id = {}
112+
for c in json.loads(categories)['categories'] + c8y_api.get_calculation_categories()[0]['categories']:
113+
categories_by_id[c['id']] = c
114+
mo_id = c8y_api.get_calculation_categories()[0]['id']
115+
fragment = {
116+
'categories': list(categories_by_id.values())
117+
}
118+
c8y_api.update_managed_object(mo_id, json.dumps(fragment))
113119
else:
114120
log.warning('More than 1 category managed object! Unable to update managed object')
115121
log.info('==========Categories created==========')

event-based-simulators/main/sim_0011_profile.template

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
"AvailabilityLossTime": [
3939
{
4040
"type": "MACHINE_EVENT",
41-
"category": "1",
41+
"category": "10001",
4242
"value": ""
4343
},
4444
{
4545
"type": "MACHINE_EVENT",
46-
"category": "2",
46+
"category": "10002",
4747
"value": ""
4848
}
4949
],
@@ -63,12 +63,12 @@
6363
"machineEvents": {
6464
"MACHINE_STATUS": [
6565
{
66-
"category": "1",
66+
"category": "10001",
6767
"value": "evt(\"${deviceId}\",\"Availability\",\"status\",false) = \"Planned maintenance\""
6868
},
6969
{
70-
"category": "2",
71-
"value": "evt(\"${deviceId}\",\"Availability\",\"source\",false) = \"Manual stop\""
70+
"category": "10002",
71+
"value": "evt(\"${deviceId}\",\"Availability\",\"status\",false) = \"Manual stop\""
7272
}
7373
],
7474
"QUALITY_STATUS": []

0 commit comments

Comments
 (0)