As in 2.30.1971 : StandardCamera.TestStartEndForm with OCR, LiveStreamOp with overlay (test par.), camera does not upload binary files on startup.

This commit is contained in:
Milan Hanajik
2022-10-04 16:46:17 +02:00
parent 6270e0c417
commit 6158ee93dc
17 changed files with 2631 additions and 1894 deletions
+55 -30
View File
@@ -1,10 +1,11 @@
///
/// Copyright (c) 2017 Sensus Metering Systems
/// Copyright (c) 2017-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Net;
using System.Net.Sockets;
@@ -69,6 +70,15 @@ namespace TBF.Rig.Network.Camera.CLP1611
public bool Running { get { return running; } }
bool running;
public bool ShowOverlayRect { set { showOverlayRect = value; } }
bool showOverlayRect = false;
public Rectangle OverlayRect { set { overlayRect = value; } }
Rectangle overlayRect;
public int OverlayThickness { set { overlayThickness = value; } }
int overlayThickness;
public int CameraIdx { get { return cameraIdx; } }
int cameraIdx;
///
@@ -243,7 +253,7 @@ namespace TBF.Rig.Network.Camera.CLP1611
{
if ((CameraCfg.DebugLevel != DebugMode.Simulate) && (CameraCfg.DebugLevel != DebugMode.DetectedOff))
{
if (scpThread != null) scpThread.Join(50);
if (scpThread != null && scpThread.IsAlive) scpThread.Join(50);
if (rtpListenerThread != null) rtpListenerThread.Join(50);
if (msrmntListenerThread != null) msrmntListenerThread.Join(50);
@@ -466,37 +476,37 @@ namespace TBF.Rig.Network.Camera.CLP1611
FileInfo[] fileInfos = dirInfo.GetFiles();
foreach (FileInfo fi in fileInfos)
{
lock (fileUploadLock)
{
FileStream fs = fi.Open(FileMode.Open);
fs.Position = 0;
byte[] sha1 = sha1calculator.ComputeHash(fs);
fs.Close();
//lock (fileUploadLock)
//{
// FileStream fs = fi.Open(FileMode.Open);
// fs.Position = 0;
// byte[] sha1 = sha1calculator.ComputeHash(fs);
// fs.Close();
sha1str.Clear();
foreach (var b in sha1) sha1str.Append(b.ToString("x2"));
// sha1str.Clear();
// foreach (var b in sha1) sha1str.Append(b.ToString("x2"));
if (!sha1sumResponse.Contains(string.Format("{0} clp/{1}", sha1str, fi.Name)))
{
/// Copy a file to the camera if SHA1 sum is different of the file is missing
log.InfoFormat("{0}, IP={1}, Uploading file {2}", Name, IPAddress, fi.Name);
scpClient.Upload(fi, string.Format("~/clp/{0}", fi.Name));
}
}
// if (!sha1sumResponse.Contains(string.Format("{0} clp/{1}", sha1str, fi.Name)))
// {
// /// Copy a file to the camera if SHA1 sum is different of the file is missing
// log.InfoFormat("{0}, IP={1}, Uploading file {2}", Name, IPAddress, fi.Name);
// scpClient.Upload(fi, string.Format("~/clp/{0}", fi.Name));
// }
//}
if (!sha1sumResponse.Contains(fi.Name))
{
/// Change file properties if it was a new file
string command = string.Format("chmod 755 ~/clp/{0}", fi.Name);
log.InfoFormat("{0}, IP={1}, Executing command '{2}'", Name, IPAddress, command);
sshClient.CreateCommand(command).Execute();
//if (!sha1sumResponse.Contains(fi.Name))
//{
// /// Change file properties if it was a new file
// string command = string.Format("chmod 755 ~/clp/{0}", fi.Name);
// log.InfoFormat("{0}, IP={1}, Executing command '{2}'", Name, IPAddress, command);
// sshClient.CreateCommand(command).Execute();
//if (fi.Name.Equals("runmeonce"))
//{
// log.InfoFormat("{0}, IP={1}, Executing command 'sudo clp/runmeonce'", Name, IPAddress);
// sshClient.CreateCommand("sudo clp/runmeonce").Execute();
//}
}
// //if (fi.Name.Equals("runmeonce"))
// //{
// // log.InfoFormat("{0}, IP={1}, Executing command 'sudo clp/runmeonce'", Name, IPAddress);
// // sshClient.CreateCommand("sudo clp/runmeonce").Execute();
// //}
//}
}
}
}
@@ -590,6 +600,8 @@ namespace TBF.Rig.Network.Camera.CLP1611
{
JpegFrame jpegFrame = new JpegFrame();
bool synced = false;
int penWidth = 1;
Pen pen = new Pen(Color.Green, penWidth);
while (!stopRtpListenerFlag)
{
@@ -608,7 +620,20 @@ namespace TBF.Rig.Network.Camera.CLP1611
switch (jpegFrame.AddPacket(newPacket))
{
case RtpFrame.STATE.Complete:
UiBridge.Bridge.OnImage(this.cameraIdx, jpegFrame.ToImage());
Image image = jpegFrame.ToImage();
if (showOverlayRect && overlayRect != null && overlayThickness > 0)
{
using (var grph = Graphics.FromImage(image))
{
if (penWidth != overlayThickness)
{
penWidth = overlayThickness;
pen = new Pen(Color.Green, penWidth);
}
grph.DrawRectangle(pen, overlayRect);
}
}
UiBridge.Bridge.OnImage(this.cameraIdx, image);
jpegFrame.Clear();
break;
case RtpFrame.STATE.Error:
+2 -2
View File
@@ -5,7 +5,7 @@ using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Xml.Serialization;
using Config.Entities;
using Common;
using TBF.Rig.Generic;
using TBF.Resources;
@@ -53,7 +53,7 @@ namespace TBF.Rig.Network.Camera.CLP1611
HardwareAddress = 1;
TestImagesMode = TestImagesMode.None;
TestImagesCount = 3000;
DebugLevel = Common.DebugMode.AutoDetect;
DebugLevel = DebugMode.AutoDetect;
}
public string ToString(int i)
+1 -1
View File
@@ -8,7 +8,7 @@ namespace TBF.Rig.Network.Camera.CLP1611
{
public class Factory : IComponentFactory
{
public string ClassName { get { return this.GetType().Namespace.Substring(8); } }
public string ClassName { get { return GetType().Namespace.Substring(8); } }
public override string ToString() { return ClassName; }
public IComponent DummyComponent() { return new Camera(); }
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics;
using log4net;
using Common;
using TBF.Rig.Network.Telnet;
namespace TBF.Rig.Network.Camera.CLP1611
@@ -34,7 +35,7 @@ namespace TBF.Rig.Network.Camera.CLP1611
public Event Run()
{
if (camera.CameraCfg.DebugLevel == Common.DebugMode.Simulate) return Event.None;
if (camera.CameraCfg.DebugLevel == DebugMode.Simulate) return Event.None;
log.DebugFormat("Run(): telnet.State = {0}, liveStreamCommandSent = {1}", telnet.State, liveStreamCommandSent);
@@ -53,7 +54,7 @@ namespace TBF.Rig.Network.Camera.CLP1611
public void Stop()
{
if (camera.CameraCfg.DebugLevel == Common.DebugMode.Simulate) return;
if (camera.CameraCfg.DebugLevel == DebugMode.Simulate) return;
log.DebugFormat("Stop(): telnet.State = {0}, liveStreamCommandSent = {1}", telnet.State, liveStreamCommandSent);