[−][src]Enum ichen_openprotocol::Message
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: ID
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.
Response
The Server should reply with a ControllersList
message.
Fields of RequestControllersList
controller_id: Option<ID>
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<ID, 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: ID
Unique ID of the controller.
display_name: Option<&'a str>
Human-friendly name for display (or None
if not relevant).
is_disconnected: 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<ID>>
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
to 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
or have values
equal to the matching fields in controller
.
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: ID
Unique ID of the controller.
data: HashMap<&'a str, f64>
A data dictionary containing a set of cycle data.
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.
Action Required
The user should send a JobCardsList
message to the Server as a reply.
Fields of RequestJobCardsList
controller_id: ID
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: ID
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.
Response
The Server should reply with a JoinResponse
message.
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 implemented is in the constant PROTOCOL_VERSION
.
password: &'a str
Password to log onto the server.
language: Language
Language encoding.
filter: Filters
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
RequestMoldData
The REQ_MOLD
message, sent to the server to request the set of mold settings data of a controller.
Response
The Server should reply with a MoldData
message.
Fields of RequestMoldData
controller_id: ID
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: ID
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.
Response
The Server should reply with a MoldData
message if field
is None
,
or a MoldDataValue
message.
Fields of ReadMoldData
controller_id: ID
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: ID
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.
Action Required
The user should send an OperatorInfo
message to the Server as a reply.
Fields of LoginOperator
controller_id: ID
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: ID
Unique ID of the controller.
operator_id: Option<ID>
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.
Valid values are from 0 to MAX_OPERATOR_LEVEL
(usually 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: EN
(English).
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
Return Err(
OpenProtocolError
)
if there is an error during parsing.
pub fn to_json_str(&self) -> Result<String>
[src]
Validate all the fields in the Message
, then serialize it into a JSON string.
Errors
Return Err(
OpenProtocolError
)
if there is an error.
Examples
let msg = Message::new_join_with_org("MyPassword", Filters::Status + Filters::Cycle, "MyCompany"); assert_eq!( r#"{"$type":"Join","orgId":"MyCompany","version":"4.0","password":"MyPassword","language":"EN","filter":"Status, Cycle","sequence":1}"#, msg.to_json_str().unwrap() );
pub fn new_alive() -> Self
[src]
Create an ALIVE
message.
pub fn new_join(password: &'a str, filter: Filters) -> Self
[src]
Create a JOIN
message with default language and protocol version.
The default language is DEFAULT_LANGUAGE
(usually EN
).
The default protocol version is given in PROTOCOL_VERSION
.
Examples
use ichen_openprotocol::*; let msg = Message::new_join("MyPassword", Filters::Status + Filters::Cycle); match msg { Message::Join { org_id: None, version: Message::PROTOCOL_VERSION, password: "MyPassword", language: Message::DEFAULT_LANGUAGE, filter, .. } if filter == Filters::Status + Filters::Cycle => (), _ => panic!() }
pub fn new_join_with_org(
password: &'a str,
filter: Filters,
org: &'a str
) -> Self
[src]
password: &'a str,
filter: Filters,
org: &'a str
) -> Self
Create a JOIN
message with non-default organization.
Examples
use ichen_openprotocol::*; let msg = Message::new_join_with_org("MyPassword", Filters::Status + Filters::Cycle, "MyCompany"); match msg { Message::Join { org_id: Some("MyCompany"), version: Message::PROTOCOL_VERSION, password: "MyPassword", language: Message::DEFAULT_LANGUAGE, filter, .. } if filter == Filters::Status + Filters::Cycle => (), _ => panic!() }
pub fn validate(&self) -> Result<'a, ()>
[src]
Validate the Message
data structure.
Errors
Returns Err(
OpenProtocolError
)
if some fields in the Message
are not valid.
Examples
let msg = Message::ControllerStatus { controller_id: ID::from_u32(12345), display_name: None, is_disconnected: None, op_mode: None, job_mode: None, job_card_id: Some(None), mold_id: Some(Some("Test-123".into())), // Value is "Test-123" operator_id: None, operator_name: None, variable: None, audit: None, alarm: None, controller: None, state: StateValues::new_with_all( OpMode::Automatic, JobMode::ID02, None, None, Some("Test-FooBar"), // Notice that this state value should be "Test-123" ), options: Default::default(), }; // Validation will fail because `state.mold_id` is not the same as the `mold_id` field. assert_eq!( r#"Err(InconsistentState("mold_id"))"#, format!("{:?}", msg.validate()) );
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]
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de: 'a, 'a> Deserialize<'de> for Message<'a>
[src]
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
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]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,