CameraUICmd and CameraUICmdEventArgs added ti UiBridge

This commit is contained in:
Milan Hanajik 2017-10-20 14:06:50 +02:00
parent 75f72cb04e
commit 4cc9715f57
7 changed files with 258 additions and 34 deletions

View File

@ -36,6 +36,10 @@ namespace TBF.Screens
this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.minusButton = new System.Windows.Forms.Button(); this.minusButton = new System.Windows.Forms.Button();
this.plusButton = new System.Windows.Forms.Button(); this.plusButton = new System.Windows.Forms.Button();
this.liveButton = new System.Windows.Forms.Button();
this.stopButton = new System.Windows.Forms.Button();
this.grabButton = new System.Windows.Forms.Button();
this.saveImageButton = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout();
@ -63,6 +67,10 @@ namespace TBF.Screens
// splitContainer1.Panel2 // splitContainer1.Panel2
// //
this.splitContainer1.Panel2.BackColor = System.Drawing.SystemColors.ControlLight; this.splitContainer1.Panel2.BackColor = System.Drawing.SystemColors.ControlLight;
this.splitContainer1.Panel2.Controls.Add(this.saveImageButton);
this.splitContainer1.Panel2.Controls.Add(this.grabButton);
this.splitContainer1.Panel2.Controls.Add(this.stopButton);
this.splitContainer1.Panel2.Controls.Add(this.liveButton);
this.splitContainer1.Panel2.Controls.Add(this.minusButton); this.splitContainer1.Panel2.Controls.Add(this.minusButton);
this.splitContainer1.Panel2.Controls.Add(this.plusButton); this.splitContainer1.Panel2.Controls.Add(this.plusButton);
// //
@ -80,6 +88,34 @@ namespace TBF.Screens
this.plusButton.UseVisualStyleBackColor = true; this.plusButton.UseVisualStyleBackColor = true;
this.plusButton.Click += new System.EventHandler(this.plusButton_Click); this.plusButton.Click += new System.EventHandler(this.plusButton_Click);
// //
// liveButton
//
resources.ApplyResources(this.liveButton, "liveButton");
this.liveButton.Name = "liveButton";
this.liveButton.UseVisualStyleBackColor = true;
this.liveButton.Click += new System.EventHandler(this.liveButton_Click);
//
// stopButton
//
resources.ApplyResources(this.stopButton, "stopButton");
this.stopButton.Name = "stopButton";
this.stopButton.UseVisualStyleBackColor = true;
this.stopButton.Click += new System.EventHandler(this.stopButton_Click);
//
// grabButton
//
resources.ApplyResources(this.grabButton, "grabButton");
this.grabButton.Name = "grabButton";
this.grabButton.UseVisualStyleBackColor = true;
this.grabButton.Click += new System.EventHandler(this.grabButton_Click);
//
// saveImageButton
//
resources.ApplyResources(this.saveImageButton, "saveImageButton");
this.saveImageButton.Name = "saveImageButton";
this.saveImageButton.UseVisualStyleBackColor = true;
this.saveImageButton.Click += new System.EventHandler(this.saveImageButton_Click);
//
// PicturesTabPageCtrl // PicturesTabPageCtrl
// //
resources.ApplyResources(this, "$this"); resources.ApplyResources(this, "$this");
@ -101,5 +137,9 @@ namespace TBF.Screens
private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Button minusButton; private System.Windows.Forms.Button minusButton;
private System.Windows.Forms.Button plusButton; private System.Windows.Forms.Button plusButton;
private System.Windows.Forms.Button grabButton;
private System.Windows.Forms.Button stopButton;
private System.Windows.Forms.Button liveButton;
private System.Windows.Forms.Button saveImageButton;
} }
} }

View File

