Skip to content

Commit

Permalink
feat: adds ptz speed adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
aknous committed Jun 15, 2023
1 parent 6b871ae commit 033ef22
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 7 deletions.
3 changes: 3 additions & 0 deletions QscQsysDspPlugin/QscDsp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,13 @@ public void CreateDspObjects()

value.PanLeftTag = FormatTag(prefix, value.PanLeftTag);
value.PanRightTag = FormatTag(prefix, value.PanRightTag);
value.PanSpeedTag = FormatTag(prefix, value.PanSpeedTag);
value.TiltUpTag = FormatTag(prefix, value.TiltUpTag);
value.TiltDownTag = FormatTag(prefix, value.TiltDownTag);
value.TiltSpeedTag = FormatTag(prefix, value.TiltSpeedTag);
value.ZoomInTag = FormatTag(prefix, value.ZoomInTag);
value.ZoomOutTag = FormatTag(prefix, value.ZoomOutTag);
value.ZoomSpeedTag = FormatTag(prefix, value.ZoomSpeedTag);
value.PresetBankTag = FormatTag(prefix, value.PresetBankTag);
value.Privacy = FormatTag(prefix, value.Privacy);
value.OnlineStatus = FormatTag(prefix, value.OnlineStatus);
Expand Down
33 changes: 33 additions & 0 deletions QscQsysDspPlugin/QscDspCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,28 @@ public void WritePresetName(string newLabel, ushort presetNumber)

}

public void SetPanSpeed(ushort speed)
{
var newSpeed = Scale(speed);
var cmdToSend = string.Format("csv \"{0}\" {1}", Config.PanSpeedTag, newSpeed);
_Dsp.SendLine(cmdToSend);
}

public void SetTiltSpeed(ushort speed)
{
var newSpeed = Scale(speed);
var cmdToSend = string.Format("csv \"{0}\" {1}", Config.TiltSpeedTag, newSpeed);
_Dsp.SendLine(cmdToSend);
}

public void SetZoomSpeed(ushort speed)
{
var newSpeed = Scale(speed);
var cmdToSend = string.Format("csv \"{0}\" {1}", Config.ZoomSpeedTag, newSpeed);
_Dsp.SendLine(cmdToSend);
}


/// <summary>
/// Adds the command to the change group
/// </summary>
Expand Down Expand Up @@ -189,6 +211,17 @@ public void ParseSubscriptionMessage(string customName, string value, string abs

}

double Scale(double input)
{
Debug.Console(1, this, "Scaling (double) input '{0}'", input);

var output = (input / 65535);

Debug.Console(1, this, "Scaled output '{0}'", output);

return output;
}


public BoolFeedback IsOnline { get; private set; }

Expand Down
64 changes: 62 additions & 2 deletions QscQsysDspPlugin/QscDspCameraBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public static void LinkToApiExt(this QscDspCamera camera, BasicTriList trilist,
}

// from SiMPL > to Plugin
trilist.SetUShortSigAction(joinMap.PanSpeed.JoinNumber, (a) => camera.SetPanSpeed(a));
trilist.SetUShortSigAction(joinMap.TiltSpeed.JoinNumber, (a) => camera.SetTiltSpeed(a));
trilist.SetUShortSigAction(joinMap.ZoomSpeed.JoinNumber, (a) => camera.SetZoomSpeed(a));
trilist.SetSigTrueAction(joinMap.PrivacyOn.JoinNumber, camera.PrivacyOn);
trilist.SetSigTrueAction(joinMap.PrivacyOff.JoinNumber, camera.PrivacyOff);

Expand All @@ -77,7 +80,10 @@ public class QscDspCameraDeviceJoinMap : JoinMapBase
public uint PresetStoreStart { get; set; }
public uint PresetNamesStart { get; set; }
public uint PrivacyOn { get; set; }
public uint PrivacyOff { get; set; }
public uint PrivacyOff { get; set; }
public uint PanSpeed { get; set; }
public uint TiltSpeed { get; set; }
public uint ZoomSpeed { get; set; }

