Camera.HRLiveStreamOp operation added, RoiDetectionOp moved to RoI component, etc.
This commit is contained in:
parent
7c1d0be9c9
commit
e730ee1541
@ -56,8 +56,8 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
string image;
|
||||
|
||||
|
||||
Telnet.TelnetClient telnet;
|
||||
TerminalDlg terminalDlg;
|
||||
public Telnet.TelnetClient Telnet;
|
||||
private TerminalDlg terminalDlg;
|
||||
|
||||
|
||||
public Camera() {}
|
||||
@ -69,7 +69,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
netAdapter = TbfComponents.FindComponent(cfg.ParentName, components) as GenericDevices.INetworkAdapter;
|
||||
if (netAdapter == null) throw new ArgumentNullException("no network adapter");
|
||||
|
||||
telnet = null;
|
||||
Telnet = null;
|
||||
terminalDlg = null;
|
||||
|
||||
running = false;
|
||||
@ -89,15 +89,15 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
if (!cameraDetected) throw new Exception("No camera detected");
|
||||
|
||||
/// Open telnet clint and start the log-in process
|
||||
telnet = new Telnet.TelnetClient(this, cameraCfg.Name, ClpUserName, ClpPassword, ClpPrompt);
|
||||
Telnet = new Telnet.TelnetClient(this, cameraCfg.Name, ClpUserName, ClpPassword, ClpPrompt);
|
||||
|
||||
if (cameraCfg.DisplayTerminal)
|
||||
{
|
||||
terminalDlg = new TerminalDlg(cameraCfg.Name, telnet);
|
||||
terminalDlg = new TerminalDlg(cameraCfg.Name, Telnet);
|
||||
terminalDlg.Show();
|
||||
}
|
||||
|
||||
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.CONNECT, ipAddress.ToString(), 10, 30));
|
||||
Telnet.Enqueue(new Telnet.Command(Network.Telnet.CmdAction.CONNECT, ipAddress.ToString(), 10, 30));
|
||||
|
||||
running = true;
|
||||
|
||||
@ -112,10 +112,10 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
terminalDlg = null;
|
||||
}
|
||||
|
||||
if (telnet != null)
|
||||
if (Telnet != null)
|
||||
{
|
||||
telnet.Dispose();
|
||||
telnet = null;
|
||||
Telnet.Dispose();
|
||||
Telnet = null;
|
||||
}
|
||||
|
||||
running = false;
|
||||
@ -128,7 +128,12 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
|
||||
public IOperation LiveStreamOp()
|
||||
{
|
||||
return new LiveStreamOp(this, telnet);
|
||||
return new LiveStreamOp(this, Telnet, "clp/livestream.sh");
|
||||
}
|
||||
|
||||
public IOperation HRLiveStreamOp()
|
||||
{
|
||||
return new LiveStreamOp(this, Telnet, "clp/hrlivestream.sh");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
{
|
||||
readonly Camera camera;
|
||||
readonly Telnet.TelnetClient telnet;
|
||||
readonly string command;
|
||||
|
||||
bool liveStreamCommandSent;
|
||||
|
||||
@ -13,10 +14,11 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
/// Events: Event.None or Event.Error
|
||||
/// </summary>
|
||||
/// <param name="camera">CLP1611.Camera reference</param>
|
||||
public LiveStreamOp(Camera camera, Telnet.TelnetClient telnet)
|
||||
public LiveStreamOp(Camera camera, Telnet.TelnetClient telnet, string command)
|
||||
{
|
||||
this.camera = camera;
|
||||
this.telnet = telnet;
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
|
||||
@ -31,7 +33,7 @@ namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
{
|
||||
if (telnet.State == TelnetClient.TelnetState.Inactive)
|
||||
{
|
||||
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_STRING, "clp/livestream.sh"));
|
||||
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_STRING, command));
|
||||
liveStreamCommandSent = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,49 +0,0 @@
|
||||
using TBF.BenchControl.Network.Telnet;
|
||||
|
||||
namespace TBF.BenchControl.Network.Camera.CLP1611
|
||||
{
|
||||
public class RoiDetectionOp : IOperation
|
||||
{
|
||||
readonly Camera camera;
|
||||
readonly Telnet.TelnetClient telnet;
|
||||
|
||||
bool liveStreamCommandSent;
|
||||
|
||||
/// <summary>
|
||||
/// Events: Event.None or Event.Error
|
||||
/// </summary>
|
||||
/// <param name="camera">CLP1611.Camera reference</param>
|
||||
public RoiDetectionOp(Camera camera, Telnet.TelnetClient telnet)
|
||||
{
|
||||
this.camera = camera;
|
||||
this.telnet = telnet;
|
||||
}
|
||||
|
||||
|
||||
public void Start()
|
||||
{
|
||||
liveStreamCommandSent = false;
|
||||
}
|
||||
|
||||
public Event Run()
|
||||
{
|
||||
if (!liveStreamCommandSent)
|
||||
{
|
||||
if (telnet.State == TelnetClient.TelnetState.Inactive)
|
||||
{
|
||||
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_COMMAND, "clp/roidetection.sh"));
|
||||
liveStreamCommandSent = true;
|
||||
}
|
||||
}
|
||||
return Event.None;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (liveStreamCommandSent)
|
||||
{
|
||||
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_COMMAND, Telnet.TelnetClient.CtrlCCommand));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -18,6 +18,16 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
|
||||
protected readonly RoICfg roiCfg;
|
||||
|
||||
readonly CLP1611.Camera camera;
|
||||
readonly Telnet.TelnetClient telnet;
|
||||
|
||||
|
||||
Boxes.IntBox oroiX;
|
||||
Boxes.IntBox oroiY;
|
||||
Boxes.IntBox oroiWid;
|
||||
Boxes.IntBox oroiHgh;
|
||||
|
||||
|
||||
public RoI()
|
||||
{
|
||||
}
|
||||
@ -26,7 +36,28 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
: base(cfg)
|
||||
{
|
||||
roiCfg = cfg as RoICfg;
|
||||
camera = TbfComponents.FindComponent(cfg.ParentName, components) as CLP1611.Camera;
|
||||
if (camera != null) telnet = camera.Telnet;
|
||||
|
||||
oroiX = new Boxes.IntBox();
|
||||
oroiY = new Boxes.IntBox();
|
||||
oroiWid = new Boxes.IntBox();
|
||||
oroiHgh = new Boxes.IntBox();
|
||||
|
||||
log.Debug(this.ToString());
|
||||
}
|
||||
|
||||
public IOperation RoiDetectionOp()
|
||||
{
|
||||
if (camera != null && telnet != null)
|
||||
{
|
||||
return new RoiDetectionOp(this, camera, telnet, string.Format("clp/RoiDetection {0}", roiCfg.Args),
|
||||
oroiX, oroiY, oroiWid, oroiHgh);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
///
|
||||
/// Serialized parameters
|
||||
///
|
||||
public int HardwareAddress;
|
||||
public string Args;
|
||||
|
||||
/// Private parameterless constructor invoked by all other (public) constructors
|
||||
RoICfg() { }
|
||||
@ -22,13 +22,13 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
{
|
||||
Name = name;
|
||||
Factory = factory;
|
||||
ParentName = "Network.Camera";
|
||||
HardwareAddress = 1;
|
||||
ParentName = "Camera";
|
||||
Args = string.Empty;
|
||||
}
|
||||
|
||||
public string ToString(int i)
|
||||
{
|
||||
return string.Format("Name={0}, HWAddr={1}", Name, HardwareAddress);
|
||||
return string.Format("Name={0}, Parent={1}, Args={2}", Name, ParentName, Args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,14 +62,14 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
classNameLabel.Text = config.Factory.ClassName;
|
||||
nameTextBox.Text = config.Name;
|
||||
parentNameComboBox.Text = string.IsNullOrEmpty(config.ParentName) ? "---" : config.ParentName;
|
||||
hwAddressTextBox.Text = config.HardwareAddress.ToString();
|
||||
argsTextBox.Text = config.Args;
|
||||
}
|
||||
|
||||
public void Unlock()
|
||||
{
|
||||
nameTextBox.Enabled = true;
|
||||
parentNameComboBox.Enabled = true;
|
||||
hwAddressTextBox.Enabled = true;
|
||||
argsTextBox.Enabled = true;
|
||||
}
|
||||
|
||||
public CfgUpdateFlags UpdateCfg()
|
||||
@ -80,7 +80,7 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
|
||||
config.Name = nameTextBox.Text;
|
||||
config.ParentName = parentNameComboBox.Text.Equals("---") ? string.Empty : parentNameComboBox.Text;
|
||||
config.HardwareAddress = int.Parse(hwAddressTextBox.Text);
|
||||
config.Args = argsTextBox.Text;
|
||||
|
||||
return flags;
|
||||
}
|
||||
@ -89,18 +89,13 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
{
|
||||
CfgUpdateFlags flags = CfgUpdateFlags.None;
|
||||
|
||||
int dummy;
|
||||
if (!parentNameComboBox.Items.Contains(parentNameComboBox.Text))
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "Invalid 'Parent Name'";
|
||||
}
|
||||
if (!int.TryParse(hwAddressTextBox.Text, out dummy) || dummy < 1 || dummy > 63)
|
||||
{
|
||||
flags |= CfgUpdateFlags.Error;
|
||||
message += Environment.NewLine + "'HW Address' should be between 1 and 63";
|
||||
}
|
||||
return flags;
|
||||
|
||||
return flags;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,8 +31,8 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.hwAddressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.bitPositionLabel = new System.Windows.Forms.Label();
|
||||
this.argsTextBox = new System.Windows.Forms.TextBox();
|
||||
this.argsLabel = new System.Windows.Forms.Label();
|
||||
this.parentNameLabel = new System.Windows.Forms.Label();
|
||||
this.nameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.nameLabel = new System.Windows.Forms.Label();
|
||||
@ -40,27 +40,27 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
this.parentNameComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// hwAddressTextBox
|
||||
// argsTextBox
|
||||
//
|
||||
this.hwAddressTextBox.Enabled = false;
|
||||
this.hwAddressTextBox.Location = new System.Drawing.Point(122, 99);
|
||||
this.hwAddressTextBox.Name = "hwAddressTextBox";
|
||||
this.hwAddressTextBox.Size = new System.Drawing.Size(46, 20);
|
||||
this.hwAddressTextBox.TabIndex = 6;
|
||||
this.argsTextBox.Enabled = false;
|
||||
this.argsTextBox.Location = new System.Drawing.Point(104, 99);
|
||||
this.argsTextBox.Name = "argsTextBox";
|
||||
this.argsTextBox.Size = new System.Drawing.Size(372, 20);
|
||||
this.argsTextBox.TabIndex = 6;
|
||||
//
|
||||
// bitPositionLabel
|
||||
// argsLabel
|
||||
//
|
||||
this.bitPositionLabel.AutoSize = true;
|
||||
this.bitPositionLabel.Location = new System.Drawing.Point(36, 102);
|
||||
this.bitPositionLabel.Name = "bitPositionLabel";
|
||||
this.bitPositionLabel.Size = new System.Drawing.Size(67, 13);
|
||||
this.bitPositionLabel.TabIndex = 5;
|
||||
this.bitPositionLabel.Text = "HW Address";
|
||||
this.argsLabel.AutoSize = true;
|
||||
this.argsLabel.Location = new System.Drawing.Point(18, 102);
|
||||
this.argsLabel.Name = "argsLabel";
|
||||
this.argsLabel.Size = new System.Drawing.Size(57, 13);
|
||||
this.argsLabel.TabIndex = 5;
|
||||
this.argsLabel.Text = "Arguments";
|
||||
//
|
||||
// parentNameLabel
|
||||
//
|
||||
this.parentNameLabel.AutoSize = true;
|
||||
this.parentNameLabel.Location = new System.Drawing.Point(36, 76);
|
||||
this.parentNameLabel.Location = new System.Drawing.Point(18, 76);
|
||||
this.parentNameLabel.Name = "parentNameLabel";
|
||||
this.parentNameLabel.Size = new System.Drawing.Size(69, 13);
|
||||
this.parentNameLabel.TabIndex = 3;
|
||||
@ -69,7 +69,7 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
// nameTextBox
|
||||
//
|
||||
this.nameTextBox.Enabled = false;
|
||||
this.nameTextBox.Location = new System.Drawing.Point(122, 47);
|
||||
this.nameTextBox.Location = new System.Drawing.Point(104, 47);
|
||||
this.nameTextBox.Name = "nameTextBox";
|
||||
this.nameTextBox.Size = new System.Drawing.Size(130, 20);
|
||||
this.nameTextBox.TabIndex = 2;
|
||||
@ -77,7 +77,7 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
// nameLabel
|
||||
//
|
||||
this.nameLabel.AutoSize = true;
|
||||
this.nameLabel.Location = new System.Drawing.Point(36, 50);
|
||||
this.nameLabel.Location = new System.Drawing.Point(18, 50);
|
||||
this.nameLabel.Name = "nameLabel";
|
||||
this.nameLabel.Size = new System.Drawing.Size(35, 13);
|
||||
this.nameLabel.TabIndex = 1;
|
||||
@ -86,7 +86,7 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
// classNameLabel
|
||||
//
|
||||
this.classNameLabel.AutoSize = true;
|
||||
this.classNameLabel.Location = new System.Drawing.Point(119, 21);
|
||||
this.classNameLabel.Location = new System.Drawing.Point(101, 21);
|
||||
this.classNameLabel.Name = "classNameLabel";
|
||||
this.classNameLabel.Size = new System.Drawing.Size(83, 13);
|
||||
this.classNameLabel.TabIndex = 0;
|
||||
@ -96,24 +96,24 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
//
|
||||
this.parentNameComboBox.Enabled = false;
|
||||
this.parentNameComboBox.FormattingEnabled = true;
|
||||
this.parentNameComboBox.Location = new System.Drawing.Point(122, 73);
|
||||
this.parentNameComboBox.Location = new System.Drawing.Point(104, 73);
|
||||
this.parentNameComboBox.Name = "parentNameComboBox";
|
||||
this.parentNameComboBox.Size = new System.Drawing.Size(130, 21);
|
||||
this.parentNameComboBox.TabIndex = 4;
|
||||
//
|
||||
// CameraCfgCtrl
|
||||
// RoICfgCtrl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.parentNameComboBox);
|
||||
this.Controls.Add(this.hwAddressTextBox);
|
||||
this.Controls.Add(this.bitPositionLabel);
|
||||
this.Controls.Add(this.argsTextBox);
|
||||
this.Controls.Add(this.argsLabel);
|
||||
this.Controls.Add(this.parentNameLabel);
|
||||
this.Controls.Add(this.nameTextBox);
|
||||
this.Controls.Add(this.nameLabel);
|
||||
this.Controls.Add(this.classNameLabel);
|
||||
this.Name = "CameraCfgCtrl";
|
||||
this.Size = new System.Drawing.Size(300, 200);
|
||||
this.Name = "RoICfgCtrl";
|
||||
this.Size = new System.Drawing.Size(500, 300);
|
||||
this.Load += new System.EventHandler(this.PumpCfgCtrl_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
@ -122,8 +122,8 @@ namespace TBF.BenchControl.Network.Camera.RoI
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox hwAddressTextBox;
|
||||
private System.Windows.Forms.Label bitPositionLabel;
|
||||
private System.Windows.Forms.TextBox argsTextBox;
|
||||
private System.Windows.Forms.Label argsLabel;
|
||||
private System.Windows.Forms.Label parentNameLabel;
|
||||
private System.Windows.Forms.TextBox nameTextBox;
|
||||
private System.Windows.Forms.Label nameLabel;
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
using TBF.BenchControl.Network.Telnet;
|
||||
|
||||
namespace TBF.BenchControl.Network.Camera.RoI
|
||||
{
|
||||
public class RoiDetectionOp : IOperation
|
||||
{
|
||||
readonly CLP1611.Camera camera;
|
||||
readonly Telnet.TelnetClient telnet;
|
||||
readonly string command;
|
||||
|
||||
bool roiDetectionCommandSent;
|
||||
|
||||
Boxes.IntBox oroiX;
|
||||
Boxes.IntBox oroiY;
|
||||
Boxes.IntBox oroiWid;
|
||||
Boxes.IntBox oroiHgh;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Events: Event.None or Event.Error
|
||||
/// </summary>
|
||||
/// <param name="camera">CLP1611.Camera reference</param>
|
||||
public RoiDetectionOp(RoI roi, CLP1611.Camera camera, Telnet.TelnetClient telnet, string command,
|
||||
Boxes.IntBox oroiX,
|
||||
Boxes.IntBox oroiY,
|
||||
Boxes.IntBox oroiWid,
|
||||
Boxes.IntBox oroiHgh)
|
||||
{
|
||||
this.camera = camera;
|
||||
this.telnet = telnet;
|
||||
this.command = command;
|
||||
this.oroiX = oroiX;
|
||||
this.oroiY = oroiY;
|
||||
this.oroiWid = oroiWid;
|
||||
this.oroiHgh = oroiHgh;
|
||||
}
|
||||
|
||||
|
||||
public void Start()
|
||||
{
|
||||
roiDetectionCommandSent = false;
|
||||
}
|
||||
|
||||
public Event Run()
|
||||
{
|
||||
if (!roiDetectionCommandSent)
|
||||
{
|
||||
if (telnet.State == TelnetClient.TelnetState.Inactive)
|
||||
{
|
||||
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_COMMAND, command));
|
||||
roiDetectionCommandSent = true;
|
||||
}
|
||||
}
|
||||
return Event.None;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (roiDetectionCommandSent)
|
||||
{
|
||||
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_COMMAND, Telnet.TelnetClient.CtrlCCommand));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -514,7 +514,6 @@
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Network\Camera\CLP1611\Factory.cs" />
|
||||
<Compile Include="BenchControl\Network\Camera\CLP1611\LiveStreamOp.cs" />
|
||||
<Compile Include="BenchControl\Network\Camera\CLP1611\RoiDetectionOp.cs" />
|
||||
<Compile Include="BenchControl\Network\Camera\CLP1611\TerminalDlg.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -530,6 +529,7 @@
|
||||
<DependentUpon>RoICfgCtrl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="BenchControl\Network\Camera\RoI\Factory.cs" />
|
||||
<Compile Include="BenchControl\Network\Camera\RoI\RoiDetectionOp.cs" />
|
||||
<Compile Include="BenchControl\Network\Telnet\Command.cs" />
|
||||
<Compile Include="BenchControl\Network\Telnet\EventArgsClasses.cs" />
|
||||
<Compile Include="BenchControl\Network\Telnet\TelnetClient.cs" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user