@ -1,5 +1,5 @@
/// ///
/// Copyright (c) 2013-2017 Sensus Metering Systems /// Copyright (c) 2017 Sensus Metering Systems
/// ///
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -8,6 +8,8 @@ using log4net;
using Config.Entities; using Config.Entities;
using TBF.Resources; using TBF.Resources;
using TBF.UiBridge; using TBF.UiBridge;
using TBF.BenchControl;
using TBF.BenchControl.Network.Camera.CLP1611;
namespace TBF.Screens namespace TBF.Screens
{ {
@ -139,5 +141,26 @@ namespace TBF.Screens
picturesFlowLayoutPanel.Controls.Add(ctrl); picturesFlowLayoutPanel.Controls.Add(ctrl);
} }
} }
}
private void grabButton_Click(object sender, EventArgs e)
{
Bridge.OnCameraUICmd(this, new CameraUICmdEventArgs(CameraUICmd.Grab, -1));
}
private void liveButton_Click(object sender, EventArgs e)
{
Bridge.OnCameraUICmd(this, new CameraUICmdEventArgs(CameraUICmd.Live, -1));
}
private void stopButton_Click(object sender, EventArgs e)
{
Bridge.OnCameraUICmd(this, new CameraUICmdEventArgs(CameraUICmd.Stop, -1));
}
private void saveImageButton_Click(object sender, EventArgs e)
{
Bridge.OnCameraUICmd(this, new CameraUICmdEventArgs(CameraUICmd.SaveImage, -1));
}
}
} }

View File

