1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#[macro_use]
extern crate serde_derive;

extern crate ommui_string_patterns;
extern crate xio_base_datatypes;

use ommui_string_patterns::freetextstring;
use xio_base_datatypes as base;

use std::collections::BTreeMap;

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
/// A complete job set.
pub struct JobSet {
    pub parameters: Vec<ParameterSet>,
    pub jobs: BTreeMap<String, Job>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct ParameterSet {
    pub name: String,
    pub descriptions: BTreeMap<String, ParameterDescription>,
    pub values: BTreeMap<String, base::ParameterValue>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct ParameterDescription {
    #[serde(rename = "_caption")]
    pub caption: String,
    #[serde(rename = "type")]
    pub data_type: base::DataType,
    pub storage: base::StorageType,
    #[serde(rename = "override")]
    pub override_option: base::OverrideOption,
}

#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Job {
    pub commands: Vec<Command>,
}

#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Command {
    #[serde(rename = "_caption", with = "freetextstring")]
    pub caption: String,

    #[serde(rename = "type")]
    pub command_type: String,

    // TODO: verify that the key is an idstring
    #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
    pub parameters: BTreeMap<String, String>,

    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    pub conditions: Vec<Condition>,
}

#[derive(Clone, Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct Condition {
    #[serde(rename = "_caption", with = "freetextstring")]
    pub caption: String,

    #[serde(rename = "type")]
    pub command_type: String,

    pub exit_job: bool,

    // TODO: verify that the key is an idstring
    #[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
    pub parameters: BTreeMap<String, String>,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct ChannelAssignment {
    pub capability: String,
    pub channel: String,
}

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
/// The assignment of variables mapped to a hardware board
pub struct HardwareAssignment {
    pub hardware_board: String,
    pub mapping: BTreeMap<String, ChannelAssignment>,
}