[][src]Enum ichen_openprotocol::Message

pub enum Message<'a> {
    Alive {
        options: MessageOptions<'a>,
    },
    ControllerAction {
        controller_id: NonZeroU32,
        action_id: i32,
        timestamp: DateTime<FixedOffset>,
        options: MessageOptions<'a>,
    },
    RequestControllersList {
        controller_id: Option<NonZeroU32>,
        options: MessageOptions<'a>,
    },
    ControllersList {
        data: HashMap<&'a str, Controller<'a>>,
        options: MessageOptions<'a>,
    },
    ControllerStatus {
        controller_id: NonZeroU32,
        display_name: Option<&'a str>,
        is_connected: Option<bool>,
        op_mode: Option<OpMode>,
        job_mode: Option<JobMode>,
        alarm: Option<KeyValuePair<&'a str, bool>>,
        audit: Option<KeyValuePair<&'a str, f64>>,
        variable: Option<KeyValuePair<&'a str, f64>>,
        operator_id: Option<Option<NonZeroU32>>,
        operator_name: Option<Option<&'a str>>,
        job_card_id: Option<Option<Cow<'a, str>>>,
        mold_id: Option<Option<Cow<'a, str>>>,
        state: StateValues<'a>,
        controller: Option<Box<Controller<'a>>>,
        options: MessageOptions<'a>,
    },
    CycleData {
        controller_id: NonZeroU32,
        data: HashMap<&'a str, f64>,
        timestamp: DateTime<FixedOffset>,
        state: StateValues<'a>,
        options: MessageOptions<'a>,
    },
    RequestJobCardsList {
        controller_id: NonZeroU32,
        options: MessageOptions<'a>,
    },
    JobCardsList {
        controller_id: NonZeroU32,
        data: HashMap<&'a str, JobCard<'a>>,
        options: MessageOptions<'a>,
    },
    Join {
        org_id: Option<&'a str>,
        version: &'a str,
        password: &'a str,
        language: Language,
        filter: Cow<'a, [Filter]>,
        options: MessageOptions<'a>,
    },
    JoinResponse {
        result: u32,
        level: Option<u32>,
        message: Option<Cow<'a, str>>,
        options: MessageOptions<'a>,
    },
    RequestMoldData {
        controller_id: NonZeroU32,
        options: MessageOptions<'a>,
    },
    MoldData {
        controller_id: NonZeroU32,
        data: HashMap<&'a str, f64>,
        timestamp: DateTime<FixedOffset>,
        state: StateValues<'a>,
        options: MessageOptions<'a>,
    },
    ReadMoldData {
        controller_id: NonZeroU32,
        field: Option<&'a str>,
        options: MessageOptions<'a>,
    },
    MoldDataValue {
        controller_id: NonZeroU32,
        field: &'a str,
        value: f64,
        options: MessageOptions<'a>,
    },
    LoginOperator {
        controller_id: NonZeroU32,
        password: &'a str,
        options: MessageOptions<'a>,
    },
    OperatorInfo {
        controller_id: NonZeroU32,
        operator_id: Option<NonZeroU32>,
        name: &'a str,
        password: &'a str,
        level: u8,
        options: MessageOptions<'a>,
    },
}

All Open Protocol message types.

See this document for details.

Variants

Alive

The ALIVE message, sent periodically as the keep-alive mechanism.

Fields of Alive

options: MessageOptions<'a>

Message configuration options.

ControllerAction

The CNTRLER_ACTION message, sent by the server whenever the current action of a controller changes.

Fields of ControllerAction

controller_id: NonZeroU32

Unique ID of the controller.

action_id: i32

Unique action code.

See this document for details.

timestamp: DateTime<FixedOffset>

Time-stamp of the event.

options: MessageOptions<'a>

Message configuration options.

RequestControllersList

The REQ_CNTRLER_LIST message, sent to the server to request a list of controllers (i.e. machines) within the user's organization.

Fields of RequestControllersList

controller_id: Option<NonZeroU32>

Unique ID of the controller to request.

If omitted, all controllers of the user's organization will be returned.

options: MessageOptions<'a>

Message configuration options.

ControllersList

The RESP_CNTRLER_LIST message, sent by the server in response to a RequestControllersList message.

Fields of ControllersList

data: HashMap<&'a str, Controller<'a>>

List of controllers requested by a previous RequestControllersList message.

Each controller data structure contains the last-known values of the controller's state.

options: MessageOptions<'a>

Message configuration options.

ControllerStatus

