Skip to content

Commit

Permalink
Add Extended IO manager
Browse files Browse the repository at this point in the history
Provide service to manage the extended IO (mainly PLC1200 signal modules). Including:

- Config the modules, or retrieve the configuration
- Sync system time to extended IO controller
- Update the firmware of the controller and some modules - currently
  only controller firmware updating is supported.
- Read extended IO events

The extended IO controller is an ASIC, whose job is to forward the
configuration to signal modules and collect events from modules. The
firmware of the controller provides the IO read/write functionalities
through a FUSE filesystem /eio. The iot2050-eiod.service is managing
this FUSE file system.

This manager is exposing service to localhost via gRPC, the
iot2050-eiosd.service is managing this gRPC server.

To sync the system time to eio controller, the
iot2050-eio-time-syncing.service is doing the job.

iot2050-eio-fwu-monitor.service is used to monitor the current firmware
version of the eio controller, and raise alarm to console when the
firmware does not match. This is useful when the host application is
upgraded but the eio controller firmware is not updated accordingly, for
example, when trying another example image via a SDCard/USB stick.

To consume the service provided by this manager, an iot2050-eio cli is
provided to config/retrieve/update-firmware from the console. This cli
is purely a gRPC client to call the RPC procedure provided by the
iot2050-eiosd.service.

It's also possible to consume the service from WEB applications, we will
provide a demo web application for configing/retrieving the
signal modules.

The module configuration is written in YAML, which will be validated via
JSON schemas internally.

For this YAML file, please check the
config-template/sm-config-example.yaml for details. Please note the
`description` for each slot, currently when retrieving the
configuration, the description should be a multiline text, however, it's
not so easy to generate multile line text for yaml. This part is still
WIP.

The YAML configuration is internally converted to the binary format which the
extended IO controller accepts. We may use some binary schema tools such
as Kaitai Struct to rewrite this part of logic in the future.

Co-developed-by: Li Hua Qian <[email protected]>
Signed-off-by: Li Hua Qian <[email protected]>
Signed-off-by: Baocheng Su <[email protected]>
  • Loading branch information
BaochengSu committed Dec 2, 2023
1 parent aae9157 commit 9ae0f67
Show file tree
Hide file tree
Showing 37 changed files with 4,640 additions and 0 deletions.
24 changes: 24 additions & 0 deletions recipes-app/iot2050-eio-manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# IOT2050 Extended IO Subsystem

The IOT2050 Extended IO (EIO) subsystem is for managing the extended
IOs, currently the PLC1200 signal modules.

This subsystem is only valid on IOT2050-SM variant at the moment.

The core is a RPC service implemented with the help of gPRC.

In addition:
- A FUSE service for loading the ext-io file system.
- A time syncing service for sync the system time to extended IO
controller.
- A cli tool for communicating with the gRPC server:
- Deploy/Retrieve extended IO configurations
- Update firmware for the extended IO controller or modules.
- A firmware updating monitoring service for notify updating while
firmware does not match.

## Regenerate the gRPC python modules if proto file changes:

```shell
python3 -m grpc_tools.protoc -I. --python_out=. --pyi_out=. --grpc_python_out=. gRPC/EIOManager/iot2050-eio.proto
```
4 changes: 4 additions & 0 deletions recipes-app/iot2050-eio-manager/files/bin/firmware-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": "L00.00.00.12-0-ged53b19",
"sha1sum":"93dc2baadd6e74ffc5e74332625881ae6974879c"
}
Binary file not shown.
Binary file not shown.
20 changes: 20 additions & 0 deletions recipes-app/iot2050-eio-manager/files/config-schema/schema-na.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) Siemens AG, 2023
#
# Authors:
# Su Bao Cheng <[email protected]>
#
# SPDX-License-Identifier: MIT
$schema: 'https://json-schema.org/draft/2020-12/schema'
$id: 'https://iot2050-sm/sm-na'

type: object
properties:
description:
type: string
mlfb:
const: "NA"

required:
- mlfb

unevaluatedProperties: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Copyright (c) Siemens AG, 2023
#
# Authors:
# Su Bao Cheng <[email protected]>
#
# SPDX-License-Identifier: MIT
$schema: 'https://json-schema.org/draft/2020-12/schema'
$id: 'https://iot2050-sm/sm-config'

type: object
properties:
slot1:
$ref: "#/$defs/slot"
slot2:
$ref: "#/$defs/slot"
slot3:
$ref: "#/$defs/slot"
slot4:
$ref: "#/$defs/slot"
slot5:
$ref: "#/$defs/slot"
slot6:
$ref: "#/$defs/slot"

required:
- slot1
- slot2
- slot3
- slot4
- slot5
- slot6