@ -130,7 +130,7 @@
<value>0, 0</value> <value>0, 0</value>
</data> </data>
<data name="picturesFlowLayoutPanel.Size" type="System.Drawing.Size, System.Drawing"> <data name="picturesFlowLayoutPanel.Size" type="System.Drawing.Size, System.Drawing">
<value>1009, 689</value> <value>1007, 689</value>
</data> </data>
<data name="picturesFlowLayoutPanel.TabIndex" type="System.Int32, mscorlib"> <data name="picturesFlowLayoutPanel.TabIndex" type="System.Int32, mscorlib">
<value>0</value> <value>0</value>
@ -165,14 +165,134 @@
<data name="&gt;&gt;splitContainer1.Panel1.ZOrder" xml:space="preserve"> <data name="&gt;&gt;splitContainer1.Panel1.ZOrder" xml:space="preserve">
<value>0</value> <value>0</value>
</data> </data>
<data name="saveImageButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Arial, 8.25pt, style=Bold</value>
</data>
<data name="saveImageButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="saveImageButton.Location" type="System.Drawing.Point, System.Drawing">
<value>1, 189</value>
</data>
<data name="saveImageButton.Size" type="System.Drawing.Size, System.Drawing">
<value>23, 23</value>
</data>
<data name="saveImageButton.TabIndex" type="System.Int32, mscorlib">
<value>5</value>
</data>
<data name="saveImageButton.Text" xml:space="preserve">
<value>S</value>
</data>
<data name="&gt;&gt;saveImageButton.Name" xml:space="preserve">
<value>saveImageButton</value>
</data>
<data name="&gt;&gt;saveImageButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;saveImageButton.Parent" xml:space="preserve">
<value>splitContainer1.Panel2</value>
</data>
<data name="&gt;&gt;saveImageButton.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="grabButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Arial, 8.25pt, style=Bold</value>
</data>
<data name="grabButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="grabButton.Location" type="System.Drawing.Point, System.Drawing">
<value>1, 102</value>
</data>
<data name="grabButton.Size" type="System.Drawing.Size, System.Drawing">
<value>23, 23</value>
</data>
<data name="grabButton.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="grabButton.Text" xml:space="preserve">
<value>o</value>
</data>
<data name="&gt;&gt;grabButton.Name" xml:space="preserve">
<value>grabButton</value>
</data>
<data name="&gt;&gt;grabButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;grabButton.Parent" xml:space="preserve">
<value>splitContainer1.Panel2</value>
</data>
<data name="&gt;&gt;grabButton.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="stopButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Arial, 8.25pt</value>
</data>
<data name="stopButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="stopButton.Location" type="System.Drawing.Point, System.Drawing">
<value>1, 160</value>
</data>
<data name="stopButton.Size" type="System.Drawing.Size, System.Drawing">
<value>23, 23</value>
</data>
<data name="stopButton.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="stopButton.Text" xml:space="preserve">
<value>■</value>
</data>
<data name="&gt;&gt;stopButton.Name" xml:space="preserve">
<value>stopButton</value>
</data>
<data name="&gt;&gt;stopButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;stopButton.Parent" xml:space="preserve">
<value>splitContainer1.Panel2</value>
</data>
<data name="&gt;&gt;stopButton.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="liveButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Arial, 8.25pt</value>
</data>
<data name="liveButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="liveButton.Location" type="System.Drawing.Point, System.Drawing">
<value>1, 131</value>
</data>
<data name="liveButton.Size" type="System.Drawing.Size, System.Drawing">
<value>23, 23</value>
</data>
<data name="liveButton.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="liveButton.Text" xml:space="preserve">
<value>►</value>
</data>
<data name="&gt;&gt;liveButton.Name" xml:space="preserve">
<value>liveButton</value>
</data>
<data name="&gt;&gt;liveButton.Type" xml:space="preserve">
<value>System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;liveButton.Parent" xml:space="preserve">
<value>splitContainer1.Panel2</value>
</data>
<data name="&gt;&gt;liveButton.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="minusButton.Font" type="System.Drawing.Font, System.Drawing"> <data name="minusButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Microsoft Sans Serif, 8.25pt, style=Bold</value> <value>Arial, 8.25pt</value>
</data> </data>
<data name="minusButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms"> <data name="minusButton.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value> <value>NoControl</value>
</data> </data>
<data name="minusButton.Location" type="System.Drawing.Point, System.Drawing"> <data name="minusButton.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 33</value> <value>1, 33</value>
</data> </data>
<data name="minusButton.Size" type="System.Drawing.Size, System.Drawing"> <data name="minusButton.Size" type="System.Drawing.Size, System.Drawing">
<value>23, 23</value> <value>23, 23</value>
@ -193,13 +313,13 @@
<value>splitContainer1.Panel2</value> <value>splitContainer1.Panel2</value>
</data> </data>
<data name="&gt;&gt;minusButton.ZOrder" xml:space="preserve"> <data name="&gt;&gt;minusButton.ZOrder" xml:space="preserve">
<value>0</value> <value>4</value>
</data> </data>
<data name="plusButton.Font" type="System.Drawing.Font, System.Drawing"> <data name="plusButton.Font" type="System.Drawing.Font, System.Drawing">
<value>Microsoft Sans Serif, 8.25pt, style=Bold</value> <value>Arial, 8.25pt</value>
</data> </data>
<data name="plusButton.Location" type="System.Drawing.Point, System.Drawing"> <data name="plusButton.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 7</value> <value>1, 7</value>
</data> </data>
<data name="plusButton.Size" type="System.Drawing.Size, System.Drawing"> <data name="plusButton.Size" type="System.Drawing.Size, System.Drawing">
<value>23, 23</value> <value>23, 23</value>
@ -220,7 +340,7 @@
<value>splitContainer1.Panel2</value> <value>splitContainer1.Panel2</value>
</data> </data>
<data name="&gt;&gt;plusButton.ZOrder" xml:space="preserve"> <data name="&gt;&gt;plusButton.ZOrder" xml:space="preserve">
<value>1</value> <value>5</value>
</data> </data>
<data name="&gt;&gt;splitContainer1.Panel2.Name" xml:space="preserve"> <data name="&gt;&gt;splitContainer1.Panel2.Name" xml:space="preserve">
<value>splitContainer1.Panel2</value> <value>splitContainer1.Panel2</value>
@ -241,7 +361,7 @@
<value>1033, 689</value> <value>1033, 689</value>
</data> </data>
<data name="splitContainer1.SplitterDistance" type="System.Int32, mscorlib"> <data name="splitContainer1.SplitterDistance" type="System.Int32, mscorlib">
<value>1009</value> <value>1007</value>
</data> </data>
<data name="splitContainer1.SplitterWidth" type="System.Int32, mscorlib"> <data name="splitContainer1.SplitterWidth" type="System.Int32, mscorlib">
<value>1</value> <value>1</value>

View File

@ -1711,6 +1711,7 @@
<Compile Include="UiBridge\Bridge.cs" /> <Compile Include="UiBridge\Bridge.cs" />
<Compile Include="UiBridge\ButtonsEtcEventArgs.cs" /> <Compile Include="UiBridge\ButtonsEtcEventArgs.cs" />
<Compile Include="UiBridge\CameraInfoEventArgs.cs" /> <Compile Include="UiBridge\CameraInfoEventArgs.cs" />
<Compile Include="UiBridge\CameraUICmdEventArgs.cs" />
<Compile Include="UiBridge\EmergencyStopEventArgs.cs" /> <Compile Include="UiBridge\EmergencyStopEventArgs.cs" />
<Compile Include="UiBridge\Enums.cs" /> <Compile Include="UiBridge\Enums.cs" />
<Compile Include="UiBridge\ImageEventArgs.cs" /> <Compile Include="UiBridge\ImageEventArgs.cs" />

