Struct Message

Source
pub struct Message(/* private fields */);
Expand description

Single command message object type.

There are several way to build a message:

  • The main constructor Message::new() for “standard” messages.

  • Use the builder pattern with MessageBuilder.

  • Many convenient constructors are provided for “extended” commands.

  • Message::from_bytes() allows to manually specify the address and data words bytes, and will automatically fill the sync byte and checksum.

  • Full control of all the bytes values is possible with the trait implementaion From<[u8;7]>.

The bytes of a Message can be accessed with Message::as_ref().

Message objects can also be sent to the target device with PelcoDPort::send_message().

Implementations§

Source§

impl Message

Source

pub fn new( address: u8, cmd1: Command1, cmd2: Command2, data1: u8, data2: u8, ) -> Message

New “standard” command message. This constructor cannot be used for “extended” commands, for which dedicated constructors or Message::from_bytes() should be used.

Example:

let msg = Message::new(
    10,
    Command1::SENSE | Command1::CAMERA_ON_OFF,
    Command2::FOCUS_FAR | Command2::DOWN,
    0x00,
    0x40,
);
assert_eq!(&[0xFF, 0x0A, 0x88, 0x90, 0x00, 0x40, 0x62], msg.as_ref());
Source

pub fn from_bytes(address: u8, words: [u8; 4]) -> Message

Alternate constructor taking the raw words to insert in the message. The sync byte and checksum automatically inserted.

Source

pub fn set_preset(address: u8, preset_id: u8) -> Result<Message>

Set Preset. An error is returned if preset_id is 0, but special values (like “flip 180”) are not checked.

Source

pub fn clear_preset(address: u8, preset_id: u8) -> Result<Message>

Clear Preet. An error is returned if preset_id is 0.

Source

pub fn go_to_preset(address: u8, preset_id: u8) -> Result<Message>

Call Preet. An error is returned if preset_id is 0.

Source

pub fn flip_180(address: u8) -> Result<Message>

Call the special preset “rotate 180 degrees”.

Source

pub fn go_to_zero_pan(address: u8) -> Result<Message>

Call the special preset “Go To Zero Pan”.

Source

pub fn set_auxiliary(address: u8, sub_opcode: u8, aux_id: u8) -> Result<Message>

Set Auxiliary. No particular check is done on the arguments.

Source

pub fn clear_auxiliary( address: u8, sub_opcode: u8, aux_id: u8, ) -> Result<Message>

Clear Auxiliary. No particular check is done on the arguments.

Source

pub fn remote_reset(address: u8) -> Result<Message>

Reset.

Source

pub fn set_zone_start(address: u8, zone_id: u8) -> Result<Message>

Set Zone Start.

Source

pub fn set_zone_end(address: u8, zone_id: u8) -> Result<Message>

Set Zone End.

Source

pub fn write_char_to_screen( address: u8, column: u8, character: char, ) -> Result<Message>

Write Character To Screen.

Source

pub fn clear_screen(address: u8) -> Result<Message>

Clear Screen.

Source

pub fn alarm_acknowledge(address: u8, alarm_no: u8) -> Result<Message>

Alarm Acknowledge.

Source

pub fn zone_scan_on(address: u8) -> Result<Message>

Zone Scan On.

Source

pub fn zone_scan_off(address: u8) -> Result<Message>

Zone Scan Off.

Source

pub fn set_pattern_start(address: u8, pattern_id: u8) -> Result<Message>

Record Pattern Start.

Source

pub fn set_pattern_stop(address: u8, pattern_id: u8) -> Result<Message>

Record Pattern End.

Source

pub fn run_pattern(address: u8, pattern_id: u8) -> Result<Message>

Run Pattern.

Source

pub fn set_zoom_speed(address: u8, speed: ZoomSpeed) -> Result<Message>

Set Zoom Speed.

Source

pub fn set_focus_speed(address: u8, speed: FocusSpeed) -> Result<Message>

Set Focus Speed.

Source

pub fn reset_camera_to_defaults(address: u8) -> Result<Message>

Reset Camera to Defaults.

Source

pub fn auto_focus(address: u8, ctrl: AutoCtrl) -> Result<Message>

Auto Focus.

Source

pub fn auto_iris(address: u8, cmd: AutoCtrl) -> Result<Message>

Auto Iris.

Source

pub fn agc(address: u8, cmd: AutoCtrl) -> Result<Message>

AGC.

Source

pub fn backlight_compensation(address: u8, ctrl: OnOff) -> Result<Message>

Backlight Compensation.

Source

pub fn auto_white_balance(address: u8, ctrl: OnOff) -> Result<Message>

Auto White Balance.

Source

pub fn enable_device_phase_delay_mode(address: u8) -> Result<Message>

Enable Device Phase Delay Mode.

Source

pub fn set_shutter_speed(address: u8, ctrl: ShutterSpeed) -> Result<Message>

Set Shutter Speed.

Source

pub fn adjust_line_lock_phase_delay( address: u8, ctrl: AdjustmentValue, ) -> Result<Message>

Adjust Line Lock Phase Delay.

Source

pub fn adjust_white_balance_rb( address: u8, ctrl: AdjustmentValue, ) -> Result<Message>

Adjust White Balance (R-B)

Source

pub fn adjust_white_balance_mg( address: u8, ctrl: AdjustmentValue, ) -> Result<Message>

Adjust White Balance (M-G)

Source

pub fn adjust_gain(address: u8, ctrl: AdjustmentValue) -> Result<Message>

Adjust Gain.

Source

pub fn adjust_auto_iris_level( address: u8, ctrl: AdjustmentValue, ) -> Result<Message>

Adjust Auto-Iris Level

Source

pub fn adjust_auto_iris_peak( address: u8, ctrl: AdjustmentValue, ) -> Result<Message>

Adjust Auto-Iris Peak Value.

Source

pub fn query() -> Result<Message>

Query.

Trait Implementations§

Source§

impl AsRef<[u8]> for Message

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Message

Source§

fn clone(&self) -> Message

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<[u8; 7]> for Message

Source§

fn from(array: [u8; 7]) -> Self

Create a Message by specifying all the bytes manually:

let msg = Message::from([11, 22, 33, 44, 55, 66, 77]);
assert_eq!(&[11, 22, 33, 44, 55, 66, 77], msg.as_ref());
Source§

impl From<MessageBuilder> for Message

Source§

fn from(draft: MessageBuilder) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Message

Source§

fn eq(&self, other: &Message) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryFrom<&[u8]> for Message

Source§

type Error = &'static str

The type returned in the event of a conversion error.
Source§

fn try_from(value: &[u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for Message

Source§

impl StructuralPartialEq for Message

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.