Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d15073bb5 | ||
|
|
79be186bef |
@@ -1,6 +1,7 @@
|
|||||||
///
|
///
|
||||||
/// Copyright (c) 2017 Sensus Slovensko a.s.
|
/// Copyright (c) 2017 Sensus Slovensko a.s.
|
||||||
///
|
///
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using log4net;
|
using log4net;
|
||||||
@@ -14,9 +15,12 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
|||||||
public class GrabImagesOp : IOperation
|
public class GrabImagesOp : IOperation
|
||||||
{
|
{
|
||||||
/// TODO: Implement support for grabbing multiple images, now imgFileNames.Lenght should be 1
|
/// TODO: Implement support for grabbing multiple images, now imgFileNames.Lenght should be 1
|
||||||
|
|
||||||
private static readonly ILog log = LogManager.GetLogger(typeof(GrabImagesOp));
|
private static readonly ILog log = LogManager.GetLogger(typeof(GrabImagesOp));
|
||||||
public override string ToString() { return string.Format("GrabImageOp()"); }
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return string.Format("GrabImageOp()");
|
||||||
|
}
|
||||||
|
|
||||||
readonly Camera camera;
|
readonly Camera camera;
|
||||||
readonly Telnet.TelnetClient telnet;
|
readonly Telnet.TelnetClient telnet;
|
||||||
@@ -37,7 +41,8 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
|||||||
/// Events: Event.None or Event.Error
|
/// Events: Event.None or Event.Error
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="camera">CLP1611.Camera reference</param>
|
/// <param name="camera">CLP1611.Camera reference</param>
|
||||||
public GrabImagesOp(Camera camera, string[] imgFileNames, bool blackAndWhite, bool lowResolution, ImageRotation imageRotation)
|
public GrabImagesOp(Camera camera, string[] imgFileNames, bool blackAndWhite, bool lowResolution,
|
||||||
|
ImageRotation imageRotation)
|
||||||
{
|
{
|
||||||
/// TODO: Implement support for grabbing multiple images, now imgFileNames.Lenght should be 1
|
/// TODO: Implement support for grabbing multiple images, now imgFileNames.Lenght should be 1
|
||||||
|
|
||||||
@@ -77,15 +82,31 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
|||||||
///
|
///
|
||||||
/// An image specified, (1) delete previous image, (2) check if this is a simulation
|
/// An image specified, (1) delete previous image, (2) check if this is a simulation
|
||||||
///
|
///
|
||||||
|
try
|
||||||
|
{
|
||||||
File.Delete(imgFileNames[0]);
|
File.Delete(imgFileNames[0]);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Celan up failed! Delete file atempt {0} failed! Detail: {1}", imgFileNames[0], e.StackTrace);
|
||||||
|
}
|
||||||
|
|
||||||
if (camera.CameraCfg.DebugLevel == DebugMode.Simulate || camera.CameraCfg.DebugLevel == DebugMode.DetectedOff)
|
if (camera.CameraCfg.DebugLevel == DebugMode.Simulate ||
|
||||||
|
camera.CameraCfg.DebugLevel == DebugMode.DetectedOff)
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
/// Camera is in simulation mode => create a simulated image
|
/// Camera is in simulation mode => create a simulated image
|
||||||
///
|
///
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
File.Copy(string.Format("{0}\\Pictures\\sample.jpg", Program.ExecutableDir), imgFileNames[0]);
|
File.Copy(string.Format("{0}\\Pictures\\sample.jpg", Program.ExecutableDir), imgFileNames[0]);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Simulation/DetectedOff file copy to {0} failed! Deatil: {1}", imgFileNames[0], e.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +132,8 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
|||||||
///
|
///
|
||||||
/// Normal operation, no command sent yet => (1) wait until telnet state = Inactive, (2) send a command
|
/// Normal operation, no command sent yet => (1) wait until telnet state = Inactive, (2) send a command
|
||||||
///
|
///
|
||||||
|
try
|
||||||
|
{
|
||||||
if (camera.Running && (telnet.State == TelnetClient.TelnetState.Inactive))
|
if (camera.Running && (telnet.State == TelnetClient.TelnetState.Inactive))
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
@@ -144,6 +167,20 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
|||||||
grabImageCommandSent = true;
|
grabImageCommandSent = true;
|
||||||
log.WarnFormat("{0} IP={1} command={2}", camera.Name, camera.IPAddress, command);
|
log.WarnFormat("{0} IP={1} command={2}", camera.Name, camera.IPAddress, command);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (camera == null)
|
||||||
|
{
|
||||||
|
log.Error("Failed stand up from camera inactive status! Detail: " + e.StackTrace);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Failed stand up from camera inactive status! {0} IP={1} command={2} ! Detail: {3}", camera.Name, camera.IPAddress, command, e.StackTrace);
|
||||||
|
}
|
||||||
|
return Event.CameraBusy;
|
||||||
|
}
|
||||||
|
|
||||||
return Event.CameraBusy;
|
return Event.CameraBusy;
|
||||||
}
|
}
|
||||||
else if (grabPassed)
|
else if (grabPassed)
|
||||||
@@ -151,6 +188,8 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
|||||||
///
|
///
|
||||||
/// Normal operation, grab passed => transfer/transferring the image
|
/// Normal operation, grab passed => transfer/transferring the image
|
||||||
///
|
///
|
||||||
|
try
|
||||||
|
{
|
||||||
if (transferringGrabbedImage)
|
if (transferringGrabbedImage)
|
||||||
{
|
{
|
||||||
/// Grab passed and image transfer is in progress
|
/// Grab passed and image transfer is in progress
|
||||||
@@ -168,6 +207,12 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
|||||||
return Event.CameraBusy;
|
return Event.CameraBusy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Somtehing get wrong with DownloadFile - grabbed.jpg or .bmp to {0}! Detials: {1}",imgFileNames[0], e.StackTrace);
|
||||||
|
return Event.CameraBusy;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (grabFailed)
|
else if (grabFailed)
|
||||||
{
|
{
|
||||||
///
|
///
|
||||||
@@ -184,10 +229,13 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
|||||||
{
|
{
|
||||||
grabPassed = true;
|
grabPassed = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
///
|
///
|
||||||
/// Start the file transfer
|
/// Start the file transfer
|
||||||
///
|
///
|
||||||
if (0 == camera.DownloadFile(blackAndWhite ? "grabbed.jpg" : "grabbed.bmp", imgFileNames[0]))
|
if (0 == camera.DownloadFile(blackAndWhite ? "grabbed.jpg" : "grabbed.bmp",
|
||||||
|
imgFileNames[0]))
|
||||||
{
|
{
|
||||||
/// File transfer successfully started
|
/// File transfer successfully started
|
||||||
transferringGrabbedImage = true;
|
transferringGrabbedImage = true;
|
||||||
@@ -198,6 +246,12 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
|||||||
return Event.CameraBusy; /// File transfer not started yet
|
return Event.CameraBusy; /// File transfer not started yet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Sometihing get wrong! Detail:{0}", e.StackTrace);
|
||||||
|
return Event.CameraBusy;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
grabFailed = true;
|
grabFailed = true;
|
||||||
@@ -215,10 +269,17 @@ namespace TBF.Rig.Network.Camera.CLP1611
|
|||||||
if (camera.CameraCfg.DebugLevel == DebugMode.Simulate) return;
|
if (camera.CameraCfg.DebugLevel == DebugMode.Simulate) return;
|
||||||
|
|
||||||
if (grabImageCommandSent)
|
if (grabImageCommandSent)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_COMMAND, Telnet.TelnetClient.CtrlCCommand));
|
telnet.Enqueue(new Telnet.Command(Telnet.CmdAction.SEND_COMMAND, Telnet.TelnetClient.CtrlCCommand));
|
||||||
log.WarnFormat("{0} IP={1} command=CTRL-C", camera.Name, camera.IPAddress);
|
log.WarnFormat("{0} IP={1} command=CTRL-C", camera.Name, camera.IPAddress);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Failed {0} IP={1} command=CTRL-C! Detail: {2}", camera.Name, camera.IPAddress, e.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,6 +92,9 @@ namespace TBF.Rig.Network.Camera.Roi
|
|||||||
string masks = string.Empty;
|
string masks = string.Empty;
|
||||||
Roi previous = roi.PreviousRoi;
|
Roi previous = roi.PreviousRoi;
|
||||||
int maskLevel = 0;
|
int maskLevel = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
while (previous != null && maskLevel++ < 3)
|
while (previous != null && maskLevel++ < 3)
|
||||||
{
|
{
|
||||||
if (!previous.Detected)
|
if (!previous.Detected)
|
||||||
@@ -104,6 +107,7 @@ namespace TBF.Rig.Network.Camera.Roi
|
|||||||
previous.RoiWid.Val, previous.RoiHgh.Val);
|
previous.RoiWid.Val, previous.RoiHgh.Val);
|
||||||
previous = previous.PreviousRoi;
|
previous = previous.PreviousRoi;
|
||||||
}
|
}
|
||||||
|
|
||||||
command = string.Format("clp/RoiDetection{0}{1}{2}{3}{4} {5}",
|
command = string.Format("clp/RoiDetection{0}{1}{2}{3}{4} {5}",
|
||||||
masks,
|
masks,
|
||||||
string.Format(roiCfg.LoadImages ? " -l {0}" : " -n {0}", roiCfg.DetectionImagesCount),
|
string.Format(roiCfg.LoadImages ? " -l {0}" : " -n {0}", roiCfg.DetectionImagesCount),
|
||||||
@@ -120,9 +124,16 @@ namespace TBF.Rig.Network.Camera.Roi
|
|||||||
roiDetectionCommandSent = true;
|
roiDetectionCommandSent = true;
|
||||||
log.WarnFormat("{0}/{1} command={2}", roiCfg.Name, camera.Name, command);
|
log.WarnFormat("{0}/{1} command={2}", roiCfg.Name, camera.Name, command);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Something wrong in start! Command: {0} ! Details: {1}", command, e.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
return Event.CameraBusy;
|
return Event.CameraBusy;
|
||||||
}
|
}
|
||||||
else if (passed)
|
else if (passed)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (transferringDetectedImage)
|
if (transferringDetectedImage)
|
||||||
{
|
{
|
||||||
@@ -141,6 +152,12 @@ namespace TBF.Rig.Network.Camera.Roi
|
|||||||
return Event.CameraBusy;
|
return Event.CameraBusy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Someting wrong with DownloadFile(detected.jpg), imgFileNamePrefix: {0}! Details: {1}", imgFileNamePrefix, e.StackTrace);
|
||||||
|
return Event.CameraBusy;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (failed)
|
else if (failed)
|
||||||
{
|
{
|
||||||
/// ROI detection failed, there in no image to transfer
|
/// ROI detection failed, there in no image to transfer
|
||||||
@@ -151,6 +168,8 @@ namespace TBF.Rig.Network.Camera.Roi
|
|||||||
return Event.RoiDetectionPreviousFailed;
|
return Event.RoiDetectionPreviousFailed;
|
||||||
}
|
}
|
||||||
else if (response != null)
|
else if (response != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
int from = response.IndexOf('[');
|
int from = response.IndexOf('[');
|
||||||
int to = response.IndexOf(']');
|
int to = response.IndexOf(']');
|
||||||
@@ -177,7 +196,8 @@ namespace TBF.Rig.Network.Camera.Roi
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
roi.SetRoi(x, y, w, h);
|
roi.SetRoi(x, y, w, h);
|
||||||
log.WarnFormat("{0}/{1} Detection PASSED: x={2} y={3} w={4} h={5}", roiCfg.Name, camera.Name, x, y, w, h);
|
log.WarnFormat("{0}/{1} Detection PASSED: x={2} y={3} w={4} h={5}", roiCfg.Name,
|
||||||
|
camera.Name, x, y, w, h);
|
||||||
passed = true;
|
passed = true;
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -196,6 +216,12 @@ namespace TBF.Rig.Network.Camera.Roi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.ErrorFormat("Error in taken results! Details: {0}", e.StackTrace);
|
||||||
|
return Event.CameraBusy;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return Event.CameraBusy;
|
return Event.CameraBusy;
|
||||||
|
|||||||
+4
-4
@@ -39,7 +39,7 @@
|
|||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
<DefineConstants>TRACE;DEBUG;CAMERA</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE;CAMERA</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
<DefineConstants>TRACE;DEBUG;CAMERA</DefineConstants>
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
<OutputPath>bin\x86\Release\</OutputPath>
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE;CAMERA</DefineConstants>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
|||||||
Reference in New Issue
Block a user