The UPD_CNTRLER message, sent by the server whenever the status of a connected controller changes.

Only the changed fields will be set, with other fields/properties being set to None as they are not relevant.

Fields of ControllerStatus

controller_id: NonZeroU32

Unique ID of the controller.

display_name: Option<&'a str>

Human-friendly name for display (or None if not relevant).

is_connected: Option<bool>

If true, the controller has disconnected from the iChen® Server.

op_mode: Option<OpMode>

Current operation mode of the controller (or None if not relevant).

job_mode: Option<JobMode>

Current job mode of the controller (or None if not relevant).

alarm: Option<KeyValuePair<&'a str, bool>>

State of an alarm (if any) on the controller (or None if not relevant).

See this document for valid alarm codes.

audit: Option<KeyValuePair<&'a str, f64>>

Change of a setting (if any) on the controller for audit trail purpose (or None if not relevant).

variable: Option<KeyValuePair<&'a str, f64>>

Change of a variable (if any) on the controller (or None if not relevant).

operator_id: Option<Option<NonZeroU32>>

Unique ID of the current logged-on user, Some(None) if a user has logged out (or None if not relevant).

operator_name: Option<Option<&'a str>>

Name of the current logged-on user, Some(None) if the current user has no name (or None if not relevant).

job_card_id: Option<Option<Cow<'a, str>>>

Unique ID of the current job card loaded, Some(None) if no job card is currently loaded (or None if not relevant).

mold_id: Option<Option<Cow<'a, str>>>

Unique ID of the current mold data set loaded, Some(None) if no mold data set is currently loaded (or None if not relevant).

state: StateValues<'a>

Snapshot of the current known states of the controller.

controller: Option<Box<Controller<'a>>>

A Controller data structure containing the last-known state of the controller.

This field is only sent once by the server as soon as a new controller has connected into the network. All subsequent messages have this field set to None.

If this field is not None, then all other info fields should be None.

options: MessageOptions<'a>

Message configuration options.

CycleData

The CYCLE_DATA message, sent by the server at the end of each machine cycle.

Fields of CycleData

controller_id: NonZeroU32

Unique ID of the controller.

data: HashMap<&'a str, f64>

A data dictionary containing a set of cycle data.Alive

See this document for examples.

timestamp: DateTime<FixedOffset>

Time-stamp of the event.

state: StateValues<'a>

Snapshot of the current known states of the controller.

options: MessageOptions<'a>

Message configuration options.

RequestJobCardsList

The REQ_JOBCARDS_LIST message, sent by the server when a connected controller requests a list of job cards.

Fields of RequestJobCardsList

controller_id: NonZeroU32

Unique ID of the controller.

options: MessageOptions<'a>

Message configuration options.

JobCardsList

The RESP_JOBSLIST message, sent to the server in response to a RequestJobCardsList message.

Fields of JobCardsList

controller_id: NonZeroU32

Unique ID of the controller.

data: HashMap<&'a str, JobCard<'a>>

A data dictionary containing a set of JobCard data structures.

options: MessageOptions<'a>

Message configuration options.

Join

The JOIN message, sent to log onto the server.

Fields of Join

org_id: Option<&'a str>

Organization ID (if any).

version: &'a str

The maximum protocol version supported, in the format x.x.x.x.

The current protocol version implemnted is in the constant PROTOCOL_VERSION.

password: &'a str

Password to log onto the server.

language: Language

Language encoding.

filter: Cow<'a, [Filter]>

A collection of Filter values containing what type(s) of messages to receive.

options: MessageOptions<'a>

Message configuration options.

JoinResponse

The RESP_JOIN message, sent by the Server in response to a Join message.

Fields of JoinResponse

result: u32

Result code, >= 100 indicates success.

level: Option<u32>

The allowed access level for this client.

message: Option<Cow<'a, str>>

A message (mostly likely an error message in case of failure), if any.

options: MessageOptions<'a>

Message configuration options.

RequestMoldData

The REQ_MOLD message, sent to the server to request the set of mold settings data of a controller.

Fields of RequestMoldData

controller_id: NonZeroU32

Unique ID of the controller.

options: MessageOptions<'a>

Message configuration options.

MoldData

The RESP_MOLD message, sent by the server in response to a RequestMoldData message or a ReadMoldData message with field set to None (meaning read all).

Fields of MoldData

controller_id: NonZeroU32

Unique ID of the controller.

data: HashMap<&'a str, f64>

A data dictionary containing a set of mold settings.

