Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

faeture: add the ability to set the pacing time via config #44

Merged
merged 2 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion PanasonicCameraEpi/HttpCommandQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ namespace PanasonicCameraEpi
public class HttpCommandQueue : CommandQueue
{
public event EventHandler<GenericHttpClientEventArgs> ResponseReceived;
private int _pacing = 130;

public HttpCommandQueue(IBasicCommunication coms)
: base(coms)
{

}
public HttpCommandQueue(IBasicCommunication coms, int pacing)
: base(coms)
{
_pacing = pacing;
}

protected override object ProcessQueue(object obj)
{
Expand Down Expand Up @@ -48,7 +54,7 @@ protected override object ProcessQueue(object obj)
Debug.Console(1, client, "Dispatching request: {0}", request.Url.PathAndParams);

client.Client.DispatchAsync(request, OnResponseReceived);
Thread.Sleep(130); //command gap of 130 recommended by documentation
Thread.Sleep(_pacing); //command gap of 130 recommended by documentation
}
catch (Exception ex)
{
Expand Down
10 changes: 9 additions & 1 deletion PanasonicCameraEpi/PanasonicCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,15 @@ public PanasonicCamera(IBasicCommunication comms, DeviceConfig config)
throw new NotImplementedException("Need to create a command queue for serial");
}
_monitor = new PanasonicHttpCameraMonitor(this, tempClient, cameraConfig.CommunicationMonitor);
var queue = new HttpCommandQueue(comms);
HttpCommandQueue queue;
if (cameraConfig.Pacing > 0)
{
queue = new HttpCommandQueue(comms, cameraConfig.Pacing);
}
else
{
queue = new HttpCommandQueue(comms);
}
queue.ResponseReceived += _responseHandler.HandleResponseReceived;
_queue = queue;

Expand Down
3 changes: 3 additions & 0 deletions PanasonicCameraEpi/PanasonicCameraPropsConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public PanasonicCameraPropsConfig()
public int TiltSpeed { get; set; }
public string HomeCommand { get; set; }
public string PrivacyCommand { get; set; }

public int Pacing { get; set; }

}

public class PanasonicControlPropertiesConfig
Expand Down