View File

@ -142,29 +142,6 @@ namespace TBF.UiBridge
public static event EventHandler<ProcedureCompletedEventArgs> ProcedureCompletedHandler; public static event EventHandler<ProcedureCompletedEventArgs> ProcedureCompletedHandler;
/// <summary>
/// Called from a camera when camera state (shown as a caption in PicturesTabPage) changes
/// </summary>
public static void OnCameraInfo(int cameraIdx, string info)
{
if (CameraInfoHandler == null) return;
try { CameraInfoHandler(null, new CameraInfoEventArgs(cameraIdx, info)); }
catch (Exception e) { log.Error("CameraInfoHandler(...) failed", e); }
}
public static event EventHandler<CameraInfoEventArgs> CameraInfoHandler;
/// <summary>
/// Called from any RTP listener thread (e.g. MJpeg RTP listener thread)
/// </summary>
public static void OnImage(int cameraIdx, System.Drawing.Image image)
{
if (ImageHandler == null) return;
try { ImageHandler(null, new ImageEventArgs(cameraIdx, image)); }
catch (Exception e) { log.Error("ImageHandler(...) failed", e); }
}
public static event EventHandler<ImageEventArgs> ImageHandler;
/// <summary> /// <summary>
/// Called from the state machine when there is and information to be logged. /// Called from the state machine when there is and information to be logged.
/// </summary> /// </summary>
@ -247,5 +224,40 @@ namespace TBF.UiBridge
catch (Exception e) { log.Error("CloseQandAFormHandler(...) failed", e); } catch (Exception e) { log.Error("CloseQandAFormHandler(...) failed", e); }
} }
public static event EventHandler<EventArgs> CloseQandAFormHandler; public static event EventHandler<EventArgs> CloseQandAFormHandler;
/// <summary>
/// Called from the state machine when a procedure is selected and UI needs to be updated.
/// </summary>
public static void OnCameraUICmd(object sender, CameraUICmdEventArgs data)
{
if (CameraUICmdHandler == null) return;
try { CameraUICmdHandler(sender, data); }
catch (Exception e) { log.Error("CameraUICmdHandler(...) failed", e); }
}
public static event EventHandler<CameraUICmdEventArgs> CameraUICmdHandler;
/// <summary>
/// Called from a camera when camera state (shown as a caption in PicturesTabPage) changes
/// </summary>
public static void OnCameraInfo(int cameraIdx, string info)
{
if (CameraInfoHandler == null) return;
try { CameraInfoHandler(null, new CameraInfoEventArgs(cameraIdx, info)); }
catch (Exception e) { log.Error("CameraInfoHandler(...) failed", e); }
}
public static event EventHandler<CameraInfoEventArgs> CameraInfoHandler;
/// <summary>
/// Called from any RTP listener thread (e.g. MJpeg RTP listener thread)
/// </summary>
public static void OnImage(int cameraIdx, System.Drawing.Image image)
{
if (ImageHandler == null) return;
try { ImageHandler(null, new ImageEventArgs(cameraIdx, image)); }
catch (Exception e) { log.Error("ImageHandler(...) failed", e); }
}
public static event EventHandler<ImageEventArgs> ImageHandler;
} }
} }

View File

@ -0,0 +1,28 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
///
using System;
namespace TBF.UiBridge
{
public enum CameraUICmd
{
None,
Grab,
Live,
Stop,
SaveImage,
}
public class CameraUICmdEventArgs : EventArgs
{
public CameraUICmd CameraUICmd;
public int CameraIdx; /// 0-based camera index/identifier. -1 = all cameras
public CameraUICmdEventArgs(CameraUICmd cameraUICmd, int cameraIdx)
{
CameraUICmd = cameraUICmd;
CameraIdx = cameraIdx;
}
}
}

View File

@ -8,7 +8,7 @@ namespace TBF.UiBridge
{ {
public class ImageEventArgs : EventArgs public class ImageEventArgs : EventArgs
{ {
public int CameraIdx; public int CameraIdx; /// 0-based camera index/identifier
public Image Image; public Image Image;
public ImageEventArgs(int cameraIdx, Image image) public ImageEventArgs(int cameraIdx, Image image)