timestamp: DateTime<FixedOffset>

Time-stamp of the event.

state: StateValues<'a>

Snapshot of the current known states of the controller.

options: MessageOptions<'a>

Message configuration options.

ReadMoldData

The READ_MOLD_DATA message, sent to the server to read the current value of a particular mold setting.

The server keeps a cache of the states of all mold settings for each controller. The value returned is based on the server cache. No command is sent to controller to poll the latest value.

Fields of ReadMoldData

controller_id: NonZeroU32

Unique ID of the controller.

field: Option<&'a str>

Name of the mold setting to read, None for all.

options: MessageOptions<'a>

Message configuration options.

MoldDataValue

The RESP_MOLD_DATA_VALUE message, sent by the server in response to a ReadMoldData message.

Fields of MoldDataValue

controller_id: NonZeroU32

Unique ID of the controller.

field: &'a str

Name of the mold setting to read.

value: f64

Current cached value of the mold setting.

options: MessageOptions<'a>

Message configuration options.

LoginOperator

The REQ_PWD_LEVEL message, sent by server when a connected controller attempts to authenticate and authorize a user password.

Fields of LoginOperator

controller_id: NonZeroU32

Unique ID of the controller.

password: &'a str

User password.

options: MessageOptions<'a>

Message configuration options.

OperatorInfo

The RESP_PWD_LEVEL message, sent to the server in response to a LoginOperator message.

Fields of OperatorInfo

controller_id: NonZeroU32

Unique ID of the controller.

operator_id: Option<NonZeroU32>

Unique ID of the authenticated user.

name: &'a str

Name of the user.

password: &'a str

User password.

level: u8

Allowed access level for the user (0-10).

options: MessageOptions<'a>

Message configuration options.

Methods

impl<'a> Message<'a>[src]

pub const PROTOCOL_VERSION: &'static str[src]

Current protocol version: 4.0.

pub const DEFAULT_LANGUAGE: Language[src]

Default language to use: Language::EN.

pub const MAX_OPERATOR_LEVEL: u8[src]

Maximum operator level: 10.

pub fn parse_from_json_str(json: &'a str) -> Result<'a, Self>[src]

Parse a JSON string into a Message.

Errors

Returns [Err(OpenProtocolError)] if there is an error, which may be one of the following:

  • JsonError: Error during parsing, which may be due to malformed JSON text, missing fields, wrong data types for fields etc.
  • EmptyField: A mandatory String field is empty (i.e. zero-length) or all white-spaces.
  • InvalidField: The value of a field is inappropriate for that field, although there is no syntax error. For example, encountering NaN on a numeric field usually yields this error.
  • ConstraintViolated: An integrity constraint is violated by the data structure. For example, if current progress (progress) field of a JobCard structure is larger than its total production count (total) field.

pub fn to_json_str(&self) -> Result<String>[src]

Validate all the fields in the Message, then serialize it into a JSON string.

Errors

Returns [Err(OpenProtocolError)] if there is an error, which may be one of the following:

  • JsonError: Error during parsing, which may be due to malformed JSON text, missing fields, wrong data types for fields etc.
  • EmptyField: A mandatory String field is empty (i.e. zero-length) or all white-spaces.
  • InvalidField: The value of a field is inappropriate for that field, although there is no syntax error. For example, encountering NaN on a numeric field usually yields this error.
  • ConstraintViolated: An integrity constraint is violated by the data structure. For example, if current progress (progress) field of a JobCard structure is larger than its total production count (total) field.

pub fn new_alive() -> Self[src]

Create an ALIVE message.

pub fn new_join(password: &'a str, filter: &'a [Filter]) -> Self[src]

Create a JOIN message with default language and protocol version.

pub fn new_join_with_org(
    password: &'a str,
    filter: &'a [Filter],
    org: Option<&'a str>
) -> Self
[src]

Create a JOIN message with non-default organization.

pub fn validate(&self) -> Result<'a, ()>[src]

Validate the data structure.

Trait Implementations

impl<'a> PartialEq<Message<'a>> for Message<'a>[src]

impl<'a> Debug for Message<'a>[src]

impl<'a> Serialize for Message<'a>[src]

impl<'de: 'a, 'a> Deserialize<'de> for Message<'a>[src]

Auto Trait Implementations

impl<'a> Sync for Message<'a>

impl<'a> Send for Message<'a>

impl<'a> Unpin for Message<'a>

impl<'a> RefUnwindSafe for Message<'a>

impl<'a> UnwindSafe for Message<'a>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]