public QscDspCameraDeviceJoinMap()
{
Expand All @@ -94,6 +100,9 @@ public QscDspCameraDeviceJoinMap()
PresetNamesStart = 2;
PrivacyOn = 48;
PrivacyOff = 49;
PanSpeed = 1;
TiltSpeed = 2;
ZoomSpeed = 3;
}

public override void OffsetJoinNumbers(uint joinStart)
Expand All @@ -110,7 +119,10 @@ public override void OffsetJoinNumbers(uint joinStart)
PresetStoreStart = PresetStoreStart + joinOffset;
PrivacyOn = PrivacyOn + joinOffset;
PrivacyOff = PrivacyOff + joinOffset;
Online = Online + joinOffset;
Online = Online + joinOffset;
PanSpeed = PanSpeed + joinOffset;
TiltSpeed = TiltSpeed + joinOffset;
ZoomSpeed = ZoomSpeed + joinOffset;
}
}

Expand Down Expand Up @@ -276,6 +288,54 @@ public class QscDspCameraDeviceJoinMapAdvanced : JoinMapBaseAdvanced
JoinType = eJoinType.Serial
});

[JoinName("PanSpeed")]
public JoinDataComplete PanSpeed = new JoinDataComplete(
new JoinData
{
JoinNumber = 1,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Camera pan speed",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Analog
});

/// <summary>
/// Camera tilt speed
/// </summary>
[JoinName("TiltSpeed")]
public JoinDataComplete TiltSpeed = new JoinDataComplete(
new JoinData
{
JoinNumber = 2,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Camera tilt speed",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Analog
});

/// <summary>
/// Camera zoom speed
/// </summary>
[JoinName("ZoomSpeed")]
public JoinDataComplete ZoomSpeed = new JoinDataComplete(
new JoinData
{
JoinNumber = 3,
JoinSpan = 1
},
new JoinMetadata
{
Description = "Camera zoom speed",
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
JoinType = eJoinType.Analog
});


public QscDspCameraDeviceJoinMapAdvanced(uint joinStart)
: base(joinStart, typeof(QscDspCameraDeviceJoinMapAdvanced))
Expand Down
22 changes: 17 additions & 5 deletions QscQsysDspPlugin/QscDspPropertiesConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,13 @@ public class QscDialerConfig
/// "camera-1": {
/// "panLeftTag": "CAM01_LEFT",
/// "panRightTag": "CAM01_RIGHT",
/// "panSpeedTag": "CAM01_PANSPEED",
/// "tiltUpTag": "CAM01_UP",
/// "tiltDownTag": "CAM01_DOWN",
/// "tiltDownTag": "CAM01_DOWN",
/// "tiltSpeedTag": "CAM01_TILTSPEED",
/// "zoomInTag": "CAM01_ZOOMIN",
/// "zoomOutTag": "CAM01_ZOOMOUT",
/// "zoomOutTag": "CAM01_ZOOMOUT",
/// "zoomSpeedTag": "CAM01_ZOOMSPEED",
/// "privacy": "CAM01_PRIVACY",
/// "onlineStatus": "CAM01_STATUS",
/// "presets": {
Expand Down Expand Up @@ -319,19 +322,28 @@ public class QscDspCameraConfig
public string PanLeftTag { get; set; }

[JsonProperty("panRightTag")]
public string PanRightTag { get; set; }
public string PanRightTag { get; set; }

[JsonProperty("panSpeedTag")]
public string PanSpeedTag { get; set; }

[JsonProperty("tiltUpTag")]
public string TiltUpTag { get; set; }

[JsonProperty("tiltDownTag")]
public string TiltDownTag { get; set; }
public string TiltDownTag { get; set; }

[JsonProperty("tiltSpeedTag")]
public string TiltSpeedTag { get; set; }

[JsonProperty("zoomInTag")]
public string ZoomInTag { get; set; }

[JsonProperty("zoomOutTag")]
public string ZoomOutTag { get; set; }
public string ZoomOutTag { get; set; }

[JsonProperty("zoomSpeedTag")]
public string ZoomSpeedTag { get; set; }

[JsonProperty("presetBankTag")]
public string PresetBankTag { get; set; }
Expand Down

0 comments on commit 033ef22

Please sign in to comment.