$defs:
slot:
type: object
properties:
mlfb:
enum:
- 6ES7647-0CM00-1AA2
- 6ES7223-1QH32-0XB0
- 6ES7231-4HF32-0XB0
- 6ES7231-5PD32-0XB0
- 6ES7231-5PF32-0XB0
- 6ES7238-5XA32-0XB0
- NA

allOf:

- if:
properties:
mlfb:
const: 6ES7647-0CM00-1AA2
then:
$ref: https://iot2050-sm/sm-sens-di

- if:
properties:
mlfb:
const: 6ES7223-1QH32-0XB0
then:
$ref: https://iot2050-sm/sm1223-ac-rly

- if:
properties:
mlfb:
const: 6ES7231-4HF32-0XB0
then:
$ref: https://iot2050-sm/sm1231-ai

- if:
properties:
mlfb:
enum:
- 6ES7231-5PD32-0XB0
- 6ES7231-5PF32-0XB0
then:
$ref: https://iot2050-sm/sm1231-rtd

- if:
properties:
mlfb:
const: 6ES7238-5XA32-0XB0
then:
$ref: https://iot2050-sm/sm1238-em-480vac

- if:
properties:
mlfb:
const: NA
then:
$ref: https://iot2050-sm/sm-na

unevaluatedProperties: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) Siemens AG, 2023
#
# Authors:
# Su Bao Cheng <[email protected]>
#
# SPDX-License-Identifier: MIT
$schema: 'https://json-schema.org/draft/2020-12/schema'
$id: 'https://iot2050-sm/sm-sens-di'

type: object
properties:
description:
type: string
mlfb:
const: "6ES7647-0CM00-1AA2"

required:
- mlfb

unevaluatedProperties: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright (c) Siemens AG, 2023
#
# Authors:
# Su Bao Cheng <[email protected]>
#
# SPDX-License-Identifier: MIT
$schema: 'https://json-schema.org/draft/2020-12/schema'
$id: 'https://iot2050-sm/sm1223-ac-rly'

type: object
properties:
description:
type: string
mlfb:
const: "6ES7223-1QH32-0XB0"
di:
type: object
properties:
ch0_3_delay_time:
enum: [2, 3, 4, 5, 6, 7, 9]
ch4_7_delay_time:
enum: [2, 3, 4, 5, 6, 7, 9]
required:
- ch0_3_delay_time
- ch4_7_delay_time
unevaluatedProperties: false
dq:
type: object
properties:
behavior_with_OD:
enum: [2, 3]
ch0:
$ref: "#/$defs/channel"
ch1:
$ref: "#/$defs/channel"
ch2:
$ref: "#/$defs/channel"
ch3:
$ref: "#/$defs/channel"
ch4:
$ref: "#/$defs/channel"
ch5:
$ref: "#/$defs/channel"
ch6:
$ref: "#/$defs/channel"
ch7:
$ref: "#/$defs/channel"

if:
properties:
behavior_with_OD:
const: 3
then:
required: [ch0, ch1, ch2, ch3, ch4, ch5, ch6, ch7]

required:
- behavior_with_OD
unevaluatedProperties: false

required:
- mlfb
- di
- dq

$defs:
channel:
type: object
properties:
substitute:
enum: [0, 1]
required:
- substitute

unevaluatedProperties: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Copyright (c) Siemens AG, 2023
#
# Authors:
# Su Bao Cheng <[email protected]>
#
# SPDX-License-Identifier: MIT
$schema: 'https://json-schema.org/draft/2020-12/schema'
$id: 'https://iot2050-sm/sm1231-ai'

type: object
properties:
description:
type: string
mlfb:
const: "6ES7231-4HF32-0XB0"
power_alarm:
type: boolean
integ_time:
enum: [0, 1, 2, 3]
ch0:
$ref: "#/$defs/channel"
ch1:
$ref: "#/$defs/channel"
ch2:
$ref: "#/$defs/channel"
ch3:
$ref: "#/$defs/channel"
ch4:
$ref: "#/$defs/channel"
ch5:
$ref: "#/$defs/channel"
ch6:
$ref: "#/$defs/channel"
ch7:
$ref: "#/$defs/channel"

required: [mlfb, power_alarm, integ_time, ch0, ch1, ch2, ch3, ch4, ch5, ch6, ch7]

$defs:
channel:
type: object
properties:
type:
enum: [1, 3]
smooth:
enum: [0, 1, 2, 3]
open_wire_alarm:
type: boolean
overflow_alarm:
type: boolean
underflow_alarm:
type: boolean

if:
properties:
type:
const: 1
then:
properties:
range:
enum: [7, 8, 9]
else:
properties:
range:
enum: [2, 3]

required:
- type
- range
- smooth
- open_wire_alarm
- overflow_alarm
- underflow_alarm
unevaluatedProperties: false

unevaluatedProperties: false
Loading

0 comments on commit 9ae0f67

Please sign in to comment.