Fix naming of get and set zoom
This commit is contained in:
3 files changed
+53
-31
No files matched your search
@@ -112,6 +112,9 @@ pub struct BcXml {
|
||||
/// The floodlight settings for automatically turning on/off on schedule/motion
|
||||
#[yaserde(rename = "FloodlightTask")]
|
||||
pub floodlight_task: Option<FloodlightTask>,
|
||||
/// For geting the zoom anf focus of the camera
|
||||
#[yaserde(rename = "PtzZoomFocus")]
|
||||
pub ptz_zoom_focus: Option<PtzZoomFocus>,
|
||||
/// For zooming the camera
|
||||
#[yaserde(rename = "StartZoomFocus")]
|
||||
pub start_zoom_focus: Option<StartZoomFocus>,
|
||||
@@ -975,6 +978,21 @@ pub struct AlarmDelay {
|
||||
pub def: Option<u32>,
|
||||
}
|
||||
|
||||
/// PtzZoomFocus xml
|
||||
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
|
||||
pub struct PtzZoomFocus {
|
||||
/// XML Version
|
||||
#[yaserde(attribute)]
|
||||
pub version: String,
|
||||
/// Channel ID
|
||||
#[yaserde(rename = "channelId")]
|
||||
pub channel_id: u8,
|
||||
/// Max, min and current zoom. (Read Only)
|
||||
pub zoom: HelperPosition,
|
||||
/// Max, min and current focus. (Read Only)
|
||||
pub focus: HelperPosition,
|
||||
}
|
||||
|
||||
/// StartZoomFocus xml
|
||||
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
|
||||
pub struct StartZoomFocus {
|
||||
@@ -985,14 +1003,10 @@ pub struct StartZoomFocus {
|
||||
#[yaserde(rename = "channelId")]
|
||||
pub channel_id: u8,
|
||||
/// Command: Observed values: zoomPos. (Write Only)
|
||||
pub command: Option<String>,
|
||||
pub command: String,
|
||||
/// Target Position: Observed Values: 2994, 2508, 2888, 3089, 3194, 3163. (Write Only)
|
||||
#[yaserde(rename = "movePos")]
|
||||
pub move_pos: Option<u32>,
|
||||
/// Max, min and current zoom. (Read Only)
|
||||
pub zoom: Option<HelperPosition>,
|
||||
/// Max, min and current focus. (Read Only)
|
||||
pub focus: Option<HelperPosition>,
|
||||
pub move_pos: u32,
|
||||
}
|
||||
|
||||
/// Helper for Max, Min, Curr pos of zoom/focus
|
||||
@@ -1000,13 +1014,13 @@ pub struct StartZoomFocus {
|
||||
pub struct HelperPosition {
|
||||
/// Max value
|
||||
#[yaserde(rename = "maxPos")]
|
||||
pub maxPos: u32,
|
||||
pub max_pos: u32,
|
||||
/// Min value
|
||||
#[yaserde(rename = "minPos")]
|
||||
pub minPos: u32,
|
||||
pub min_pos: u32,
|
||||
/// Curr value
|
||||
#[yaserde(rename = "curPos")]
|
||||
pub curPos: u32,
|
||||
pub cur_pos: u32,
|
||||
}
|
||||
|
||||
/// Support xml
|
||||
|
||||
@@ -238,14 +238,17 @@ impl BcCamera {
|
||||
|
||||
/// The camera will zoom to a given zoom amount.
|
||||
/// Not sure what the units for this are, seems to be 1000 is 1x and 2000 is 2x
|
||||
pub async fn zoom_to(&self, in_zoom_pos: u32) -> Result<()> {
|
||||
pub async fn zoom_to(&self, zoom_pos: u32) -> Result<()> {
|
||||
log::debug!("Setting to {}", zoom_pos);
|
||||
let current = self.get_zoom().await?;
|
||||
let zoom_pos;
|
||||
if let Some(zoom) = current.zoom {
|
||||
zoom_pos = in_zoom_pos.clamp(zoom.minPos, zoom.maxPos);
|
||||
} else {
|
||||
zoom_pos = in_zoom_pos;
|
||||
}
|
||||
log::debug!(
|
||||
" curr: {}, min: {}, max: {}",
|
||||
current.zoom.cur_pos,
|
||||
current.zoom.min_pos,
|
||||
current.zoom.max_pos
|
||||
);
|
||||
let zoom_pos = zoom_pos.clamp(current.zoom.min_pos, current.zoom.max_pos);
|
||||
log::debug!("Clamped to {}", zoom_pos);
|
||||
|
||||
self.has_ability_rw("control").await?;
|
||||
let connection = self.get_connection();
|
||||
@@ -270,9 +273,8 @@ impl BcCamera {
|
||||
start_zoom_focus: Some(StartZoomFocus {
|
||||
version: xml_ver(),
|
||||
channel_id: self.channel_id,
|
||||
command: Some("zoomPos".to_string()),
|
||||
move_pos: Some(zoom_pos),
|
||||
..Default::default()
|
||||
command: "zoomPos".to_string(),
|
||||
move_pos: zoom_pos,
|
||||
}),
|
||||
..Default::default()
|
||||
})),
|
||||
@@ -297,7 +299,7 @@ impl BcCamera {
|
||||
}
|
||||
|
||||
/// Get the zoom xml, that has current min and max zoom values
|
||||
pub async fn get_zoom(&self) -> Result<StartZoomFocus> {
|
||||
pub async fn get_zoom(&self) -> Result<PtzZoomFocus> {
|
||||
self.has_ability_ro("control").await?;
|
||||
let connection = self.get_connection();
|
||||
let msg_num = self.new_message_num();
|
||||
@@ -329,7 +331,7 @@ impl BcCamera {
|
||||
if let BcBody::ModernMsg(ModernMsg {
|
||||
payload:
|
||||
Some(BcPayloads::BcXml(BcXml {
|
||||
start_zoom_focus: Some(xml),
|
||||
ptz_zoom_focus: Some(xml),
|
||||
..
|
||||
})),
|
||||
..
|
||||
@@ -339,7 +341,7 @@ impl BcCamera {
|
||||
} else {
|
||||
Err(Error::UnintelligibleReply {
|
||||
reply: std::sync::Arc::new(Box::new(msg)),
|
||||
why: "Expected StartZoomFocus xml but it was not recieved",
|
||||
why: "Expected PtzZoomFocus xml but it was not recieved",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+15
-9
@@ -2968,7 +2968,7 @@ Message have zero to two payloads.
|
||||
</body>
|
||||
```
|
||||
|
||||
- 294: `<StartZoomFocus>` (Read)
|
||||
- 294: `<PtzZoomFocus>` (Read)
|
||||
|
||||
- Client: Standard header and channel extension
|
||||
|
||||
@@ -3173,12 +3173,18 @@ Message have zero to two payloads.
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
|
||||
- 295: `<StartZoomFocus>` (Write)
|
||||
|
||||
- Client
|
||||
|
||||
- Extension: Usual extension xml with channel
|
||||
|
||||
- Payload
|
||||
|
||||
```xml
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<body>
|
||||
<Net3g4gInfo version="1.1">
|
||||
<sigIntensityLevel>5</sigIntensityLevel>
|
||||
<sigIntensityValue>21</sigIntensityValue>
|
||||
<netMode>7</netMode>
|
||||
<mobileOperator>72403</mobileOperator>
|
||||
</Net3g4gInfo>
|
||||
</body>
|
||||
```
|
||||
<StartZoomFocus version="1.1">
|
||||
<channelId>1</ch
|
||||
Reference in new issue
Block a user