5703 lines
217 KiB
C#
5703 lines
217 KiB
C#
|
|
using AForge.Imaging;
|
|||
|
|
using Google.Apis.Auth.OAuth2;
|
|||
|
|
using Google.Apis.Services;
|
|||
|
|
using Google.Apis.Sheets.v4;
|
|||
|
|
using Google.Apis.Sheets.v4.Data;
|
|||
|
|
using Google.Apis.Util.Store;
|
|||
|
|
using HDIPMk2Streaming;
|
|||
|
|
using LibVLCSharp.Shared;
|
|||
|
|
using LibVLCSharp.WinForms;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Diagnostics;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.Globalization;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.IO.Ports;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Net;
|
|||
|
|
using System.Net.NetworkInformation;
|
|||
|
|
using System.Net.Sockets;
|
|||
|
|
using System.Reflection;
|
|||
|
|
using System.Security.Principal;
|
|||
|
|
using System.ServiceModel.Discovery;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Text.RegularExpressions;
|
|||
|
|
using System.Threading;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
using Application = System.Windows.Forms.Application;
|
|||
|
|
using Color = System.Drawing.Color;
|
|||
|
|
using DateTime = System.DateTime;
|
|||
|
|
using IPAddress = System.Net.IPAddress;
|
|||
|
|
|
|||
|
|
namespace RapierCommand1
|
|||
|
|
{
|
|||
|
|
public partial class frmRapierCmd : Form
|
|||
|
|
{
|
|||
|
|
static readonly UdpClient sendClientANPR = new UdpClient();
|
|||
|
|
static readonly UdpClient sendClientOV = new UdpClient();
|
|||
|
|
static readonly UdpClient clRx = new UdpClient();
|
|||
|
|
|
|||
|
|
static IPEndPoint groupEp;
|
|||
|
|
static IPEndPoint RemoteIpEndPoint;
|
|||
|
|
|
|||
|
|
static IPEndPoint localEPANPR = new IPEndPoint(IPAddress.Any, 0); // this is used in the async recv callback
|
|||
|
|
static IPEndPoint localEPOV = new IPEndPoint(IPAddress.Any, 0); // this is used in the async recv callback
|
|||
|
|
static IPEndPoint remoteEPANPR = new IPEndPoint(IPAddress.Any, 0); // this is the address and port of the ITX encoder here
|
|||
|
|
static IPEndPoint remoteEPOV = new IPEndPoint(IPAddress.Any, 0); // this is the address and port of the ITX encoder here
|
|||
|
|
|
|||
|
|
readonly LibVLC libVLC = new LibVLC();
|
|||
|
|
|
|||
|
|
public static readonly Regex RegexIPPattern = new Regex(@"^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}|6[0-4][0-9]{3}|[1-5][0-9]{4}|[0-9]{1,4}))?$", RegexOptions.Compiled); // IP Regex with optional port extension
|
|||
|
|
public static readonly Regex RegexVISCA = new Regex(@"^81(( [0-9A-Fa-f]{2})+)? FF$", RegexOptions.Compiled); // VISCA Regex
|
|||
|
|
|
|||
|
|
Point LastLoc = new Point(0, 0);
|
|||
|
|
|
|||
|
|
readonly Color BtnColour = Color.FromArgb(192, 255, 255);
|
|||
|
|
|
|||
|
|
enum SelectedCam
|
|||
|
|
{
|
|||
|
|
NONE,
|
|||
|
|
ANPR,
|
|||
|
|
OVERVIEW
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
enum Module
|
|||
|
|
{
|
|||
|
|
NONE,
|
|||
|
|
KTnC,
|
|||
|
|
HZ5512,
|
|||
|
|
HZ5510,
|
|||
|
|
MC105
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
enum EncoderManufacturer
|
|||
|
|
{
|
|||
|
|
NONE,
|
|||
|
|
MLVInew,
|
|||
|
|
MLVIold,
|
|||
|
|
KTnC,
|
|||
|
|
IONODES,
|
|||
|
|
IONODES_AVML
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SelectedCam CameraSelected = SelectedCam.NONE;
|
|||
|
|
Module CameraModule = Module.NONE;
|
|||
|
|
EncoderManufacturer Encoder = EncoderManufacturer.NONE;
|
|||
|
|
|
|||
|
|
int monitorCount = 0;
|
|||
|
|
int noOfExpectedResonses = 1;
|
|||
|
|
int noOfOnvifResponses = 0;
|
|||
|
|
int TimeoutCounter = 0;
|
|||
|
|
readonly int sizedif = 350;
|
|||
|
|
|
|||
|
|
public static bool CorrectPassword = false;
|
|||
|
|
public static bool MAVCopy = false;
|
|||
|
|
|
|||
|
|
bool selectedCamera = false;
|
|||
|
|
bool cancelMonitor = false;
|
|||
|
|
bool getReplyFlg = false;
|
|||
|
|
bool monitorOnFlg = false;
|
|||
|
|
bool CamsFound = false;
|
|||
|
|
bool rxDataUdpTimeout = false;
|
|||
|
|
bool AdvancedOpen = false;
|
|||
|
|
bool FullscreenANPR = false;
|
|||
|
|
bool FullscreenOV = false;
|
|||
|
|
bool LVOV = false;
|
|||
|
|
bool LVANPR = false;
|
|||
|
|
bool TibboOnline = true;
|
|||
|
|
bool DefConfig = false;
|
|||
|
|
bool IsRMA = false;
|
|||
|
|
bool InProgress = false;
|
|||
|
|
bool VISCAInReply = false;
|
|||
|
|
bool OVstartup = true;
|
|||
|
|
bool ANPRstartup = true;
|
|||
|
|
bool WWSave = false;
|
|||
|
|
bool starting = true;
|
|||
|
|
|
|||
|
|
string rxBuffer;
|
|||
|
|
string rxMssg = "";
|
|||
|
|
string rxMssg2 = "";
|
|||
|
|
string rxMssgVISCA = "";
|
|||
|
|
string IrisLimitHex;
|
|||
|
|
string CamIP;
|
|||
|
|
string newSerialNumberString;
|
|||
|
|
string SoftwareVer;
|
|||
|
|
string selectedPort = "";
|
|||
|
|
string OVStreamUrl = "NONE";
|
|||
|
|
string ANPRStreamUrl = "NONE";
|
|||
|
|
string GUIVersion = Convert.ToString(Assembly.GetExecutingAssembly().GetName().Version);
|
|||
|
|
|
|||
|
|
static readonly string EncoderSoftVer = "A100.11031.00";
|
|||
|
|
|
|||
|
|
public static string TxtFileDir = @"C:\ProgramData\MAV\R50_HD_IP\";
|
|||
|
|
|
|||
|
|
readonly string[] onvifDevices = new string[128]; // allows up to 128 encoders to be found on 1 network segment
|
|||
|
|
|
|||
|
|
readonly string MadeInGb = "^^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR2,2~SD15^JUS^LRN^CI0^XZ" +
|
|||
|
|
"~DG000.GRF,00768,008," +
|
|||
|
|
",:::::::::::::::::::::::::::::::J0H7L037,I07FF0J01FF80H01DHDK05DD80H03FHFK0IF80H0J7J037H7,H0JFJ07FHF8001DD80J0HDC0,03FE0J01FF,0770K0176,0FF0K03FC,0DC0K05D8,1FC0K07F0,1740K0760,1F80K0FE0,1D80K0DC0,3F0L0FC0,370L0740,3F0K01FIF8,1D0K01DID8,3F0K01FIF8,370K017I70,3F0K01FIF8,1D0L0JD8,3F0L0FC0,370L0740,1F80K0FE0,1DC0K05C0,1FC0K07F0,0760K0H70,0FF0K03FC,05D80J01DC,03FC0J01FF,01770K0H740,01FHF10I07FHF80H0JDJ01DHD80H03FHFJ01FHF80H017H7K0I7,I07FF0J03FF80I01DD0K05D80K020L02,,:::::::::::::::::::::::~DG001.GRF,00768,008," +
|
|||
|
|
",::::::::::::::::::::::::H010,H010O02,I080N04,I040N08,I020H07FC0010,I01007F0F8020,I0180E1F8D840,J0C1E0H03C80,J027FJFD,J0310I0H2,J0190I024,K0D0I06C,K070I074,K0380H068,K0180H064,K0180H0FC,K01C1FD60,L0A1FE60,L0900440,L0H80840,L0841040,L0822040,L0814040,L0808040,L0C1C040,L0C320C0,L0C630C0,L0HC18C0,L05804C0,L0700680,L0600380,L0C00180,K01D0H0C0,K0340H0C0,K064003E0,K0C400630,J0184005B8,J0304005B4,J0207FFE32,J0C03003E1,I01803001C080,I010M0C0,I020M060,I040M010,I080M010,,::::::::I01FMFE0,::::::::,:::::::~DG002.GRF,01536,024," +
|
|||
|
|
",I03FE1FHFCFFE07C00F807E00FFC00FHFE03F1F00F0,I03FF1FHFCFFE07E01F807F00FHF80FHFE03F1F80F0,I03FF8FHFCFFE07F01F807F00FHFE0FHFE03F1FC0F0,I03FFC7FFCFFE07F03F80FF80FIF0FHFE03F1FC0F0,I03FFE3FFCFFE07F87F80FF80FIF8FHFE03F1FE0F0,I03FHF1FFCFFE07FCFF81FF80F87F8FC0H03F1FF0F0,I03FHF8FFCFFE07FIF81FFC0F81F8FC0H03F1FF8F0,I03FHFC7FCFFE07FIF81F7C0F80FCFHFC03F1FFCF0,I03FHFE3FCFFE07FIF83F7E0F80FCFHFC03F1FFCF0,I01FIF1FCFFE07FFEF83E7E0F80FCFHFC03F1FFEF0,J0JF8FCFFE07DFEF83E3E0F80FCFHFC03F1F7FF0,J07FHFC7CFFE07CFCF87FHF0F80FCFHFC03F1F3FF0,J03FHFE3CFFE07C00F87FHF0F81F8FC0H03F1F1FF0,I031FIF1CFFE07C00F8FIF8F83F8FC0H03F1F0FF0,I038FIF8CFFE07C00F8FIF8FIF8FHFE03F1F0FF0,I03C7FHFC0FFE07C00F8FIF8FIF0FHFE03F1F07F0,I03E3FHFE0FFE07C00F9F80FCFHFE0FHFE03F1F03F0,I03F1FIF0FFE07C00F9F80FCFHFC0FHFE03F1F01F0,I03F8FIF8FFE07C00F9F007CFFC00FHFE03F1F00F0,I03FC7FHFCFFE,I03FE3FHFEFFE,I03FF1FKFE,I03FF8FKFE07FF80FHFH0FCFIF83F803E1F00F0,I03FFC7FJFE07FFE0FHFE0FCFIF83F803E1F80F0,I03FFE3FJFE07FHF0FIF0FCFIF83F803E1FC0F0,I03FHF1FJFE07FHF0FIF0FCFIF87FC03E1FE0F0,I03FHF8" +
|
|||
|
|
"FJFE07FHF0FIF0FCFIF87FC03E1FF0F0,N07FIFE07C1F0FC3F0FC03E007FE03E1FF0F0,N03FIFE07C1F0FC1F0FC03E00FFE03E1FF8F0,N01FIFE07FHF0FC1F0FC03E00FBF03E1FFCF0,I03FNFE07FFE0FC3F0FC03E01FBF03E1FFEF0,I03FNFE07FHF0FIF0FC03E01F9F03E1F7EF0,I03FNFE07FHF8FHFE0FC03E01F1F83E1F3FF0,I03FNFE07C1F8FHFC0FC03E03FHF83E1F3FF0,I03FNFE07C0F8FHFC0FC03E03FHFC3E1F1FF0,I03FNFE07C1F8FCFE0FC03E03FHFC3E1F0FF0,I03FNFE07FHF8FC7E0FC03E07FHFC3E1F07F0,I03FNFE07FHF8FC3F0FC03E07FHFE3E1F03F0,I03FNFE07FHF0FC3F8FC03E0FC07E3E1F03F0,I03FNFE07FFE0FC1F8FC03E0FC03F3E1F01F0,,::::::::::::::::::::::^XA" +
|
|||
|
|
"^MMT" +
|
|||
|
|
"^PW384" +
|
|||
|
|
"^LL0096" +
|
|||
|
|
"^LS0" +
|
|||
|
|
"^FT224,96^XG000.GRF,1,1^FS+" +
|
|||
|
|
"^FT288,96^XG001.GRF,1,1^FS" +
|
|||
|
|
"^FT32,96^XG002.GRF,1,1^FS" +
|
|||
|
|
"^PQ1,0,1,Y^XZ" +
|
|||
|
|
"^XA^ID000.GRF^FS^XZ" +
|
|||
|
|
"^XA^ID001.GRF^FS^XZ" +
|
|||
|
|
"^XA^ID002.GRF^FS^XZ";
|
|||
|
|
|
|||
|
|
string GE67SALbl = "CT~~CD,~CC^~CT~" +
|
|||
|
|
"^XA ~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR2,2~SD30^JUS^LRN^CI0^XZ" +
|
|||
|
|
"^XA" +
|
|||
|
|
"^MMT" +
|
|||
|
|
"^PW320" +
|
|||
|
|
"^LL0096" +
|
|||
|
|
"^LS0" +
|
|||
|
|
@"^FT15,41^A0N,31,26^FH\^FDGE67SA-M3 SN:K1004XXX^FS" +
|
|||
|
|
@"^FT48,78^A0N,31,26^FH\^FDHD:IP Mk2 SW05/03^FS" +
|
|||
|
|
"^PQ1,0,1,Y^XZ";
|
|||
|
|
|
|||
|
|
string YT65JGLbl = "^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR2,2~SD15^JUS^LRN^CI0^XZ" + Environment.NewLine +
|
|||
|
|
"^XA" + Environment.NewLine +
|
|||
|
|
"^MMT" + Environment.NewLine +
|
|||
|
|
"^PW384" + Environment.NewLine +
|
|||
|
|
"^LL0096" + Environment.NewLine +
|
|||
|
|
"^LS0" + Environment.NewLine +
|
|||
|
|
"^FO256,0^GFA,01536,01536,00016,:Z64:" + Environment.NewLine +
|
|||
|
|
"eJzN072K20AQB/ARW6gRp1aCYL2CzDU2BJtUeQ2BC7cBF+eAyCpsiBuB2gSO82skTZAwRM1hv4LMQVRGxzYSLJ6sOa2+sFPfdD+W0ez+tQvw+ougoDe09B3MLhsMb+9XaIF32U74AYPZnSVqzx/X0iu79ceBabyY+P/xMsnwfuCwsRO+T2J8aOaBobtkRjv76xvFcnz/e9U5X8+yvIJWrBPJ0O9K+rxpVB02p4UW2ap/YJLz/CBSfiK1075hKuy9A+SX2dg6e6RsC+vLCMiDXvfr8RK8OT/GnvKfnmGe3bzRopN7xSPyFUBnP4zaM7I52xr4m1HPjw06R1hlt7Uz41PPVeG53jSwd8FlTwxLEGSlykv61LVr2NK7xgnPE6YXI5XP0EA3MU0Ky7xsmW8l7pAja1yeFtK7dl36qXFs5nJ+YN2+7JdkfUMVYLKVH1HzKjmtYzJ567tOwhEbr/v2S9dsDcizPUzDkQvKx66JJvSC6Azr/IY+H1iLdPaZZ623OtM6JlFreb/XyMC0H73Llu9jLCqmxVfshNSl+RMWteX7dGnKB5brmbL1LFKmHa6ajrcaHjv9PYNBtU3KvydBa5ZydZ9e/Jf/VEbhxIBRpf7nwK+p/gEmr4ir:A94D" + Environment.NewLine +
|
|||
|
|
"^FO0,0^GFA,01280,01280,00020,:Z64:" + Environment.NewLine +
|
|||
|
|
"eJztz7ENAyEMQFGjKygZgVFuNBiNUxbhdAsQpQgFwrFDlARwkzr3JTePAhvg/8LkMhisKoGOjTRS4BAv9PIyw+Zp9vI2y7bRXAvYMFiuvR3NVt9sDTaaI8OS3ce8DWyKzMG3JbLVS1Yns0GwrUxm9t54P/59NH0T7J4mW1Cy2BnfpgZLTwuTgWh+NicZnJ392gMKlLLa:A7F4" + Environment.NewLine +
|
|||
|
|
$"^FT159,84^A0N,25,24^FH\\^FDK1004XXX^FS" + Environment.NewLine +
|
|||
|
|
"^FT26,56^A0N,14,14^FH\\^FDModel:^FS" + Environment.NewLine +
|
|||
|
|
$"^FT159,32^A0N,25,28^FH\\^FDFHD:IP Mk2^FS" + Environment.NewLine +
|
|||
|
|
"^FT159,56^A0N,14,14^FH\\^FDSerial Number:^FS" + Environment.NewLine +
|
|||
|
|
$"^FT26,84^A0N,25,24^FH\\^FDYT65JG-M2^FS" + Environment.NewLine +
|
|||
|
|
"^PQ1,0,1,Y^XZ";
|
|||
|
|
|
|||
|
|
readonly byte[] viscaExpAuto = VISCACommand(0x04, 0x39, 0x00);
|
|||
|
|
readonly byte[] viscaExpShutter = VISCACommand(0x04, 0x39, 0x0A);
|
|||
|
|
readonly byte[] viscaExpManual = VISCACommand(0x04, 0x39, 0x03);
|
|||
|
|
readonly byte[] viscaInqExpMode = VISCAInquiry(0x04, 0x39);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaAutoIR = VISCACommand(0x04, 0x51, 0x02);
|
|||
|
|
readonly byte[] viscaManualIR = VISCACommand(0x04, 0x51, 0x03);
|
|||
|
|
readonly byte[] viscaIrDay = VISCACommand(0x04, 0x01, 0x03);
|
|||
|
|
readonly byte[] viscaIrNight = VISCACommand(0x04, 0x01, 0x02);
|
|||
|
|
readonly byte[] viscaInqIrMode = VISCAInquiry(0x04, 0x51);
|
|||
|
|
readonly byte[] viscaInqIrDayNight = VISCAInquiry(0x04, 0x01);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaFocusAuto = VISCACommand(0x04, 0x38, 0x02);
|
|||
|
|
readonly byte[] viscaFocusManual = VISCACommand(0x04, 0x38, 0x03);
|
|||
|
|
readonly byte[] viscaFocusNow = VISCACommand(0x04, 0x18, 0x01);
|
|||
|
|
readonly byte[] viscaInqFocusPos = VISCAInquiry(0x04, 0x48);
|
|||
|
|
readonly byte[] viscaInqFocusMode = VISCAInquiry(0x04, 0x38);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaInqZoomPos = VISCAInquiry(0x04, 0x47);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaShutterUp = VISCACommand(0x04, 0x0A, 0x02);
|
|||
|
|
readonly byte[] viscaShutterDown = VISCACommand(0x04, 0x0A, 0x03);
|
|||
|
|
readonly byte[] viscaInqShutter = VISCAInquiry(0x04, 0x4A);
|
|||
|
|
readonly byte[] viscaMinShutterOn = VISCACommand(0x04, 0x12, 0x02);
|
|||
|
|
readonly byte[] viscaMinShutterInq = VISCAInquiry(0x04, 0x13);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaIrisUp = VISCACommand(0x04, 0x0B, 0x02);
|
|||
|
|
readonly byte[] viscaIrisDown = VISCACommand(0x04, 0x0B, 0x03);
|
|||
|
|
readonly byte[] viscaInqIris = VISCAInquiry(0x04, 0x4B);
|
|||
|
|
readonly byte[] viscaInqIrisLim = VISCAInquiry(0x70, 0xD3);
|
|||
|
|
readonly byte[] viscaInqIrisLimWW = VISCAInquiry(0x05, 0x24, 0x4B, 0x01);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaGainUp = VISCACommand(0x04, 0x0C, 0x02);
|
|||
|
|
readonly byte[] viscaGainDown = VISCACommand(0x04, 0x0C, 0x03);
|
|||
|
|
readonly byte[] viscaInqGain = VISCAInquiry(0x04, 0x4C);
|
|||
|
|
readonly byte[] viscaInqGainLim = VISCAInquiry(0x04, 0x2C);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaSharpnessUp = VISCACommand(0x04, 0x02, 0x02);
|
|||
|
|
readonly byte[] viscaSharpnessDown = VISCACommand(0x04, 0x02, 0x03);
|
|||
|
|
readonly byte[] viscaInqSharpness = VISCAInquiry(0x04, 0x42);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaExpCompOn = VISCACommand(0x04, 0x3E, 0x02);
|
|||
|
|
readonly byte[] viscaExpCompOff = VISCACommand(0x04, 0x3E, 0x03);
|
|||
|
|
readonly byte[] viscaExpCompUp = VISCACommand(0x04, 0x0E, 0x02);
|
|||
|
|
readonly byte[] viscaExpCompDown = VISCACommand(0x04, 0x0E, 0x03);
|
|||
|
|
readonly byte[] viscaExpCompReset = VISCACommand(0x04, 0x0E, 0x00);
|
|||
|
|
readonly byte[] viscaInqExpCompMode = VISCAInquiry(0x04, 0x3E);
|
|||
|
|
readonly byte[] viscaInqExpComp = VISCAInquiry(0x04, 0x4E);
|
|||
|
|
|
|||
|
|
readonly byte[] visca720p25 = VISCACommand(0x04, 0x24, 0x72, 0x01, 0x01);
|
|||
|
|
readonly byte[] visca720p30 = VISCACommand(0x04, 0x24, 0x72, 0x00, 0x0F);
|
|||
|
|
readonly byte[] visca1080p25 = VISCACommand(0x04, 0x24, 0x72, 0x00, 0x08);
|
|||
|
|
readonly byte[] visca1080p30 = VISCACommand(0x04, 0x24, 0x72, 0x00, 0x07);
|
|||
|
|
readonly byte[] viscaQuery = VISCAInquiry(0x04, 0x24, 0x72);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaInqNR = VISCAInquiry(0x04, 0x53);
|
|||
|
|
readonly byte[] viscaInqNRWW = VISCAInquiry(0x05, 0x53);
|
|||
|
|
readonly byte[] viscaInqGamma = VISCAInquiry(0x04, 0x5B);
|
|||
|
|
readonly byte[] viscaInqContrast = VISCAInquiry(0x71, 0x40);
|
|||
|
|
readonly byte[] viscaInqContrastWW = VISCAInquiry(0x05, 0x5D);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaMirrorOn = VISCACommand(0x04, 0x61, 0x02);
|
|||
|
|
readonly byte[] viscaMirrorOff = VISCACommand(0x04, 0x61, 0x03);
|
|||
|
|
readonly byte[] viscaInqMirror = VISCAInquiry(0x04, 0x61);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaDISOn = VISCACommand(0x04, 0x34, 0x02);
|
|||
|
|
readonly byte[] viscaDISOff = VISCACommand(0x04, 0x34, 0x03);
|
|||
|
|
readonly byte[] viscaInqDIS = VISCAInquiry(0x04, 0x34);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaWDROn = VISCACommand(0x04, 0x3D, 0x02);
|
|||
|
|
readonly byte[] viscaWDROff = VISCACommand(0x04, 0x3D, 0x03);
|
|||
|
|
readonly byte[] viscaWDRInq = VISCAInquiry(0x04, 0x3D);
|
|||
|
|
readonly byte[] viscaWDRLevelInq = VISCAInquiry(0x70, 0x3A);
|
|||
|
|
readonly byte[] viscaWDROnWW = VISCACommand(0x04, 0x1A, 0x02);
|
|||
|
|
readonly byte[] viscaWDRManualWW = VISCACommand(0x04, 0x1A, 0x30, 0x00);
|
|||
|
|
readonly byte[] viscaWDROffWW = VISCACommand(0x04, 0x1A, 0x03);
|
|||
|
|
readonly byte[] viscaWDRInqWW = VISCAInquiry(0x04, 0x1A);
|
|||
|
|
readonly byte[] viscaWDRLvllInqDWW = VISCAInquiry(0x04, 0x1A, 0x40);
|
|||
|
|
readonly byte[] viscaWDRLvllInqBWW = VISCAInquiry(0x04, 0x1A, 0x50);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaFirmwareVer = VISCAInquiry(0x00, 0x02);
|
|||
|
|
readonly byte[] viscaFirmwareVerWW = VISCAInquiry(0x00, 0x37);
|
|||
|
|
|
|||
|
|
readonly byte[] viscaSaveWW = VISCACommand(0x04, 0x3F, 0x01, 0x7F);
|
|||
|
|
|
|||
|
|
public frmRapierCmd()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void frmRapierTest_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
// --- Version Handling ---
|
|||
|
|
int dotloaction = GUIVersion.IndexOf(".");
|
|||
|
|
if (dotloaction >= 0)
|
|||
|
|
{
|
|||
|
|
if (GUIVersion.Substring(dotloaction + 1, 1) == "0")
|
|||
|
|
{
|
|||
|
|
GUIVersion = GUIVersion.Substring(0, dotloaction);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
GUIVersion = GUIVersion.Substring(0, GUIVersion.IndexOf(".", dotloaction + 1));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateFirewall(GUIVersion); // Update firewall rules on first startup
|
|||
|
|
|
|||
|
|
// --- GUI Setup ---
|
|||
|
|
this.Text = "HD:IP GUI V" + GUIVersion;
|
|||
|
|
this.Width = 980;
|
|||
|
|
|
|||
|
|
Core.Initialize();
|
|||
|
|
|
|||
|
|
videoViewANPR.MediaPlayer = new MediaPlayer(libVLC);
|
|||
|
|
videoViewOV.MediaPlayer = new MediaPlayer(libVLC);
|
|||
|
|
|
|||
|
|
clRx.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
|
|||
|
|
clRx.Client.Bind(new IPEndPoint(IPAddress.Any, 52381));
|
|||
|
|
RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 52381);
|
|||
|
|
|
|||
|
|
TkBrGain.SendToBack();
|
|||
|
|
|
|||
|
|
GetPorts();
|
|||
|
|
|
|||
|
|
if (!Directory.Exists(TxtFileDir))
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(TxtFileDir);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
using (StreamWriter AL = File.AppendText($"{TxtFileDir}ActivityLog.txt"))
|
|||
|
|
{
|
|||
|
|
AL.WriteLine("GUI Opened " + DateTime.Now);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (File.Exists($"{TxtFileDir}COMInfo.txt"))
|
|||
|
|
{
|
|||
|
|
using (StreamReader fileSerial = new StreamReader($"{TxtFileDir}COMInfo.txt"))
|
|||
|
|
{
|
|||
|
|
string ComRead = fileSerial.ReadLine();
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
MAVCopy = Convert.ToBoolean(fileSerial.ReadLine());
|
|||
|
|
|
|||
|
|
if (MAVCopy)
|
|||
|
|
{
|
|||
|
|
AdvancedOpen = CorrectPassword = true;
|
|||
|
|
PicLogo_Click(sender, e);
|
|||
|
|
TxBxZebraIP_TextChanged(sender, e);
|
|||
|
|
TxBxPSUIP_TextChanged(sender, e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch { MAVCopy = false; }
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
TxBxPSUIP.Text = fileSerial.ReadLine();
|
|||
|
|
TxBxZebraIP.Text = fileSerial.ReadLine();
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
|
|||
|
|
openSerialIfPresent(serialPort1, ComRead, tsmenuSelectCom);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
tbxSend.Select();
|
|||
|
|
DiscoverEncoders(sender, e);
|
|||
|
|
starting = false;
|
|||
|
|
this.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void UpdateFirewall(string GUIVer)
|
|||
|
|
{
|
|||
|
|
WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
|
|||
|
|
bool runAsAdmin = wp.IsInRole(WindowsBuiltInRole.Administrator);
|
|||
|
|
string ExeLoc = Assembly.GetEntryAssembly().Location.Replace("dll", "exe"); // Sometimes trys to open the dll instead of exe
|
|||
|
|
|
|||
|
|
if (MAV_Rapier_HDIP.Properties.Settings.Default.FirstRun == true && !runAsAdmin) // On first run, put into admin mode to allow defender.
|
|||
|
|
{
|
|||
|
|
StartAsAdmin(ExeLoc);
|
|||
|
|
}
|
|||
|
|
else if (runAsAdmin)
|
|||
|
|
{
|
|||
|
|
// Use dynamic for COM interop
|
|||
|
|
Type ruleType = Type.GetTypeFromProgID("HNetCfg.FWRule");
|
|||
|
|
Type policyType = Type.GetTypeFromProgID("HNetCfg.FwPolicy2");
|
|||
|
|
dynamic firewallRule = Activator.CreateInstance(ruleType);
|
|||
|
|
dynamic firewallPolicy = Activator.CreateInstance(policyType);
|
|||
|
|
|
|||
|
|
firewallRule.ApplicationName = ExeLoc;
|
|||
|
|
firewallRule.Action = 1; // NET_FW_ACTION_ALLOW
|
|||
|
|
firewallRule.Description = "Programmatically added rule to allow the GUI to work";
|
|||
|
|
firewallRule.Enabled = true;
|
|||
|
|
firewallRule.InterfaceTypes = "All";
|
|||
|
|
firewallRule.Name = "HD:IP GUI " + GUIVer;
|
|||
|
|
firewallRule.Protocol = 17; // UDP
|
|||
|
|
|
|||
|
|
firewallPolicy.Rules.Add(firewallRule);
|
|||
|
|
|
|||
|
|
MAV_Rapier_HDIP.Properties.Settings.Default.FirstRun = false; //only false after defender rule been added.
|
|||
|
|
MAV_Rapier_HDIP.Properties.Settings.Default.Save();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static void StartAsAdmin(string ExeLoc)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
ProcessStartInfo processInfo = new ProcessStartInfo(ExeLoc)
|
|||
|
|
{
|
|||
|
|
UseShellExecute = true,
|
|||
|
|
Verb = "runas"
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Process.Start(processInfo);
|
|||
|
|
MAV_Rapier_HDIP.Properties.Settings.Default.FirstRun = false;
|
|||
|
|
MAV_Rapier_HDIP.Properties.Settings.Default.Save();
|
|||
|
|
Application.Exit(); // Exit now that we have admin rights version
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Sorry, but I don't seem to be able to start this program with administrator rights!");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
private void GetPorts()
|
|||
|
|
{
|
|||
|
|
string[] ports = SerialPort.GetPortNames();
|
|||
|
|
tsmenuSelectCom.DropDownItems.Clear();
|
|||
|
|
|
|||
|
|
foreach (string port in ports)
|
|||
|
|
{
|
|||
|
|
ToolStripMenuItem newitem = new ToolStripMenuItem
|
|||
|
|
{
|
|||
|
|
Text = port
|
|||
|
|
};
|
|||
|
|
tsmenuSelectCom.DropDownItems.Add(newitem);
|
|||
|
|
}
|
|||
|
|
serialPort1.NewLine = ">";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void frmRapierTest_FormClosing(object sender, FormClosingEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (serialPort1.IsOpen)
|
|||
|
|
{
|
|||
|
|
string[] lines = { serialPort1.PortName, MAVCopy.ToString(), TxBxPSUIP.Text, TxBxZebraIP.Text };
|
|||
|
|
File.WriteAllLines($"{TxtFileDir}COMInfo.txt", lines);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (serialPort1.IsOpen == true)
|
|||
|
|
{
|
|||
|
|
serialPort1.Close();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Environment.Exit(Environment.ExitCode);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void openSerialIfPresent(SerialPort serialPort, string ComCompare, ToolStripMenuItem toolStrip)
|
|||
|
|
{
|
|||
|
|
bool portFound = false;
|
|||
|
|
|
|||
|
|
if (ComCompare == "null" || ComCompare.Length < 4)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (ToolStripMenuItem item in toolStrip.DropDownItems) // clear currently checked items
|
|||
|
|
{
|
|||
|
|
if (item.Text == ComCompare)
|
|||
|
|
{
|
|||
|
|
item.Checked = true;
|
|||
|
|
selectedPort = serialPort.PortName;
|
|||
|
|
serialPort.PortName = ComCompare;
|
|||
|
|
portFound = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
item.Checked = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (portFound == true)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
serialPort.Open();
|
|||
|
|
toolStrip.BackColor = Color.LightGreen;
|
|||
|
|
tsmenuSelectCom.Text = "Using Com " + serialPort1.PortName;
|
|||
|
|
btnClosePort.Text = "Close Port";
|
|||
|
|
|
|||
|
|
SendCmd("CK0", 1);
|
|||
|
|
|
|||
|
|
if (rxMssg.Contains("CK0"))
|
|||
|
|
{
|
|||
|
|
TibboOnline = true;
|
|||
|
|
EnableTibboControls();
|
|||
|
|
BtnANPR.BackColor = Color.LightGreen;
|
|||
|
|
BtnOV.BackColor = BtnColour;
|
|||
|
|
CameraSelected = SelectedCam.ANPR;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
foreach (ToolStripMenuItem item in toolStrip.DropDownItems) // Clear currently checked items
|
|||
|
|
{
|
|||
|
|
item.Checked = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (ComCompare != "null")
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Saved " + ComCompare + " not available");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
btnClosePort.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Saved " + ComCompare + " not found");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void tsmenuSelectCom_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
|||
|
|
{
|
|||
|
|
stopLedMonitor();
|
|||
|
|
|
|||
|
|
string clickeditem = e.ClickedItem.Text;
|
|||
|
|
|
|||
|
|
if (serialPort1.IsOpen == true)
|
|||
|
|
{
|
|||
|
|
serialPort1.Close();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
serialPort1.PortName = clickeditem;
|
|||
|
|
|
|||
|
|
foreach (ToolStripMenuItem item in tsmenuSelectCom.DropDownItems) // clear currently checked items
|
|||
|
|
{
|
|||
|
|
if (item.Text == clickeditem)
|
|||
|
|
{
|
|||
|
|
item.Checked = true;
|
|||
|
|
selectedPort = serialPort1.PortName;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
item.Checked = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
serialPort1.Open();
|
|||
|
|
|
|||
|
|
tsmenuSelectCom.BackColor = Color.LightGreen;
|
|||
|
|
tsmenuSelectCom.Text = "Using Com " + serialPort1.PortName;
|
|||
|
|
btnClosePort.Text = "Close Port";
|
|||
|
|
|
|||
|
|
SendCmd("CK0", 1);
|
|||
|
|
if (rxMssg.Contains("CK0"))
|
|||
|
|
{
|
|||
|
|
TibboOnline = true;
|
|||
|
|
EnableTibboControls();
|
|||
|
|
BtnANPR.BackColor = Color.LightGreen;
|
|||
|
|
BtnOV.BackColor = BtnColour;
|
|||
|
|
CameraSelected = SelectedCam.ANPR;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string[] lines = { serialPort1.PortName, MAVCopy.ToString(), TxBxPSUIP.Text, TxBxZebraIP.Text };
|
|||
|
|
File.WriteAllLines($"{TxtFileDir}COMInfo.txt", lines);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
foreach (ToolStripMenuItem item in tsmenuSelectCom.DropDownItems) // Clear currently checked items
|
|||
|
|
{
|
|||
|
|
item.Checked = false;
|
|||
|
|
}
|
|||
|
|
tsmenuSelectCom.BackColor = BtnColour;
|
|||
|
|
tsmenuSelectCom.Text = "Port select";
|
|||
|
|
btnClosePort.BackColor = BtnColour;
|
|||
|
|
MessageBox.Show("Port " + clickeditem + " not available", "Port select");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void SendCmd(string message, int NOER)
|
|||
|
|
{
|
|||
|
|
noOfExpectedResonses = NOER;
|
|||
|
|
|
|||
|
|
if (serialPort1.IsOpen == false)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Please select port first", "Port select");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
rxMssg = rxMssg2 = "";
|
|||
|
|
|
|||
|
|
timerTimeout.Enabled = false;
|
|||
|
|
timerTimeout.Enabled = true; // Start timeout rx data counter now
|
|||
|
|
|
|||
|
|
serialPort1.WriteLine("<" + message + "/"); // '>' is newline char so don't add to writeline message
|
|||
|
|
getReplyFlg = true;
|
|||
|
|
richTxBxRxCmd.SelectionColor = Color.Red;
|
|||
|
|
richTxBxRxCmd.AppendText(">> <" + message + "/>" + Environment.NewLine);
|
|||
|
|
richTxBxRxCmd.SelectionStart = richTxBxRxCmd.Text.Length;
|
|||
|
|
richTxBxRxCmd.ScrollToCaret();
|
|||
|
|
|
|||
|
|
if (message.Contains("#8"))
|
|||
|
|
{
|
|||
|
|
VISCAInReply = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
while (noOfExpectedResonses != 0) // wait for all replies here
|
|||
|
|
{
|
|||
|
|
Application.DoEvents();
|
|||
|
|
Thread.Sleep(10);
|
|||
|
|
|
|||
|
|
if (timerTimeout.Enabled == false) // or until timout expires
|
|||
|
|
{
|
|||
|
|
getReplyFlg = false;
|
|||
|
|
richTxBxRxCmd.SelectionColor = Color.Red;
|
|||
|
|
richTxBxRxCmd.AppendText("<< no reply" + Environment.NewLine);
|
|||
|
|
richTxBxRxCmd.SelectionStart = richTxBxRxCmd.Text.Length;
|
|||
|
|
richTxBxRxCmd.ScrollToCaret();
|
|||
|
|
rxMssg = "no reply";
|
|||
|
|
|
|||
|
|
if (monitorOnFlg == true && chkBxContErr.Checked == false)
|
|||
|
|
{
|
|||
|
|
cancelMonitor = true;
|
|||
|
|
lblMonFail.Visible = true;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
noOfExpectedResonses = 1;
|
|||
|
|
WaitMs(100);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void checkRxMessage(TextBox txBxResult)
|
|||
|
|
{
|
|||
|
|
if (rxMssg.Contains(">"))
|
|||
|
|
{
|
|||
|
|
int startPos = rxMssg.IndexOf("@");
|
|||
|
|
int endPos = rxMssg.IndexOf(">");
|
|||
|
|
if (endPos > startPos)
|
|||
|
|
{
|
|||
|
|
int trimLength = endPos - startPos;
|
|||
|
|
txBxResult.Text = rxMssg.Substring(startPos + 1, trimLength - 2);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
rxBuffer = serialPort1.ReadLine();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("COM port error " + ex);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.Invoke(new EventHandler(DoRxMssg)); // message received so deal with it
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void DoRxMssg(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
rxBuffer = rxBuffer.Substring(rxBuffer.IndexOf("<")) + ">";
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Reply in incorrect format, does not contain '<'" + Environment.NewLine + "Reply: " + rxBuffer);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (getReplyFlg == true)
|
|||
|
|
{
|
|||
|
|
richTxBxRxCmd.SelectionColor = Color.Green;
|
|||
|
|
|
|||
|
|
switch (noOfExpectedResonses)
|
|||
|
|
{
|
|||
|
|
case 2:
|
|||
|
|
rxMssg2 = rxBuffer; // this will hold the second rx message
|
|||
|
|
richTxBxRxCmd.AppendText("<< " + rxMssg2 + Environment.NewLine);
|
|||
|
|
break;
|
|||
|
|
case 1:
|
|||
|
|
rxMssg = rxBuffer; //this will hold the first rx message
|
|||
|
|
richTxBxRxCmd.AppendText("<< " + rxMssg + Environment.NewLine);
|
|||
|
|
|
|||
|
|
if (VISCAInReply == true)
|
|||
|
|
{
|
|||
|
|
rxMssgVISCA = rxBuffer;
|
|||
|
|
VISCAInReply = false;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
TxBxRxErrMssg.AppendText(rxBuffer + Environment.NewLine); // unsolicited reply so add to box
|
|||
|
|
TxBxRxErrMssg.SelectionStart = TxBxRxErrMssg.Text.Length;
|
|||
|
|
TxBxRxErrMssg.ScrollToCaret();
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
noOfExpectedResonses--;
|
|||
|
|
|
|||
|
|
if (noOfExpectedResonses == 0)
|
|||
|
|
{
|
|||
|
|
getReplyFlg = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
richTxBxRxCmd.SelectionStart = richTxBxRxCmd.Text.Length;
|
|||
|
|
richTxBxRxCmd.ScrollToCaret();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (rxBuffer.Contains("frame"))
|
|||
|
|
{
|
|||
|
|
TxBxRxErrMssg.AppendText(rxBuffer + " " + DateTime.Now.ToString("hh:mm:ss") + Environment.NewLine); // unsolicited reply so add to box
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
TxBxRxErrMssg.AppendText(rxBuffer + Environment.NewLine); // unsolicited reply so add to box
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TxBxRxErrMssg.SelectionStart = TxBxRxErrMssg.Text.Length;
|
|||
|
|
TxBxRxErrMssg.ScrollToCaret();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (rxBuffer == "<NCy/>")
|
|||
|
|
{
|
|||
|
|
btnIllumOn.BackColor = Color.LightGreen;
|
|||
|
|
btnIllumOff.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
else if (rxBuffer == "<NCn/>")
|
|||
|
|
{
|
|||
|
|
btnIllumOff.BackColor = Color.LightGreen;
|
|||
|
|
btnIllumOn.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
else if ((AdvancedOpen == true || MAVCopy == true) && (rxBuffer.Contains("<LedISet@") || rxBuffer.Contains("<NC@")))
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
TxBxLEDCurrent.Text = rxBuffer.Substring(rxBuffer.IndexOf("@") + 1, 4) + "A";
|
|||
|
|
TkBarLED.Value = Convert.ToInt16(Convert.ToDouble(rxBuffer.Substring(rxBuffer.IndexOf("@") + 1, 4)) * 10);
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void timerTimeout_Tick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
timerTimeout.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnIllumOn_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
pauseMonitor();
|
|||
|
|
SendCmd("NCy", 1);
|
|||
|
|
checkRestartMonitor();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnIllumOff_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
pauseMonitor();
|
|||
|
|
SendCmd("NCn", 1);
|
|||
|
|
checkRestartMonitor();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnSend_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendCmd(tbxSend.Text, 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnClearList_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
richTxBxRxCmd.Text = "";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnClrRxErrMssg_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
TxBxRxErrMssg.Text = "";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnClosePort_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
stopLedMonitor();
|
|||
|
|
|
|||
|
|
richTxBxRxCmd.Text = TxBxRxErrMssg.Text = "";
|
|||
|
|
btnIllumOn.BackColor = btnIllumOff.BackColor = BtnColour;
|
|||
|
|
|
|||
|
|
if (serialPort1.IsOpen)
|
|||
|
|
{
|
|||
|
|
serialPort1.Close();
|
|||
|
|
btnClosePort.BackColor = BtnColour;
|
|||
|
|
btnClosePort.Text = "Open Last Port";
|
|||
|
|
foreach (ToolStripMenuItem item in tsmenuSelectCom.DropDownItems) // clear currently checked items
|
|||
|
|
{
|
|||
|
|
item.Checked = false;
|
|||
|
|
}
|
|||
|
|
GetPorts();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (selectedPort == "")
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("No port selected", "Port select");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (ToolStripMenuItem item in tsmenuSelectCom.DropDownItems)
|
|||
|
|
{
|
|||
|
|
if (item.Text == selectedPort)
|
|||
|
|
{
|
|||
|
|
item.Checked = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
item.Checked = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
btnClosePort.Text = "Close Port";
|
|||
|
|
btnClosePort.BackColor = Color.LightGreen;
|
|||
|
|
serialPort1.Open();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void tbxSend_KeyDown(object sender, KeyEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.KeyValue == 13 && tbxSend.Text != "")
|
|||
|
|
{
|
|||
|
|
SendCmd(tbxSend.Text, 1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void WaitMs(int waittime)
|
|||
|
|
{
|
|||
|
|
timerWait.Interval = waittime;
|
|||
|
|
timerWait.Enabled = true;
|
|||
|
|
|
|||
|
|
while (timerWait.Enabled == true)
|
|||
|
|
{
|
|||
|
|
Application.DoEvents();
|
|||
|
|
Thread.Sleep(10);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void timerWait_Tick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
timerWait.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void pauseMonitor()
|
|||
|
|
{
|
|||
|
|
if (monitorOnFlg == true)
|
|||
|
|
{
|
|||
|
|
cancelMonitor = true; // stop monitor from running again
|
|||
|
|
timerMonitor.Enabled = false;
|
|||
|
|
WaitMs(500);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void checkRestartMonitor()
|
|||
|
|
{
|
|||
|
|
if (monitorOnFlg == true)
|
|||
|
|
{
|
|||
|
|
cancelMonitor = false; // start monitor running again
|
|||
|
|
timerMonitor.Enabled = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CheckEncoderManufacturer()
|
|||
|
|
{
|
|||
|
|
BtnDefConfig.Enabled = true;
|
|||
|
|
string EncoderFWVer = CheckEncoderFirmwareVer(CamIP);
|
|||
|
|
|
|||
|
|
if (EncoderFWVer.Contains("A100"))
|
|||
|
|
{
|
|||
|
|
Encoder = EncoderManufacturer.MLVInew;
|
|||
|
|
}
|
|||
|
|
else if (EncoderFWVer.Contains("89100"))
|
|||
|
|
{
|
|||
|
|
Encoder = EncoderManufacturer.MLVIold;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://" + CamIP + "/system_update.html");
|
|||
|
|
request.Credentials = new NetworkCredential("admin", "admin");
|
|||
|
|
StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.ASCII);
|
|||
|
|
|
|||
|
|
if (reader.ReadToEnd().Contains("ACE-HEN6338-iL"))
|
|||
|
|
{
|
|||
|
|
Encoder = EncoderManufacturer.KTnC;
|
|||
|
|
BtnDefConfig.Enabled = false;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
CheckIONodes(); // replies but not including the correct part number included so could be a different manufacturer
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
CheckIONodes(); // API call failed so could be a differnet manufacturer
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Encoder == EncoderManufacturer.MLVInew || Encoder == EncoderManufacturer.MLVIold)
|
|||
|
|
{
|
|||
|
|
BtnSetH264.Enabled = BtnSetMJPEGANPR.Enabled = BtnSetIPANPR.Enabled = BtnSetIPOV.Enabled = BtnFinalTest.Enabled = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
BtnSetH264.Enabled = BtnSetMJPEGANPR.Enabled = BtnSetIPANPR.Enabled = BtnSetIPOV.Enabled = BtnFinalTest.Enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CheckIONodes()
|
|||
|
|
{
|
|||
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://" + CamIP + "/services/system.ion?sel=echo&foo=bar");
|
|||
|
|
request.Credentials = new NetworkCredential("admin", "admin");
|
|||
|
|
StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.ASCII);
|
|||
|
|
|
|||
|
|
if (reader.ReadToEnd().Contains("ionrsp stat=\"ok\""))
|
|||
|
|
{
|
|||
|
|
Encoder = EncoderManufacturer.IONODES;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// Unknown encoder type
|
|||
|
|
MessageBox.Show("Cannot determine encoder type, is webpage active? Have you tried a power cycle?" + Environment.NewLine + "If issue persists please contact manufacturer");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnANPR_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
pauseMonitor();
|
|||
|
|
this.Enabled = false;
|
|||
|
|
richTxBxRxCmd.Clear();
|
|||
|
|
TxBxRxErrMssg.Clear();
|
|||
|
|
TxBxRecManVISCA.Clear();
|
|||
|
|
anprSelect(); // Also checks encoder and camera module
|
|||
|
|
|
|||
|
|
CamSetup(sender, e);
|
|||
|
|
|
|||
|
|
if (TibboOnline)
|
|||
|
|
{
|
|||
|
|
SendCmd("NC?", 1);
|
|||
|
|
checkRestartMonitor();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnOV_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
pauseMonitor();
|
|||
|
|
this.Enabled = false;
|
|||
|
|
TxBxRecManVISCA.Clear();
|
|||
|
|
ovSelect(); // Also checks encoder and camera module
|
|||
|
|
|
|||
|
|
CamSetup(sender, e);
|
|||
|
|
checkRestartMonitor();
|
|||
|
|
this.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CamSetup(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (Encoder == EncoderManufacturer.IONODES || Encoder == EncoderManufacturer.IONODES_AVML)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
if (richTxBxRxCmd.Text.Contains("no reply") || TxBxRxErrMssg.Text.Contains("no reply"))
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Tibbo not connected to VSP");
|
|||
|
|
TibboOnline = false;
|
|||
|
|
DisableTibboControls();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
gpBxCamControl.Enabled = GpBxAddCrtls.Enabled = GpBxAdCont.Enabled = GpBxMins.Enabled = true;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqZoomPos, 4, txBxZoom, false, "ZO?", 1);
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
trackBarZoom.Value = Convert.ToInt32(txBxZoom.Text, 16);
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
|
|||
|
|
SendVISCA(viscaInqFocusPos, 4, txBxFocus, false, "FF?", 1);
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
trackBarFocus.Value = Convert.ToInt32(txBxFocus.Text, 16);
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
|
|||
|
|
SendVISCA(viscaInqFocusMode, 2, TxBxReply, false, "FM?", 1);
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.Contains("2") || TxBxReply.Text.Contains("a"))
|
|||
|
|
{
|
|||
|
|
BtnFocusAuto.BackColor = Color.LightGreen;
|
|||
|
|
BtnFocusMan.BackColor = BtnColour;
|
|||
|
|
BtnFocusNeg.Enabled = BtnFocusPlus.Enabled = txBxFocus.Enabled = trackBarFocus.Enabled = TxBxFocus2.Enabled = false;
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("3") || TxBxReply.Text.Contains("m"))
|
|||
|
|
{
|
|||
|
|
BtnFocusMan.BackColor = Color.LightGreen;
|
|||
|
|
BtnFocusAuto.BackColor = BtnColour;
|
|||
|
|
BtnFocusNeg.Enabled = BtnFocusPlus.Enabled = txBxFocus.Enabled = trackBarFocus.Enabled = TxBxFocus2.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TxBxExpComp_Click(sender, e);
|
|||
|
|
SendVISCA(viscaInqExpCompMode, 2, TxBxReply, false);
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.Contains("2"))
|
|||
|
|
{
|
|||
|
|
BtnExpCompOn.BackColor = Color.LightGreen;
|
|||
|
|
BtnExpCompOff.BackColor = BtnColour;
|
|||
|
|
BtnBrightnessReset.Enabled = BtnExpCompDown.Enabled = BtnExpCompUp.Enabled = TxBxExpComp.Enabled = true;
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("3"))
|
|||
|
|
{
|
|||
|
|
BtnExpCompOff.BackColor = Color.LightGreen;
|
|||
|
|
BtnExpCompOn.BackColor = BtnColour;
|
|||
|
|
BtnBrightnessReset.Enabled = BtnExpCompDown.Enabled = BtnExpCompUp.Enabled = TxBxExpComp.Enabled = false;
|
|||
|
|
TxBxExpComp.Text = "-";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
BtnExpCompOff_Click(sender, e);
|
|||
|
|
BtnExpCompOff.BackColor = Color.LightGreen;
|
|||
|
|
BtnExpCompOn.BackColor = BtnColour;
|
|||
|
|
BtnBrightnessReset.Enabled = BtnExpCompDown.Enabled = BtnExpCompUp.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaWDRInqWW, 1, TxBxReply, false);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaWDRInq, 2, TxBxReply, false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.Contains("2"))
|
|||
|
|
{
|
|||
|
|
BtnWDROn.BackColor = Color.LightGreen;
|
|||
|
|
BtnWDROff.BackColor = SystemColors.ControlLightLight;
|
|||
|
|
BtnWDRLvlDown.Enabled = BtnWDRLvlUp.Enabled = true;
|
|||
|
|
BtnBrightnessReset.Enabled = BtnExpCompDown.Enabled = BtnExpCompOff.Enabled = BtnExpCompOn.Enabled =
|
|||
|
|
BtnExpCompUp.Enabled = TxBxExpComp.Enabled = btnIrisClose.Enabled = txBxIris.Enabled =
|
|||
|
|
btnIrisUp.Enabled = BtnGainDown.Enabled = txBxGain.Enabled = BtnGainUp.Enabled =
|
|||
|
|
BtnShutterDown.Enabled = txBxShutter.Enabled = BtnShutterUp.Enabled = false;
|
|||
|
|
txBxIris.Text = txBxGain.Text = txBxShutter.Text = "-";
|
|||
|
|
BtnExpManual.BackColor = BtnExpShtrPri.BackColor = BtnAutoExp.BackColor = BtnColour;
|
|||
|
|
|
|||
|
|
TxBxWDRLvl_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
BtnWDROff.BackColor = Color.LightGreen;
|
|||
|
|
BtnWDROn.BackColor = SystemColors.ControlLightLight;
|
|||
|
|
BtnWDRLvlDown.Enabled = BtnWDRLvlUp.Enabled = false;
|
|||
|
|
TxBxWDRLvl.Text = "-";
|
|||
|
|
BtnBrightnessReset.Enabled = BtnExpCompDown.Enabled = BtnExpCompOff.Enabled =
|
|||
|
|
BtnExpCompOn.Enabled = BtnExpCompUp.Enabled = TxBxExpComp.Enabled = true;
|
|||
|
|
|
|||
|
|
SendVISCA(viscaInqExpMode, 2, TxBxReply, false, "AM?", 1);
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.Contains("00") || (Encoder == EncoderManufacturer.IONODES_AVML && TxBxReply.Text.Contains("a")))
|
|||
|
|
{
|
|||
|
|
BtnAutoExp.BackColor = Color.LightGreen;
|
|||
|
|
BtnExpManual.BackColor = BtnExpShtrPri.BackColor = BtnColour;
|
|||
|
|
btnIrisClose.Enabled = txBxIris.Enabled = btnIrisUp.Enabled = BtnGainDown.Enabled = txBxGain.Enabled =
|
|||
|
|
BtnGainUp.Enabled = BtnShutterDown.Enabled = txBxShutter.Enabled = BtnShutterUp.Enabled = false;
|
|||
|
|
txBxGain.Text = txBxShutter.Text = txBxIris.Text = "-";
|
|||
|
|
TxBxGainLim.Enabled = TkBrGain.Enabled = true;
|
|||
|
|
|
|||
|
|
TxBxGainLim_Click(sender, e);
|
|||
|
|
|
|||
|
|
TxBxShutLim_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("03") || (Encoder == EncoderManufacturer.IONODES_AVML && TxBxReply.Text.Contains("m")))
|
|||
|
|
{
|
|||
|
|
BtnExpManual.BackColor = Color.LightGreen;
|
|||
|
|
BtnAutoExp.BackColor = BtnExpShtrPri.BackColor = BtnColour;
|
|||
|
|
btnIrisClose.Enabled = txBxIris.Enabled = btnIrisUp.Enabled = BtnGainDown.Enabled =
|
|||
|
|
txBxGain.Enabled = BtnGainUp.Enabled = BtnShutterDown.Enabled = txBxShutter.Enabled = BtnShutterUp.Enabled = true;
|
|||
|
|
TxBxGainLim.Enabled = TkBrGain.Enabled = false;
|
|||
|
|
TxBxGainLim.Text = "-";
|
|||
|
|
txBxIris_Click(sender, e);
|
|||
|
|
txBxGain_Click(sender, e);
|
|||
|
|
txBxShutter_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("0A") || (Encoder == EncoderManufacturer.IONODES_AVML && TxBxReply.Text.Contains("s")))
|
|||
|
|
{
|
|||
|
|
BtnExpShtrPri.BackColor = Color.LightGreen;
|
|||
|
|
BtnAutoExp.BackColor = BtnExpManual.BackColor = BtnColour;
|
|||
|
|
btnIrisClose.Enabled = txBxIris.Enabled = btnIrisUp.Enabled =
|
|||
|
|
BtnGainDown.Enabled = txBxGain.Enabled = BtnGainUp.Enabled = false;
|
|||
|
|
txBxIris.Text = txBxGain.Text = "-";
|
|||
|
|
BtnShutterDown.Enabled = txBxShutter.Enabled = BtnShutterUp.Enabled =
|
|||
|
|
TxBxGainLim.Enabled = TkBrGain.Enabled = true;
|
|||
|
|
txBxShutter_Click(sender, e);
|
|||
|
|
TxBxGainLim_Click(sender, e);
|
|||
|
|
TxBxShutLim_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (TibboOnline)
|
|||
|
|
{
|
|||
|
|
CheckLEDPower();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (AdvancedOpen == true)
|
|||
|
|
{
|
|||
|
|
starting = true;
|
|||
|
|
PicLogo_Click(sender, e);
|
|||
|
|
starting = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
gpBxCamControl.Enabled = GpBxAddCrtls.Enabled = GpBxAdCont.Enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void DayorNight()
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqIrDayNight, 2, TxBxReply, false, "II?", 1);
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.ToUpper().Contains("2F") || TxBxReply.Text.ToUpper().Contains("02") || TxBxReply.Text.Contains("IIo"))
|
|||
|
|
{
|
|||
|
|
BtnNight.BackColor = Color.LightGreen;
|
|||
|
|
BtnDay.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.ToUpper().Contains("3F") || TxBxReply.Text.ToUpper().Contains("03") || TxBxReply.Text.Contains("IIi"))
|
|||
|
|
{
|
|||
|
|
BtnDay.BackColor = Color.LightGreen;
|
|||
|
|
BtnNight.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ICRMode()
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqIrMode, 2, TxBxReply, false);
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.ToUpper().Contains("2F"))
|
|||
|
|
{
|
|||
|
|
BtnIRAuto.BackColor = Color.LightGreen;
|
|||
|
|
BtnIRMan.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.ToUpper().Contains("3F"))
|
|||
|
|
{
|
|||
|
|
BtnIRMan.BackColor = Color.LightGreen;
|
|||
|
|
BtnIRAuto.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnSave_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
pauseMonitor();
|
|||
|
|
SendCmd("MS0", 1);
|
|||
|
|
checkRestartMonitor();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CkBxSwitch_CheckStateChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (CkBxSwitch.CheckState == CheckState.Checked)
|
|||
|
|
{
|
|||
|
|
CkBxSwitch.Text = "Monitor all";
|
|||
|
|
}
|
|||
|
|
else if (CkBxSwitch.CheckState == CheckState.Indeterminate)
|
|||
|
|
{
|
|||
|
|
CkBxSwitch.Text = "Monitor LED only";
|
|||
|
|
if (monitorCount > 5)
|
|||
|
|
{
|
|||
|
|
monitorCount = -1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (CkBxSwitch.CheckState == CheckState.Unchecked)
|
|||
|
|
{
|
|||
|
|
CkBxSwitch.Text = "Monitor switch only";
|
|||
|
|
if (monitorCount < 5)
|
|||
|
|
{
|
|||
|
|
monitorCount = 5;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnStartMon_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (serialPort1.IsOpen == false)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Please select port first", "Port select");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
lblMonFail.Visible = cancelMonitor = false;
|
|||
|
|
monitorOnFlg = timerMonitor.Enabled = true;
|
|||
|
|
monitorCount = 0;
|
|||
|
|
|
|||
|
|
if (CkBxSwitch.CheckState == CheckState.Unchecked)
|
|||
|
|
{
|
|||
|
|
monitorCount = 5;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void resetTxBxToGrey()
|
|||
|
|
{
|
|||
|
|
foreach (Control txBx in gbBx4ChMonitor.Controls)
|
|||
|
|
{
|
|||
|
|
if (txBx is TextBox)
|
|||
|
|
{
|
|||
|
|
if (((TextBox)txBx).BackColor == Color.LightGreen)
|
|||
|
|
{
|
|||
|
|
((TextBox)txBx).BackColor = SystemColors.Window;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void timerMonitor_Tick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
timerMonitor.Enabled = false;
|
|||
|
|
rxMssg = rxMssg2 = "";
|
|||
|
|
|
|||
|
|
resetTxBxToGrey();
|
|||
|
|
|
|||
|
|
try //in case of weird reply, GUI won't completely crash
|
|||
|
|
{
|
|||
|
|
switch (monitorCount)
|
|||
|
|
{
|
|||
|
|
case 0:
|
|||
|
|
SendCmd("NV?", 2);
|
|||
|
|
string checkString = rxMssg + rxMssg2;
|
|||
|
|
txBxLedVCh1.Text = checkRxMsg("Ch1", 5, checkString);
|
|||
|
|
txBxLedVCh2.Text = checkRxMsg("Ch2", 5, checkString);
|
|||
|
|
changeTxBxColour(txBxLedVCh1, txBxLedVCh2);
|
|||
|
|
break;
|
|||
|
|
case 1:
|
|||
|
|
SendCmd("NC&", 2);
|
|||
|
|
checkString = rxMssg + rxMssg2;
|
|||
|
|
txBxLedICh1.Text = checkRxMsg("Ch1", 5, checkString);
|
|||
|
|
txBxLedICh2.Text = checkRxMsg("Ch2", 5, checkString);
|
|||
|
|
changeTxBxColour(txBxLedICh1, txBxLedICh2);
|
|||
|
|
break;
|
|||
|
|
case 2:
|
|||
|
|
SendCmd("NZ#", 2);
|
|||
|
|
checkString = rxMssg + rxMssg2;
|
|||
|
|
txBxDutyCh1.Text = checkRxMsg("Ch1", 6, checkString);
|
|||
|
|
txBxDutyCh2.Text = checkRxMsg("Ch2", 6, checkString);
|
|||
|
|
changeTxBxColour(txBxDutyCh1, txBxDutyCh2);
|
|||
|
|
break;
|
|||
|
|
case 3:
|
|||
|
|
SendCmd("NF?", 1);
|
|||
|
|
checkString = rxMssg;
|
|||
|
|
txBxFrame.Text = checkRxMsg("NF", 7, checkString);
|
|||
|
|
changeTxBxColour(txBxFrame);
|
|||
|
|
break;
|
|||
|
|
case 4:
|
|||
|
|
SendCmd("NTi", 1);
|
|||
|
|
checkString = rxMssg;
|
|||
|
|
txBxPcbTemp.Text = checkRxMsg("TempInt", 2, checkString) + "°C";
|
|||
|
|
changeTxBxColour(txBxPcbTemp);
|
|||
|
|
if (CkBxSwitch.CheckState == CheckState.Indeterminate)
|
|||
|
|
{
|
|||
|
|
monitorCount = -1;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 5:
|
|||
|
|
GigECheck("113E", TxBxGigEANPRStatus, "100");
|
|||
|
|
break;
|
|||
|
|
case 6:
|
|||
|
|
GigECheck("413E", TxBxGigEOviewStatus, "100");
|
|||
|
|
break;
|
|||
|
|
case 7:
|
|||
|
|
GigECheck("513E", TxBxGigETibboStatus, "100");
|
|||
|
|
break;
|
|||
|
|
case 8:
|
|||
|
|
GigECheck("213E", TxBxGigEOutStatus, "1000");
|
|||
|
|
break;
|
|||
|
|
case 9:
|
|||
|
|
GigECheck("313E", TxBxGigER48Status, "100");
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
|
|||
|
|
monitorCount++;
|
|||
|
|
if (monitorCount > 9)
|
|||
|
|
{
|
|||
|
|
if (CkBxSwitch.CheckState == CheckState.Unchecked)
|
|||
|
|
{
|
|||
|
|
monitorCount = 5;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
monitorCount = 0;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (cancelMonitor == false)
|
|||
|
|
{
|
|||
|
|
timerMonitor.Enabled = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void stopLedMonitor()
|
|||
|
|
{
|
|||
|
|
monitorOnFlg = false;
|
|||
|
|
cancelMonitor = true;
|
|||
|
|
timerMonitor.Enabled = false;
|
|||
|
|
resetTxBxToGrey();
|
|||
|
|
WaitMs(500);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnStopMon_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
stopLedMonitor();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void changeTxBxColour(TextBox TxBx, TextBox TxBx2)
|
|||
|
|
{
|
|||
|
|
changeTxBxColour(TxBx);
|
|||
|
|
changeTxBxColour(TxBx2);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void changeTxBxColour(TextBox TxBx)
|
|||
|
|
{
|
|||
|
|
if (TxBx.BackColor == SystemColors.Window)
|
|||
|
|
{
|
|||
|
|
TxBx.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string checkRxMsg(string searchString, int resultLength, string checkString)
|
|||
|
|
{
|
|||
|
|
int posSearchString = checkString.IndexOf(searchString);
|
|||
|
|
|
|||
|
|
if (searchString.Contains("QX")) // Second bit in hex
|
|||
|
|
{
|
|||
|
|
posSearchString += 2;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (posSearchString != -1 && checkString.Length > posSearchString + searchString.Length + 1 + resultLength)
|
|||
|
|
{
|
|||
|
|
return checkString.Substring(posSearchString + searchString.Length + 1, resultLength);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return "??";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnIrisUp_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (Encoder == EncoderManufacturer.KTnC) // R48 is reversed
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaIrisUp, "AId");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaIrisDown, "AIu");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SendVISCA(viscaInqIris, 2, txBxIris, false, "AI?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnIrisClose_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (Encoder == EncoderManufacturer.KTnC) // R48 is reversed
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaIrisDown, "AIu");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaIrisUp, "AId");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SendVISCA(viscaInqIris, 2, txBxIris, false, "AI?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnGainDown_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaGainDown, "AGd");
|
|||
|
|
SendVISCA(viscaInqGain, 2, txBxGain, false, "AG?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnGainUp_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaGainUp, "AGu");
|
|||
|
|
SendVISCA(viscaInqGain, 2, txBxGain, false, "AG?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnShutterDown_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaShutterDown, "ASd");
|
|||
|
|
SendVISCA(viscaInqShutter, 2, txBxShutter, false, "AS?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnShutterUp_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaShutterUp, "ASu");
|
|||
|
|
SendVISCA(viscaInqShutter, 2, txBxShutter, false, "AS?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnFocusAuto_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaFocusAuto, "FMa");
|
|||
|
|
SendVISCA(viscaInqFocusMode, "FMa");
|
|||
|
|
SendVISCA(viscaInqFocusMode, 2, TxBxReply, false, "FM?", 1);
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.Contains("2"))
|
|||
|
|
{
|
|||
|
|
BtnFocusAuto.BackColor = Color.LightGreen;
|
|||
|
|
BtnFocusMan.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("3"))
|
|||
|
|
{
|
|||
|
|
BtnFocusMan.BackColor = Color.LightGreen;
|
|||
|
|
BtnFocusAuto.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
BtnFocusMan_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnFocusNeg.Enabled = BtnFocusPlus.Enabled = txBxFocus.Enabled =
|
|||
|
|
trackBarFocus.Enabled = TxBxFocus2.Enabled = false;
|
|||
|
|
TxBxFocus2.Text = txBxFocus.Text = "-";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnFocusMan_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaFocusManual, "FMm");
|
|||
|
|
SendVISCA(viscaInqFocusMode, "FMm");
|
|||
|
|
SendVISCA(viscaInqFocusMode, 2, TxBxReply, false, "FM?", 1);
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.Contains("2"))
|
|||
|
|
{
|
|||
|
|
BtnFocusAuto.BackColor = Color.LightGreen;
|
|||
|
|
BtnFocusMan.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("3"))
|
|||
|
|
{
|
|||
|
|
BtnFocusMan.BackColor = Color.LightGreen;
|
|||
|
|
BtnFocusAuto.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
BtnFocusMan_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnFocusNeg.Enabled = BtnFocusPlus.Enabled = txBxFocus.Enabled = trackBarFocus.Enabled = TxBxFocus2.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void FocusNow_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaFocusNow, "FFo");
|
|||
|
|
|
|||
|
|
BtnFocusNow.Enabled = BtnFocusNeg.Enabled = BtnFocusPlus.Enabled =
|
|||
|
|
txBxFocus.Enabled = trackBarFocus.Enabled = TxBxFocus2.Enabled = false;
|
|||
|
|
|
|||
|
|
TxBxFocus2.Text = txBxFocus.Text = "-";
|
|||
|
|
|
|||
|
|
timerFocus.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void timerFocus_Tick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
timerFocus.Enabled = false;
|
|||
|
|
|
|||
|
|
txBxFocus_Click(sender, e);
|
|||
|
|
|
|||
|
|
this.Enabled =
|
|||
|
|
BtnFocusNow.Enabled = BtnFocusNeg.Enabled = BtnFocusPlus.Enabled =
|
|||
|
|
txBxFocus.Enabled = trackBarFocus.Enabled = TxBxFocus2.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ExpManual_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (CameraSelected == SelectedCam.OVERVIEW && BtnWDROn.BackColor == Color.LightGreen && DefConfig == false)
|
|||
|
|
{
|
|||
|
|
DialogResult dialogResult = MessageBox.Show("Are you sure you want to turn off WDR?", "WDR", MessageBoxButtons.YesNo);
|
|||
|
|
|
|||
|
|
if (dialogResult == DialogResult.Yes) // Off at start of button click. so turn back on if they want it
|
|||
|
|
{
|
|||
|
|
BtnWDROff_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SendVISCA(viscaExpManual, "AMm");
|
|||
|
|
BtnExpManual.BackColor = Color.LightGreen;
|
|||
|
|
BtnAutoExp.BackColor = BtnExpShtrPri.BackColor = BtnColour;
|
|||
|
|
TxBxGainLim.Text = TxBxIrisLim.Text = "-";
|
|||
|
|
|
|||
|
|
// Enable iris, gain, and shutter controls
|
|||
|
|
btnIrisClose.Enabled = txBxIris.Enabled = btnIrisUp.Enabled =
|
|||
|
|
BtnGainDown.Enabled = txBxGain.Enabled = BtnGainUp.Enabled =
|
|||
|
|
BtnShutterDown.Enabled = txBxShutter.Enabled = BtnShutterUp.Enabled = true;
|
|||
|
|
|
|||
|
|
// Disable and reset limit controls
|
|||
|
|
TxBxGainLim.Enabled = TkBrGain.Enabled =
|
|||
|
|
BtnIrisLimDown.Enabled = TxBxIrisLim.Enabled = BtnIrisLimUp.Enabled = false;
|
|||
|
|
|
|||
|
|
txBxIris_Click(sender, e);
|
|||
|
|
txBxGain_Click(sender, e);
|
|||
|
|
txBxShutter_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ExpAuto_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (CameraSelected == SelectedCam.OVERVIEW && BtnWDROn.BackColor == Color.LightGreen && DefConfig == false)
|
|||
|
|
{
|
|||
|
|
DialogResult dialogResult = MessageBox.Show("Are you sure you want to turn off WDR?", "WDR", MessageBoxButtons.YesNo);
|
|||
|
|
|
|||
|
|
if (dialogResult == DialogResult.Yes) // Off at start of button click. so turn back on if they want it
|
|||
|
|
{
|
|||
|
|
BtnWDROff_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SendVISCA(viscaExpAuto, "AMa");
|
|||
|
|
BtnAutoExp.BackColor = Color.LightGreen;
|
|||
|
|
BtnExpManual.BackColor = BtnExpShtrPri.BackColor = BtnColour;
|
|||
|
|
txBxIris.Text = txBxGain.Text = txBxShutter.Text = "-";
|
|||
|
|
|
|||
|
|
// Disable iris, gain, and shutter controls
|
|||
|
|
btnIrisClose.Enabled = txBxIris.Enabled = btnIrisUp.Enabled =
|
|||
|
|
BtnGainDown.Enabled = txBxGain.Enabled = BtnGainUp.Enabled =
|
|||
|
|
BtnShutterDown.Enabled = txBxShutter.Enabled = BtnShutterUp.Enabled = false;
|
|||
|
|
|
|||
|
|
// Enable limit controls
|
|||
|
|
TxBxGainLim.Enabled = TkBrGain.Enabled =
|
|||
|
|
BtnIrisLimDown.Enabled = TxBxIrisLim.Enabled = BtnIrisLimUp.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ExpShutter_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (CameraSelected == SelectedCam.OVERVIEW && BtnWDROn.BackColor == Color.LightGreen && DefConfig == false)
|
|||
|
|
{
|
|||
|
|
DialogResult dialogResult = MessageBox.Show("Are you sure you want to turn off WDR?", "WDR", MessageBoxButtons.YesNo);
|
|||
|
|
|
|||
|
|
if (dialogResult == DialogResult.Yes) // Off at start of button click. so turn back on if they want it
|
|||
|
|
{
|
|||
|
|
BtnWDROff_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SendVISCA(viscaExpShutter, "AMs");
|
|||
|
|
BtnExpShtrPri.BackColor = Color.LightGreen;
|
|||
|
|
BtnAutoExp.BackColor = BtnExpManual.BackColor = BtnColour;
|
|||
|
|
txBxIris.Text = txBxGain.Text = "-";
|
|||
|
|
|
|||
|
|
// Disable iris and gain controls
|
|||
|
|
btnIrisClose.Enabled = txBxIris.Enabled = btnIrisUp.Enabled =
|
|||
|
|
BtnGainDown.Enabled = txBxGain.Enabled = BtnGainUp.Enabled = false;
|
|||
|
|
// Enable shutter and limit controls
|
|||
|
|
BtnShutterDown.Enabled = txBxShutter.Enabled = BtnShutterUp.Enabled =
|
|||
|
|
TxBxGainLim.Enabled = TkBrGain.Enabled =
|
|||
|
|
BtnIrisLimDown.Enabled = TxBxIrisLim.Enabled = BtnIrisLimUp.Enabled = true;
|
|||
|
|
txBxShutter_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void PwrLow_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
pauseMonitor();
|
|||
|
|
SendCmd("NPl", 1);
|
|||
|
|
CheckLEDPower();
|
|||
|
|
checkRestartMonitor();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void PwrNormal_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
pauseMonitor();
|
|||
|
|
SendCmd("NPn", 1);
|
|||
|
|
CheckLEDPower();
|
|||
|
|
checkRestartMonitor();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void PwrHigh_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
pauseMonitor();
|
|||
|
|
SendCmd("NPh", 1);
|
|||
|
|
CheckLEDPower();
|
|||
|
|
checkRestartMonitor();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void CheckLEDPower()
|
|||
|
|
{
|
|||
|
|
SendCmd("NP?", 1);
|
|||
|
|
|
|||
|
|
BtnPwrLow.BackColor = BtnPwrMed.BackColor = BtnPwrHigh.BackColor = BtnColour;
|
|||
|
|
|
|||
|
|
if (rxBuffer == "<NPh/>")
|
|||
|
|
{
|
|||
|
|
BtnPwrHigh.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
else if (rxBuffer == "<NPn/>")
|
|||
|
|
{
|
|||
|
|
BtnPwrMed.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
else if (rxBuffer == "<NPl/>")
|
|||
|
|
{
|
|||
|
|
BtnPwrLow.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SendCmd("NC#", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxShutter_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqShutter, 2, txBxShutter, false, "AS?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxGain_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqGain, 2, txBxGain, false, "AG?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxIris_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqIris, 2, txBxIris, false, "AI?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxZoom_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqZoomPos, 4, txBxZoom, false, "ZO?", 1);
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
trackBarZoom.Value = Convert.ToInt32(txBxZoom.Text, 16);
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxFocus_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqFocusPos, 4, txBxFocus, false, "FF?", 1);
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
trackBarFocus.Value = Convert.ToInt32(txBxFocus.Text, 16);
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnDiscoverEncoders_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
DiscoverEncoders(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void DiscoverEncoders(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
BtnDiscoverEncoders.Enabled = false;
|
|||
|
|
|
|||
|
|
if (videoViewANPR.MediaPlayer.IsPlaying == false)
|
|||
|
|
{
|
|||
|
|
comboBox_Devices.Text = "Searching... ";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (videoViewOV.MediaPlayer.IsPlaying == false)
|
|||
|
|
{
|
|||
|
|
comboBox_Devices2.Text = "Searching...";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
comboBox_Devices.Items.Clear();
|
|||
|
|
comboBox_Devices2.Items.Clear();
|
|||
|
|
|
|||
|
|
Array.Clear(onvifDevices, 0, onvifDevices.Length); // empty string array
|
|||
|
|
|
|||
|
|
UdpDiscoveryEndpoint endPoint = new UdpDiscoveryEndpoint(DiscoveryVersion.WSDiscoveryApril2005);
|
|||
|
|
DiscoveryClient discoveryClient = new DiscoveryClient(endPoint);
|
|||
|
|
|
|||
|
|
discoveryClient.FindProgressChanged += discoveryClient_FindProgressChanged;
|
|||
|
|
FindCriteria findCriteria = new FindCriteria();
|
|||
|
|
findCriteria.ContractTypeNames.Add(new System.Xml.XmlQualifiedName("NetworkVideoTransmitter", "http://www.onvif.org/ver10/network/wsdl"));
|
|||
|
|
discoveryClient.FindAsync(findCriteria);
|
|||
|
|
noOfOnvifResponses = 0;
|
|||
|
|
int Onvif = 0;
|
|||
|
|
CamsFound = false;
|
|||
|
|
timerSearch.Enabled = true;
|
|||
|
|
|
|||
|
|
while (timerSearch.Enabled)
|
|||
|
|
{
|
|||
|
|
if (CamsFound && noOfOnvifResponses != Onvif)
|
|||
|
|
{
|
|||
|
|
timerSearch.Enabled = false;
|
|||
|
|
Onvif = noOfOnvifResponses;
|
|||
|
|
timerSearch.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WaitMs(60);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (CamsFound)
|
|||
|
|
{
|
|||
|
|
string[] onvifLessDuplicates = onvifDevices.Distinct().ToArray();
|
|||
|
|
int CamNum = onvifLessDuplicates.Length - 1; // Stops subtraction being done every loop.
|
|||
|
|
|
|||
|
|
for (int i = 0; i < CamNum; i++)
|
|||
|
|
{
|
|||
|
|
// Non exact, no port IP regex
|
|||
|
|
Match match = Regex.Match(onvifLessDuplicates[i], @"((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)?");
|
|||
|
|
|
|||
|
|
comboBox_Devices.Items.Add(match);
|
|||
|
|
comboBox_Devices2.Items.Add(match);
|
|||
|
|
|
|||
|
|
if (serialPort1.IsOpen == true && MAVCopy == false)
|
|||
|
|
{
|
|||
|
|
if (onvifLessDuplicates[i].Contains("192.168.1.111"))
|
|||
|
|
{
|
|||
|
|
comboBox_Devices.SelectedIndex = i;
|
|||
|
|
comboBox_Devices.Text = "192.168.1.111";
|
|||
|
|
btnPlayVlc21.Enabled = BtnSetMJPEGANPR.Enabled = BtnSetIPANPR.Enabled = BtnWebpageANPR.Enabled = true;
|
|||
|
|
btnPlayVlc21_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
else if (onvifLessDuplicates[i].Contains("192.168.1.112"))
|
|||
|
|
{
|
|||
|
|
comboBox_Devices2.SelectedIndex = i;
|
|||
|
|
comboBox_Devices2.Text = "192.168.1.112";
|
|||
|
|
btnPlayVlc22.Enabled = BtnSetH264.Enabled = BtnSetIPOV.Enabled = BtnWebpageOV.Enabled = true;
|
|||
|
|
btnPlayVlc22_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateCameraStatus(comboBox_Devices2, "192.168.1.112", videoViewOV);
|
|||
|
|
UpdateCameraStatus(comboBox_Devices, "192.168.1.111", videoViewANPR);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
comboBox_Devices.Text = comboBox_Devices2.Text = "No Cameras Found";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnDiscoverEncoders.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void UpdateCameraStatus(ComboBox comboBox, string excludedIP, VideoView videoView)
|
|||
|
|
{
|
|||
|
|
if (comboBox.Text != excludedIP && !videoView.MediaPlayer.IsPlaying)
|
|||
|
|
{
|
|||
|
|
comboBox.Text = comboBox.Items.Count == 1 ? "1 Camera found" : $"{comboBox.Items.Count} Cameras found";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void discoveryClient_FindProgressChanged(object sender, FindProgressChangedEventArgs e)
|
|||
|
|
{
|
|||
|
|
onvifDevices[noOfOnvifResponses] = Convert.ToString(e.EndpointDiscoveryMetadata.ListenUris[0]);
|
|||
|
|
noOfOnvifResponses++;
|
|||
|
|
|
|||
|
|
if (noOfOnvifResponses > 128)
|
|||
|
|
{
|
|||
|
|
noOfOnvifResponses = 0; // prevent array overflow
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CamsFound = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnPlayVlc21_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
starting = true;
|
|||
|
|
this.Enabled = false;
|
|||
|
|
TimerANPRPlaying.Enabled = false;
|
|||
|
|
BtnDefConfig.BackColor = BtnColour;
|
|||
|
|
CamIP = IPMatch(comboBox_Devices, txBxManualIP);
|
|||
|
|
|
|||
|
|
CheckEncoderManufacturer();
|
|||
|
|
|
|||
|
|
if (Encoder == EncoderManufacturer.MLVInew || Encoder == EncoderManufacturer.MLVIold)
|
|||
|
|
{
|
|||
|
|
BtnSetH264.Enabled = true;
|
|||
|
|
BtnSetIPOV.Enabled = true;
|
|||
|
|
ANPRStreamUrl = "rtsp://ADMIN:1234@" + CamIP + ":554/live/main";
|
|||
|
|
}
|
|||
|
|
else if (Encoder == EncoderManufacturer.IONODES_AVML || Encoder == EncoderManufacturer.IONODES)
|
|||
|
|
{
|
|||
|
|
BtnSetH264.Enabled = false;
|
|||
|
|
BtnSetIPOV.Enabled = false;
|
|||
|
|
ANPRStreamUrl = "rtsp://admin:admin@" + CamIP + ":554/videoinput_1/h264_1/media.stm";
|
|||
|
|
}
|
|||
|
|
else if (Encoder == EncoderManufacturer.KTnC)
|
|||
|
|
{
|
|||
|
|
BtnSetH264.Enabled = false;
|
|||
|
|
BtnSetIPOV.Enabled = false;
|
|||
|
|
ANPRStreamUrl = "rtsp://admin:admin@" + CamIP + ":554/stream0";
|
|||
|
|
|
|||
|
|
groupEp = new IPEndPoint(IPAddress.Parse(CamIP), 52381);
|
|||
|
|
clRx.Connect(groupEp);
|
|||
|
|
clRx.BeginReceive(new AsyncCallback(recv), null);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
remoteEPANPR = new IPEndPoint(IPAddress.Parse(CamIP), 52381);
|
|||
|
|
Media rtsp1 = new Media(libVLC, ANPRStreamUrl, FromType.FromLocation);
|
|||
|
|
videoViewANPR.MediaPlayer.Play(rtsp1);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Endpoint and VLC error: " + ex.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (sendClientANPR.Client.IsBound == false && Encoder != EncoderManufacturer.KTnC)
|
|||
|
|
{
|
|||
|
|
sendClientANPR.ExclusiveAddressUse = false;
|
|||
|
|
sendClientANPR.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
|
|||
|
|
sendClientANPR.Client.Bind(localEPANPR);
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
sendClientANPR.BeginReceive(new AsyncCallback(recvANPR), null);
|
|||
|
|
}
|
|||
|
|
catch (Exception f)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show(f.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
gpBxCamControl.Enabled = true;
|
|||
|
|
gbxCommands.Enabled = true;
|
|||
|
|
GpBxFrame.Enabled = true;
|
|||
|
|
BtnANPR.Enabled = true;
|
|||
|
|
GpBxAdCont.Enabled = true;
|
|||
|
|
GpBxFrame.Enabled = true;
|
|||
|
|
GpBxMins.Enabled = true;
|
|||
|
|
GpBxAddCrtls.Enabled = true;
|
|||
|
|
selectedCamera = true;
|
|||
|
|
|
|||
|
|
if (serialPort1.IsOpen == false)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Please select COM");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnANPR_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
selectedCamera = true;
|
|||
|
|
BtnANPR_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ANPRstartup = true;
|
|||
|
|
TimerANPRPlaying.Enabled = true;
|
|||
|
|
this.Enabled = true;
|
|||
|
|
starting = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnPlayVlc22_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
starting = true;
|
|||
|
|
this.Enabled = false;
|
|||
|
|
TimerOVPlaying.Enabled = false;
|
|||
|
|
BtnDefConfig.BackColor = BtnColour;
|
|||
|
|
CamIP = IPMatch(comboBox_Devices2, txBxManualIpOv);
|
|||
|
|
|
|||
|
|
CheckEncoderManufacturer();
|
|||
|
|
|
|||
|
|
if (Encoder == EncoderManufacturer.MLVInew || Encoder == EncoderManufacturer.MLVIold)
|
|||
|
|
{
|
|||
|
|
BtnSetH264.Enabled = true;
|
|||
|
|
BtnSetIPOV.Enabled = true;
|
|||
|
|
OVStreamUrl = "rtsp://ADMIN:1234@" + CamIP + ":554/live/main";
|
|||
|
|
}
|
|||
|
|
else if (Encoder == EncoderManufacturer.IONODES_AVML || Encoder == EncoderManufacturer.IONODES)
|
|||
|
|
{
|
|||
|
|
BtnSetH264.Enabled = false;
|
|||
|
|
BtnSetIPOV.Enabled = false;
|
|||
|
|
OVStreamUrl = "rtsp://admin:admin@" + CamIP + ":554/videoinput_1/h264_1/media.stm";
|
|||
|
|
}
|
|||
|
|
else if (Encoder == EncoderManufacturer.KTnC)
|
|||
|
|
{
|
|||
|
|
BtnSetH264.Enabled = false;
|
|||
|
|
BtnSetIPOV.Enabled = false;
|
|||
|
|
OVStreamUrl = "rtsp://admin:admin@" + CamIP + ":554/stream0";
|
|||
|
|
|
|||
|
|
groupEp = new IPEndPoint(IPAddress.Parse(CamIP), 52381);
|
|||
|
|
clRx.Connect(groupEp);
|
|||
|
|
clRx.BeginReceive(new AsyncCallback(recv), null);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
remoteEPOV = new IPEndPoint(IPAddress.Parse(CamIP), 52381);
|
|||
|
|
Media rtsp1 = new Media(libVLC, OVStreamUrl, FromType.FromLocation);
|
|||
|
|
videoViewOV.MediaPlayer.Play(rtsp1);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Endpoint and VLC error: " + ex.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (sendClientOV.Client.IsBound == false && Encoder != EncoderManufacturer.KTnC)
|
|||
|
|
{
|
|||
|
|
sendClientOV.ExclusiveAddressUse = false;
|
|||
|
|
sendClientOV.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
|
|||
|
|
sendClientOV.Client.Bind(localEPOV);
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
sendClientOV.BeginReceive(new AsyncCallback(recvOV), null);
|
|||
|
|
}
|
|||
|
|
catch (Exception f)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show(f.ToString());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
gpBxCamControl.Enabled = true;
|
|||
|
|
gbxCommands.Enabled = true;
|
|||
|
|
GpBxFrame.Enabled = true;
|
|||
|
|
BtnOV.Enabled = true;
|
|||
|
|
GpBxAdCont.Enabled = true;
|
|||
|
|
GpBxFrame.Enabled = true;
|
|||
|
|
GpBxMins.Enabled = true;
|
|||
|
|
GpBxAddCrtls.Enabled = true;
|
|||
|
|
selectedCamera = true;
|
|||
|
|
|
|||
|
|
if (serialPort1.IsOpen == false)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Please select COM");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnOV_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
selectedCamera = true;
|
|||
|
|
BtnOV_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
OVstartup = true;
|
|||
|
|
TimerOVPlaying.Enabled = true;
|
|||
|
|
this.Enabled = true;
|
|||
|
|
starting = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnStopVlc21_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
TimerANPRPlaying.Enabled = false;
|
|||
|
|
videoViewANPR.MediaPlayer.Stop();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnStop2_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
TimerOVPlaying.Enabled = false;
|
|||
|
|
videoViewOV.MediaPlayer.Stop();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void anprSelect()
|
|||
|
|
{
|
|||
|
|
CameraSelected = SelectedCam.ANPR;
|
|||
|
|
CamIP = IPMatch(comboBox_Devices, txBxManualIP);
|
|||
|
|
|
|||
|
|
if (serialPort1.IsOpen)
|
|||
|
|
{
|
|||
|
|
SendCmd("CK0", 1);
|
|||
|
|
richTxBxRxCmd.Clear();
|
|||
|
|
TxBxRxErrMssg.Clear();
|
|||
|
|
SendCmd("CK0", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
EncoderModuleDetect();
|
|||
|
|
|
|||
|
|
BtnANPR.BackColor = Color.LightGreen;
|
|||
|
|
BtnOV.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ovSelect()
|
|||
|
|
{
|
|||
|
|
CameraSelected = SelectedCam.OVERVIEW;
|
|||
|
|
CamIP = IPMatch(comboBox_Devices2, txBxManualIpOv);
|
|||
|
|
|
|||
|
|
if (serialPort1.IsOpen)
|
|||
|
|
{
|
|||
|
|
SendCmd("CK1", 1);
|
|||
|
|
richTxBxRxCmd.Clear();
|
|||
|
|
TxBxRxErrMssg.Clear();
|
|||
|
|
SendCmd("CK1", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
EncoderModuleDetect();
|
|||
|
|
|
|||
|
|
BtnOV.BackColor = Color.LightGreen;
|
|||
|
|
BtnANPR.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void EncoderModuleDetect()
|
|||
|
|
{
|
|||
|
|
CheckEncoderManufacturer();
|
|||
|
|
|
|||
|
|
if (Encoder == EncoderManufacturer.MLVInew || Encoder == EncoderManufacturer.MLVIold)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaFirmwareVer, 5, TxBxRecManVISCA, true);
|
|||
|
|
Thread.Sleep(100);
|
|||
|
|
SendVISCA(viscaFirmwareVer, 5, TxBxRecManVISCA, true); // Try again in case of false reply.
|
|||
|
|
this.Refresh(); // To make sure box is up to date.
|
|||
|
|
|
|||
|
|
if (TxBxRecManVISCA.Text.Contains("0468")) // HD:IP Mk2
|
|||
|
|
{
|
|||
|
|
CameraModule = Module.HZ5510;
|
|||
|
|
this.Text = "HD:IP GUI V" + GUIVersion + " - HD:IP Mk2";
|
|||
|
|
}
|
|||
|
|
else if (TxBxRecManVISCA.Text.Contains("045D")) // FHD:IP Mk2
|
|||
|
|
{
|
|||
|
|
CameraModule = Module.HZ5512;
|
|||
|
|
this.Text = "HD:IP GUI V" + GUIVersion + " - FHD:IP Mk2";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaFirmwareVerWW, 5, TxBxRecManVISCA, true);
|
|||
|
|
Thread.Sleep(100);
|
|||
|
|
SendVISCA(viscaFirmwareVerWW, 5, TxBxRecManVISCA, true); // Try again in case of false reply.
|
|||
|
|
|
|||
|
|
this.Refresh(); // To make sure box is up to date.
|
|||
|
|
|
|||
|
|
// MC-105 || MC-108 therefore R49
|
|||
|
|
if (TxBxRecManVISCA.Text.Contains("CD0E") || TxBxRecManVISCA.Text.Contains("465A"))
|
|||
|
|
{
|
|||
|
|
this.Text = "HD:IP GUI V" + GUIVersion + " - R49";
|
|||
|
|
BtnIrisLimUp.Enabled = BtnIrisLimDown.Enabled = false;
|
|||
|
|
TxBxIrisLim.Text = "-";
|
|||
|
|
CameraModule = Module.MC105;
|
|||
|
|
BtnDefConfig.Enabled = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.Text = "HD:IP GUI V" + GUIVersion + " - ???";
|
|||
|
|
BtnDefConfig.Enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (Encoder == EncoderManufacturer.KTnC)
|
|||
|
|
{
|
|||
|
|
CameraModule = Module.KTnC;
|
|||
|
|
this.Text = "HD:IP GUI V" + GUIVersion + " - R48";
|
|||
|
|
BtnDefConfig.Enabled = true;
|
|||
|
|
}
|
|||
|
|
else if (Encoder == EncoderManufacturer.IONODES)
|
|||
|
|
{
|
|||
|
|
CameraModule = Module.KTnC;
|
|||
|
|
this.Text = "HD:IP GUI V" + GUIVersion + " - HD:IP Mk1";
|
|||
|
|
BtnDefConfig.Enabled = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
CameraModule = Module.NONE;
|
|||
|
|
this.Text = "HD:IP GUI V" + GUIVersion + " - ???";
|
|||
|
|
BtnDefConfig.Enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxManualIP_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (RegexIPPattern.IsMatch(txBxManualIP.Text))
|
|||
|
|
{
|
|||
|
|
txBxManualIP.BackColor = Color.LightGreen;
|
|||
|
|
txBxManualIP.ForeColor = Color.Black;
|
|||
|
|
btnPlayVlc21.Enabled = BtnSetMJPEGANPR.Enabled = BtnSetIPANPR.Enabled = BtnWebpageANPR.Enabled = true;
|
|||
|
|
}
|
|||
|
|
else if (txBxManualIP.TextLength == 0)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
txBxManualIP.BackColor = Color.White;
|
|||
|
|
txBxManualIP.ForeColor = Color.Black;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txBxManualIP.BackColor = Color.Red;
|
|||
|
|
txBxManualIP.ForeColor = Color.White;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxManualIpOv_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (RegexIPPattern.IsMatch(txBxManualIpOv.Text))
|
|||
|
|
{
|
|||
|
|
txBxManualIpOv.BackColor = Color.LightGreen;
|
|||
|
|
txBxManualIpOv.ForeColor = Color.Black;
|
|||
|
|
btnPlayVlc22.Enabled = BtnSetH264.Enabled = BtnSetIPOV.Enabled = BtnWebpageOV.Enabled = true;
|
|||
|
|
}
|
|||
|
|
else if (txBxManualIpOv.TextLength == 0)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
txBxManualIpOv.BackColor = Color.White;
|
|||
|
|
txBxManualIpOv.ForeColor = Color.Black;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txBxManualIpOv.BackColor = Color.Red;
|
|||
|
|
txBxManualIpOv.ForeColor = Color.White;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool IsBitSet(byte b, int pos)
|
|||
|
|
{
|
|||
|
|
return (b & 1 << pos) != 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void comboBox_Devices_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
btnPlayVlc21.Enabled = BtnSetMJPEGANPR.Enabled = BtnSetIPANPR.Enabled = BtnWebpageANPR.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void comboBox_Devices2_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
btnPlayVlc22.Enabled = BtnSetIPOV.Enabled = BtnSetH264.Enabled = BtnWebpageOV.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void timerSearch_Tick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
timerSearch.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void GigECheck(string Query, TextBox TxBx, string SwitchCap)
|
|||
|
|
{
|
|||
|
|
SendCmd("QX@" + Query, 1); // Check connection speed of GigE
|
|||
|
|
|
|||
|
|
if (rxMssg.Contains("unrecognised"))
|
|||
|
|
{
|
|||
|
|
TxBx.Text = "N/A";
|
|||
|
|
TxBx.BackColor = SystemColors.Window;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string checkString = rxMssg + rxMssg2;
|
|||
|
|
byte regValue = Convert.ToByte(checkRxMsg("QX", 2, checkString), 16);
|
|||
|
|
|
|||
|
|
// Determine connection speed in mbps
|
|||
|
|
string speed = IsBitSet(regValue, 6) ? "1000" :
|
|||
|
|
IsBitSet(regValue, 5) ? "100" :
|
|||
|
|
IsBitSet(regValue, 4) ? "10" : "NONE";
|
|||
|
|
|
|||
|
|
// Add duplex type if applicable
|
|||
|
|
if (speed != "NONE")
|
|||
|
|
speed += IsBitSet(regValue, 3) ? "F" : "H";
|
|||
|
|
|
|||
|
|
TxBx.Text = speed;
|
|||
|
|
|
|||
|
|
if (!TxBx.Text.Contains(SwitchCap))
|
|||
|
|
{
|
|||
|
|
TxBx.ForeColor = Color.White;
|
|||
|
|
TxBx.BackColor = Color.Red;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
TxBx.ForeColor = Color.Black;
|
|||
|
|
TxBx.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void tbxManualIP_KeyDown(object sender, KeyEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.KeyValue == 13 && txBxManualIP.BackColor == Color.LightGreen)
|
|||
|
|
{
|
|||
|
|
btnPlayVlc21_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void tbxManualIPOV_KeyDown(object sender, KeyEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.KeyValue == 13 && txBxManualIpOv.BackColor == Color.LightGreen)
|
|||
|
|
{
|
|||
|
|
btnPlayVlc22_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnNight_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaIrNight, "IIo");
|
|||
|
|
DayorNight();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnDay_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaIrDay, "IIi");
|
|||
|
|
DayorNight();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private byte[] ConvertByteArray(string hexValue)
|
|||
|
|
{
|
|||
|
|
byte[] hexInt = new byte[4];
|
|||
|
|
|
|||
|
|
for (int i = 0; i < 4; i++)
|
|||
|
|
{
|
|||
|
|
hexInt[i] = Convert.ToByte(int.Parse(hexValue.Substring(i, 1), NumberStyles.HexNumber));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return hexInt;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void trackBarZoom_MouseUp(object sender, MouseEventArgs e)
|
|||
|
|
{
|
|||
|
|
string hexValue = trackBarZoom.Value.ToString("X4");
|
|||
|
|
|
|||
|
|
txBxZoom.Text = Convert.ToString(hexValue);
|
|||
|
|
byte[] hexInt = ConvertByteArray(hexValue);
|
|||
|
|
byte[] viscaZoomDirect = VISCACommand(0x04, 0x47, hexInt[0], hexInt[1], hexInt[2], hexInt[3]);
|
|||
|
|
|
|||
|
|
timerRxDataUdp.Interval = 5000;
|
|||
|
|
|
|||
|
|
SendVISCA(viscaZoomDirect, "#S6105" + hexValue + "T");
|
|||
|
|
|
|||
|
|
timerRxDataUdp.Interval = 2000;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SendVISCA(string ToSend)
|
|||
|
|
{
|
|||
|
|
if (Encoder == EncoderManufacturer.IONODES_AVML)
|
|||
|
|
{
|
|||
|
|
byte[] Placeholder = { 0x01 };
|
|||
|
|
SendVISCA(Placeholder, ToSend);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SendVISCA(byte[] ToSend)
|
|||
|
|
{
|
|||
|
|
if (Encoder != EncoderManufacturer.IONODES_AVML)
|
|||
|
|
{
|
|||
|
|
SendVISCA(ToSend, "");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SendVISCA(byte[] ToSend, string AVML)
|
|||
|
|
{
|
|||
|
|
switch (Encoder)
|
|||
|
|
{
|
|||
|
|
case EncoderManufacturer.MLVInew: // HD:IP Mk2, FHD:IP Mk2 & R49
|
|||
|
|
SendVISCA_MLVI_new(ToSend, 0, TxBxReply, false);
|
|||
|
|
break;
|
|||
|
|
case EncoderManufacturer.MLVIold: // HD:IP Mk2, FHD:IP Mk2 & R49
|
|||
|
|
SendVISCA_MLVI_old(ToSend);
|
|||
|
|
break;
|
|||
|
|
case EncoderManufacturer.IONODES: // FHD:IP (prototypes)
|
|||
|
|
SendVISCA_IONODES(ToSend);
|
|||
|
|
break;
|
|||
|
|
case EncoderManufacturer.IONODES_AVML:// HD:IP Mk1
|
|||
|
|
SendCmd(AVML, 1);
|
|||
|
|
break;
|
|||
|
|
case EncoderManufacturer.KTnC: // R48
|
|||
|
|
KTnCSendandReply(ToSend);
|
|||
|
|
rxMssgVISCA = "";
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SendVISCA(byte[] ToSend, int NumBytesParse, TextBox TxBx, bool AllNibbles)
|
|||
|
|
{
|
|||
|
|
if (Encoder != EncoderManufacturer.IONODES_AVML)
|
|||
|
|
{
|
|||
|
|
SendVISCA(ToSend, NumBytesParse, TxBx, AllNibbles, "", 0);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SendVISCA(byte[] ToSend, int NumBytesParse, TextBox TxBx, bool AllNibbles, string AVML, int NOER)
|
|||
|
|
{
|
|||
|
|
string lastreply;
|
|||
|
|
|
|||
|
|
switch (Encoder)
|
|||
|
|
{
|
|||
|
|
case EncoderManufacturer.MLVInew: // HD:IP Mk2, FHD:IP Mk2 & R49
|
|||
|
|
SendVISCA_MLVI_new(ToSend, NumBytesParse, TxBx, AllNibbles);
|
|||
|
|
break;
|
|||
|
|
case EncoderManufacturer.MLVIold: // HD:IP Mk2, FHD:IP Mk2 & R49
|
|||
|
|
SendVISCA_MLVI_old(ToSend);
|
|||
|
|
ViscaParseReply(NumBytesParse, TxBx, AllNibbles);
|
|||
|
|
break;
|
|||
|
|
case EncoderManufacturer.IONODES: // FHD:IP (prototypes)
|
|||
|
|
SendVISCA_IONODES(ToSend);
|
|||
|
|
lastreply = richTxBxRxCmd.Text.Substring(richTxBxRxCmd.Text.LastIndexOf("<<"));
|
|||
|
|
|
|||
|
|
if (lastreply.Contains("#")) // HD:IP Mk1 replies with question becuase it doesn't know what else to do
|
|||
|
|
{
|
|||
|
|
Encoder = EncoderManufacturer.IONODES_AVML;
|
|||
|
|
SendVISCA(ToSend, NumBytesParse, TxBx, AllNibbles, AVML, NOER);
|
|||
|
|
}
|
|||
|
|
ViscaParseReplyIONODES(NumBytesParse, TxBx, AllNibbles);
|
|||
|
|
break;
|
|||
|
|
case EncoderManufacturer.IONODES_AVML:// HD:IP Mk1
|
|||
|
|
SendCmd(AVML, NOER);
|
|||
|
|
lastreply = richTxBxRxCmd.Text.Substring(richTxBxRxCmd.Text.LastIndexOf("<<"));
|
|||
|
|
|
|||
|
|
if (lastreply.Contains("no reply")) // It's not actually AVML so go back to IONODES
|
|||
|
|
{
|
|||
|
|
Encoder = EncoderManufacturer.IONODES;
|
|||
|
|
SendVISCA(ToSend, NumBytesParse, TxBx, AllNibbles, AVML, NOER);
|
|||
|
|
}
|
|||
|
|
checkRxMessage(TxBx);
|
|||
|
|
break;
|
|||
|
|
case EncoderManufacturer.KTnC: // R48
|
|||
|
|
KTnCSendandReply(ToSend);
|
|||
|
|
ReplyKTnC(NumBytesParse, TxBx, AllNibbles);
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SendVISCA_MLVI_old(byte[] ToSend)
|
|||
|
|
{
|
|||
|
|
rxMssgVISCA = "";
|
|||
|
|
|
|||
|
|
RhTxBxVISCAReplies.SelectionColor = Color.Red;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string BuiltString = VISCABuilder(ToSend);
|
|||
|
|
RhTxBxVISCAReplies.AppendText(">> " + BuiltString + Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
RhTxBxVISCAReplies.AppendText(">> Error" + Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
RhTxBxVISCAReplies.SelectionStart = RhTxBxVISCAReplies.Text.Length;
|
|||
|
|
RhTxBxVISCAReplies.ScrollToCaret();
|
|||
|
|
|
|||
|
|
if (CameraSelected == SelectedCam.ANPR)
|
|||
|
|
{
|
|||
|
|
if (sendClientANPR.Send(ToSend, ToSend.Length, remoteEPANPR) != ToSend.Length)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Not all bytes sent");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (ToSend.Length == 13)
|
|||
|
|
{
|
|||
|
|
Thread.Sleep(200);
|
|||
|
|
|
|||
|
|
if (sendClientANPR.Send(ToSend, ToSend.Length, remoteEPANPR) != ToSend.Length)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Not all bytes sent");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (CameraSelected == SelectedCam.OVERVIEW)
|
|||
|
|
{
|
|||
|
|
if (sendClientOV.Send(ToSend, ToSend.Length, remoteEPOV) != ToSend.Length)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Not all bytes sent");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (ToSend.Length == 13)
|
|||
|
|
{
|
|||
|
|
Thread.Sleep(200);
|
|||
|
|
|
|||
|
|
if (sendClientOV.Send(ToSend, ToSend.Length, remoteEPOV) != ToSend.Length)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Not all bytes sent");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Please select camera");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WaitMs(100);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ViscaParseReply(int NumBytesParse, TextBox TxBx, bool AllNibbles)
|
|||
|
|
{
|
|||
|
|
timerRxDataUdp.Enabled = false;
|
|||
|
|
rxDataUdpTimeout = false;
|
|||
|
|
timerRxDataUdp.Enabled = true;
|
|||
|
|
|
|||
|
|
// 90 50 Done Inq + 90 51 Done cmd
|
|||
|
|
while (!rxMssgVISCA.Contains("90 5") && rxDataUdpTimeout == false)
|
|||
|
|
{
|
|||
|
|
Application.DoEvents();
|
|||
|
|
Thread.Sleep(10);
|
|||
|
|
|
|||
|
|
if (rxMssgVISCA.Contains("90 6"))
|
|||
|
|
{
|
|||
|
|
timerRxDataUdp.Enabled = false;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
timerRxDataUdp.Enabled = false;
|
|||
|
|
|
|||
|
|
if (rxDataUdpTimeout == true)
|
|||
|
|
{
|
|||
|
|
TimeoutCounter++;
|
|||
|
|
if (TimeoutCounter > 2)
|
|||
|
|
{
|
|||
|
|
RhTxBxVISCAReplies.AppendText("Timeout occured at " + TxBx.Name.Substring(4, TxBx.Name.Length - 4) + Environment.NewLine);
|
|||
|
|
RhTxBxVISCAReplies.SelectionStart = RhTxBxVISCAReplies.Text.Length;
|
|||
|
|
RhTxBxVISCAReplies.ScrollToCaret();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string RxMssg = rxMssgVISCA.Replace(" ", "");
|
|||
|
|
rxMssgVISCA = ""; // In case of another response
|
|||
|
|
|
|||
|
|
if (NumBytesParse == 0)
|
|||
|
|
{
|
|||
|
|
TxBx.Text = RxMssg;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (RxMssg.Contains("9050")) // means info to come back, 51 is just ack.
|
|||
|
|
{
|
|||
|
|
TxBx.Text = ConvertToWantedBits(RxMssg, NumBytesParse, AllNibbles);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SendVISCA_MLVI_new(byte[] ToSend, int NumBytesParse, TextBox TxBx, bool AllNibbles)
|
|||
|
|
{
|
|||
|
|
if (InProgress == true)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
InProgress = true;
|
|||
|
|
rxMssgVISCA = "";
|
|||
|
|
|
|||
|
|
RhTxBxVISCAReplies.SelectionColor = Color.Red;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string BuiltString = VISCABuilder(ToSend);
|
|||
|
|
RhTxBxVISCAReplies.AppendText(">> " + BuiltString + Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
RhTxBxVISCAReplies.AppendText(">> Error" + Environment.NewLine);
|
|||
|
|
InProgress = false;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
RhTxBxVISCAReplies.SelectionStart = RhTxBxVISCAReplies.Text.Length;
|
|||
|
|
RhTxBxVISCAReplies.ScrollToCaret();
|
|||
|
|
|
|||
|
|
// If (ANPR and not all bytes sent) or (Overview and not all bytes sent)
|
|||
|
|
if ((CameraSelected == SelectedCam.ANPR && sendClientANPR.Send(ToSend, ToSend.Length, remoteEPANPR) != ToSend.Length)
|
|||
|
|
|| (CameraSelected == SelectedCam.OVERVIEW && sendClientOV.Send(ToSend, ToSend.Length, remoteEPOV) != ToSend.Length))
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Not all bytes sent");
|
|||
|
|
InProgress = false;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
timerRxDataUdp.Enabled = false;
|
|||
|
|
rxDataUdpTimeout = false;
|
|||
|
|
timerRxDataUdp.Enabled = true;
|
|||
|
|
|
|||
|
|
// 90 50 Done Inq + 90 51 Done cmd
|
|||
|
|
while (!rxMssgVISCA.Contains("90 5") && rxDataUdpTimeout == false)
|
|||
|
|
{
|
|||
|
|
Application.DoEvents();
|
|||
|
|
Thread.Sleep(5);
|
|||
|
|
|
|||
|
|
if (rxMssgVISCA.Contains("90 6"))
|
|||
|
|
{
|
|||
|
|
InProgress = false;
|
|||
|
|
timerRxDataUdp.Enabled = false;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
else if (rxMssgVISCA == "90 41 FF ") // Not timeout just haven't captured 90 5x FF
|
|||
|
|
{
|
|||
|
|
RhTxBxVISCAReplies.AppendText("ACK but no confirm" + Environment.NewLine);
|
|||
|
|
RhTxBxVISCAReplies.SelectionStart = RhTxBxVISCAReplies.Text.Length;
|
|||
|
|
RhTxBxVISCAReplies.ScrollToCaret();
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
timerRxDataUdp.Enabled = false;
|
|||
|
|
|
|||
|
|
if (rxDataUdpTimeout == true)
|
|||
|
|
{
|
|||
|
|
RhTxBxVISCAReplies.AppendText("Timeout occured at " + TxBx.Name.Substring(4) + Environment.NewLine);
|
|||
|
|
RhTxBxVISCAReplies.SelectionStart = RhTxBxVISCAReplies.Text.Length;
|
|||
|
|
RhTxBxVISCAReplies.ScrollToCaret();
|
|||
|
|
InProgress = false;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
rxDataUdpTimeout = false;
|
|||
|
|
|
|||
|
|
string RxMssg = rxMssgVISCA.Replace(" ", "");
|
|||
|
|
rxMssgVISCA = ""; // In case of another response
|
|||
|
|
|
|||
|
|
InProgress = false;
|
|||
|
|
|
|||
|
|
// Command sent so need to save. Set timer going or reset timer.
|
|||
|
|
// Inq command and timer is already running so restart timer to not interfere with command
|
|||
|
|
if (CameraModule == Module.MC105 && WWSave == false && (ToSend[9] == 0x01 || TimerWWSave.Enabled == true))
|
|||
|
|
{
|
|||
|
|
TimerWWSave.Enabled = false;
|
|||
|
|
TimerWWSave.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (NumBytesParse == 0) // Case where we don't care what the reply is, but have to wait till it's recieved so we can send the next command.
|
|||
|
|
{
|
|||
|
|
TxBx.Text = RxMssg;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (RxMssg.Contains("9050")) //means info to come back, 51 is just ack.
|
|||
|
|
{
|
|||
|
|
TxBx.Text = ConvertToWantedBits(RxMssg, NumBytesParse, AllNibbles);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SendVISCA_IONODES(byte[] ToSend)
|
|||
|
|
{
|
|||
|
|
rxMssgVISCA = "";
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string SendString = VISCABuilder(ToSend).Replace(" ", "");
|
|||
|
|
noOfExpectedResonses = 2; // 9041 & 9051
|
|||
|
|
|
|||
|
|
if (SendString.Length == 10 || (SendString.Contains("72") && SendString.Contains("09"))) // Inquiry command 5 bytes x2 + 4 spaces for string or contains 72 which is resolution registers
|
|||
|
|
{
|
|||
|
|
noOfExpectedResonses = 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SendCmd("#" + SendString, noOfExpectedResonses);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
richTxBxRxCmd.AppendText(">> Error" + Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WaitMs(100);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private bool ViscaParseReplyIONODES(int NumBytesParse, TextBox TxBx, bool AllNibbles)
|
|||
|
|
{
|
|||
|
|
timerRxDataUdp.Enabled = false;
|
|||
|
|
rxDataUdpTimeout = false;
|
|||
|
|
timerRxDataUdp.Enabled = true;
|
|||
|
|
|
|||
|
|
while (!rxMssgVISCA.Contains("905") && !rxMssgVISCA.Contains("904") && rxDataUdpTimeout == false) // needs timeout
|
|||
|
|
{
|
|||
|
|
Application.DoEvents();
|
|||
|
|
Thread.Sleep(10);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
timerRxDataUdp.Enabled = false;
|
|||
|
|
|
|||
|
|
if (rxMssgVISCA.Contains("9061"))
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Could not execute the command in the current mode.");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
else if (rxDataUdpTimeout == true)
|
|||
|
|
{
|
|||
|
|
TimeoutCounter++;
|
|||
|
|
if (TimeoutCounter > 2)
|
|||
|
|
{
|
|||
|
|
richTxBxRxCmd.AppendText("Timeout occured at " + TxBx.Name.Substring(4, TxBx.Name.Length - 4));
|
|||
|
|
richTxBxRxCmd.SelectionStart = richTxBxRxCmd.Text.Length;
|
|||
|
|
richTxBxRxCmd.ScrollToCaret();
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string RxMssg;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
RxMssg = rxMssgVISCA.Substring(1, rxMssgVISCA.Length - 3); // Get rid of AVML wrapper.
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
RxMssg = rxMssgVISCA;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
rxMssgVISCA = ""; // In case of another message
|
|||
|
|
|
|||
|
|
if (RxMssg.Contains("9050")) // Means info to come back, 51 is just ack.
|
|||
|
|
{
|
|||
|
|
TxBx.Text = ConvertToWantedBits(RxMssg, NumBytesParse, AllNibbles);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void KTnCSendandReply(byte[] dataTx)
|
|||
|
|
{
|
|||
|
|
rxMssgVISCA = "";
|
|||
|
|
|
|||
|
|
if (clRx.Send(dataTx, dataTx.Length) != dataTx.Length)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Not all bytes sent");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (dataTx.Length == 13)
|
|||
|
|
{
|
|||
|
|
Thread.Sleep(400);
|
|||
|
|
rxMssgVISCA = "";
|
|||
|
|
|
|||
|
|
if (clRx.Send(dataTx, dataTx.Length) != dataTx.Length)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Not all bytes sent");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string SendString = VISCABuilder(dataTx);
|
|||
|
|
|
|||
|
|
RhTxBxVISCAReplies.SelectionColor = Color.Red;
|
|||
|
|
RhTxBxVISCAReplies.AppendText(">> " + SendString + Environment.NewLine);
|
|||
|
|
RhTxBxVISCAReplies.SelectionStart = RhTxBxVISCAReplies.Text.Length;
|
|||
|
|
RhTxBxVISCAReplies.ScrollToCaret();
|
|||
|
|
|
|||
|
|
timerRxDataUdp.Enabled = false;
|
|||
|
|
rxDataUdpTimeout = false;
|
|||
|
|
timerRxDataUdp.Enabled = true;
|
|||
|
|
|
|||
|
|
while (!rxMssgVISCA.Contains("90 5") && !rxMssgVISCA.Contains("90 4") && rxDataUdpTimeout == false) // needs timeout
|
|||
|
|
{
|
|||
|
|
Application.DoEvents();
|
|||
|
|
Thread.Sleep(10);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
timerRxDataUdp.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ReplyKTnC(int NumBytesParse, TextBox TxBx, bool AllNibbles)
|
|||
|
|
{
|
|||
|
|
if (rxDataUdpTimeout == true)
|
|||
|
|
{
|
|||
|
|
RhTxBxVISCAReplies.SelectionColor = Color.Green;
|
|||
|
|
RhTxBxVISCAReplies.AppendText(Environment.NewLine + "<< Rx Timeout error");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
string RxMssg = rxMssgVISCA.Replace(" ", "");
|
|||
|
|
rxMssgVISCA = ""; // In case of another message
|
|||
|
|
|
|||
|
|
if (RxMssg.Contains("9050")) // Means info to come back, 51 is just ack.
|
|||
|
|
{
|
|||
|
|
TxBx.Text = ConvertToWantedBits(RxMssg, NumBytesParse, AllNibbles);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
RhTxBxVISCAReplies.SelectionStart = RhTxBxVISCAReplies.Text.Length;
|
|||
|
|
RhTxBxVISCAReplies.ScrollToCaret();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//CallBack for KT&C encoder.
|
|||
|
|
private void recv(IAsyncResult res)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
byte[] received = clRx.EndReceive(res, ref RemoteIpEndPoint);
|
|||
|
|
clRx.BeginReceive(new AsyncCallback(recv), null);
|
|||
|
|
|
|||
|
|
StringBuilder sb = new StringBuilder();
|
|||
|
|
foreach (byte b in received)
|
|||
|
|
{
|
|||
|
|
sb.AppendFormat("{0:x2} ", b);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
rxMssgVISCA = sb.ToString().ToUpper();
|
|||
|
|
RhTxBxVISCAReplies.SelectionColor = Color.Green;
|
|||
|
|
RhTxBxVISCAReplies.AppendText("<< " + rxMssgVISCA + Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void recvANPR(IAsyncResult res)
|
|||
|
|
{
|
|||
|
|
if (InvokeRequired)
|
|||
|
|
{
|
|||
|
|
BeginInvoke(new MethodInvoker(delegate () { recvANPR(res); }));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
byte[] received = sendClientANPR.EndReceive(res, ref localEPANPR);
|
|||
|
|
sendClientANPR.BeginReceive(new AsyncCallback(recvANPR), null);
|
|||
|
|
ProcessReply(received);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void recvOV(IAsyncResult res)
|
|||
|
|
{
|
|||
|
|
if (InvokeRequired)
|
|||
|
|
{
|
|||
|
|
BeginInvoke(new MethodInvoker(delegate () { recvOV(res); }));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
byte[] received = sendClientOV.EndReceive(res, ref localEPOV);
|
|||
|
|
sendClientOV.BeginReceive(new AsyncCallback(recvOV), null);
|
|||
|
|
ProcessReply(received);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ProcessReply(byte[] received)
|
|||
|
|
{
|
|||
|
|
if (received.Length < 3) // Minimum of 90 41 FF therefore 3.
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Unexpected reply from camera VISCA" + Environment.NewLine + "reply: " + rxMssgVISCA);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
StringBuilder sb = new StringBuilder();
|
|||
|
|
|
|||
|
|
foreach (byte b in received)
|
|||
|
|
{
|
|||
|
|
sb.AppendFormat("{0:x2} ", b);
|
|||
|
|
}
|
|||
|
|
rxMssgVISCA = sb.ToString().ToUpper();
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
rxMssgVISCA = rxMssgVISCA.Substring(rxMssgVISCA.IndexOf("90"), rxMssgVISCA.IndexOf("FF 00", rxMssgVISCA.IndexOf("90")) - rxMssgVISCA.IndexOf("90") + 3);
|
|||
|
|
RhTxBxVISCAReplies.SelectionColor = Color.Green;
|
|||
|
|
RhTxBxVISCAReplies.AppendText("<< " + rxMssgVISCA + Environment.NewLine);
|
|||
|
|
RhTxBxVISCAReplies.SelectionStart = RhTxBxVISCAReplies.Text.Length;
|
|||
|
|
RhTxBxVISCAReplies.ScrollToCaret();
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string ConvertToWantedBits(string RxMssg, int NumBytesParse, bool AllNibbles)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
int bytescharlength = NumBytesParse * 2;
|
|||
|
|
// start pos is the length - FF - how many bytes wanted
|
|||
|
|
int StartParsePos = RxMssg.Length - 2 - bytescharlength;
|
|||
|
|
string ParseString = "";
|
|||
|
|
RxMssg = RxMssg.Substring(RxMssg.IndexOf("9050") + StartParsePos, bytescharlength);
|
|||
|
|
|
|||
|
|
for (int i = 1; i < bytescharlength; i += 2)
|
|||
|
|
{
|
|||
|
|
if (AllNibbles == false)
|
|||
|
|
{
|
|||
|
|
ParseString += RxMssg.Substring(i, 1);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
ParseString += RxMssg.Substring(i - 1, 2);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return ParseString.ToUpper();
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
|
|||
|
|
return RxMssg;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string VISCABuilder(byte[] ToSend)
|
|||
|
|
{
|
|||
|
|
bool StartSB = false;
|
|||
|
|
StringBuilder sb = new StringBuilder();
|
|||
|
|
|
|||
|
|
foreach (byte b in ToSend)
|
|||
|
|
{
|
|||
|
|
if (b == 0x81)
|
|||
|
|
{
|
|||
|
|
StartSB = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (StartSB == true)
|
|||
|
|
{
|
|||
|
|
sb.AppendFormat("{0:x2} ", b);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return sb.ToString().ToUpper();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void timerRxDataUdp_Tick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
timerRxDataUdp.Enabled = false;
|
|||
|
|
rxDataUdpTimeout = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void trackFocus_MouseUp(object sender, MouseEventArgs e)
|
|||
|
|
{
|
|||
|
|
string hexValue = trackBarFocus.Value.ToString("X4");
|
|||
|
|
|
|||
|
|
txBxFocus.Text = Convert.ToString(hexValue);
|
|||
|
|
byte[] hexInt = ConvertByteArray(hexValue);
|
|||
|
|
byte[] viscaFocusDirect = VISCACommand(0x04, 0x48, hexInt[0], hexInt[1], hexInt[2], hexInt[3]);
|
|||
|
|
|
|||
|
|
timerRxDataUdp.Interval = 5000;
|
|||
|
|
|
|||
|
|
SendVISCA(viscaFocusDirect, 4, TxBxReply, true, "#S6104" + hexValue + "T", 1);
|
|||
|
|
|
|||
|
|
timerRxDataUdp.Interval = 2000;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnQueryFrameRate_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaQuery, 12, TxBxReply, false);
|
|||
|
|
|
|||
|
|
Btn720p30.BackColor = BtnColour;
|
|||
|
|
Btn720p25.BackColor = BtnColour;
|
|||
|
|
Btn1080p25.BackColor = BtnColour;
|
|||
|
|
Btn1080p30.BackColor = BtnColour;
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.Contains("0E") || TxBxReply.Text.Contains("0F"))
|
|||
|
|
{
|
|||
|
|
Btn720p30.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("07") || TxBxReply.Text.Contains("06"))
|
|||
|
|
{
|
|||
|
|
Btn1080p30.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("01"))
|
|||
|
|
{
|
|||
|
|
Btn720p25.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("08"))
|
|||
|
|
{
|
|||
|
|
Btn1080p25.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Unknown framerate, please set manually");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Btn1080p25_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(visca1080p25);
|
|||
|
|
BtnQueryFrameRate_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Btn1080p30_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(visca1080p30);
|
|||
|
|
BtnQueryFrameRate_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Btn720p25_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(visca720p25);
|
|||
|
|
BtnQueryFrameRate_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Btn720p30_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(visca720p30);
|
|||
|
|
BtnQueryFrameRate_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnIRAuto_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaAutoIR);
|
|||
|
|
ICRMode();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnIRMan_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaManualIR);
|
|||
|
|
ICRMode();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxZoom_KeyDown(object sender, KeyEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.KeyValue == 13)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
trackBarZoom.Value = Convert.ToInt32(txBxZoom.Text, 16);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Not an accceptable zoom value, range is" + Environment.NewLine + trackBarZoom.Minimum + "-" + trackBarZoom.Maximum);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateZoom();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxZoom2_KeyDown(object sender, KeyEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.KeyValue == 13)
|
|||
|
|
{
|
|||
|
|
int InputVal = Convert.ToInt16(txBxZoom2.Text);
|
|||
|
|
|
|||
|
|
if (InputVal <= 10 && InputVal >= 0)
|
|||
|
|
{
|
|||
|
|
trackBarZoom.Value = Convert.ToInt32(InputVal * 1638.4);
|
|||
|
|
UpdateZoom();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnZoomIn_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
int InputVal = Convert.ToInt16(trackBarZoom.Value / 1638.4);
|
|||
|
|
|
|||
|
|
if (InputVal <= 9 && InputVal >= 0)
|
|||
|
|
{
|
|||
|
|
txBxZoom2.Text = Convert.ToString(InputVal + 1);
|
|||
|
|
if (InputVal != 10)
|
|||
|
|
{
|
|||
|
|
trackBarZoom.Value = Convert.ToInt32((InputVal * 1638.4) + 1638.4);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateZoom();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnZoomOut_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
int InputVal = Convert.ToInt16(trackBarZoom.Value / 1638.4);
|
|||
|
|
|
|||
|
|
if (InputVal <= 10 && InputVal >= 1)
|
|||
|
|
{
|
|||
|
|
txBxZoom2.Text = Convert.ToString(InputVal - 1);
|
|||
|
|
if (InputVal != 0)
|
|||
|
|
{
|
|||
|
|
trackBarZoom.Value = Convert.ToInt32((InputVal * 1638.4) - 1638.4);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateZoom();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void UpdateZoom()
|
|||
|
|
{
|
|||
|
|
string hexValue = trackBarZoom.Value.ToString("X4");
|
|||
|
|
|
|||
|
|
txBxZoom.Text = Convert.ToString(hexValue);
|
|||
|
|
byte[] hexInt = ConvertByteArray(hexValue);
|
|||
|
|
byte[] viscaZoomDirect = VISCACommand(0x04, 0x47, hexInt[0], hexInt[1], hexInt[2], hexInt[3]);
|
|||
|
|
SendVISCA(viscaZoomDirect, "#S6105" + hexValue + "T");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnFocusPlus_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
int InputVal = Convert.ToInt16((trackBarFocus.Value - 256) / 6502.4);
|
|||
|
|
|
|||
|
|
if (InputVal <= 9 && InputVal >= 0)
|
|||
|
|
{
|
|||
|
|
TxBxFocus2.Text = Convert.ToString(InputVal + 1);
|
|||
|
|
if (InputVal != 10)
|
|||
|
|
{
|
|||
|
|
trackBarFocus.Value = Convert.ToInt32((InputVal * 6502.4) + 256 + 6502.4);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateFocus();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnFocusNeg_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
int InputVal = Convert.ToInt16((trackBarFocus.Value - 256) / 6502.4);
|
|||
|
|
|
|||
|
|
if (InputVal <= 10 && InputVal >= 1)
|
|||
|
|
{
|
|||
|
|
TxBxFocus2.Text = Convert.ToString(InputVal - 1);
|
|||
|
|
if (InputVal != 0)
|
|||
|
|
{
|
|||
|
|
trackBarFocus.Value = Convert.ToInt32((InputVal * 6502.4) + 256 - 6502.4);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateFocus();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxFocus_KeyDown(object sender, KeyEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.KeyValue == 13)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
trackBarFocus.Value = Convert.ToInt32(txBxFocus.Text, 16);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Not an accceptable focus value, range is" + Environment.NewLine + trackBarFocus.Minimum + "-" + trackBarFocus.Maximum);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateFocus();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxFocus2_KeyDown(object sender, KeyEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.KeyValue == 13)
|
|||
|
|
{
|
|||
|
|
int InputVal = Convert.ToInt16(TxBxFocus2.Text);
|
|||
|
|
|
|||
|
|
if (InputVal <= 10 && InputVal >= 0)
|
|||
|
|
{
|
|||
|
|
trackBarFocus.Value = Convert.ToInt32((InputVal * 6502.4) + 256);
|
|||
|
|
UpdateFocus();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void UpdateFocus()
|
|||
|
|
{
|
|||
|
|
string hexValue = trackBarFocus.Value.ToString("X4");
|
|||
|
|
|
|||
|
|
txBxFocus.Text = Convert.ToString(hexValue);
|
|||
|
|
byte[] hexInt = ConvertByteArray(hexValue);
|
|||
|
|
byte[] viscaFocusDirect = VISCACommand(0x04, 0x48, hexInt[0], hexInt[1], hexInt[2], hexInt[3]);
|
|||
|
|
SendVISCA(viscaFocusDirect, "#S6104" + hexValue + "T");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnSharpUp_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaSharpnessUp, "APu");
|
|||
|
|
TxBxSharp_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnSharpDown_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaSharpnessDown, "APd");
|
|||
|
|
TxBxSharp_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxSharp_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqSharpness, 1, TxBxSharp, false, "AP?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void AdjustGamma(int delta, object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (TxBxGamma.Text == null)
|
|||
|
|
{
|
|||
|
|
TxBxGamma_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
byte GammaValue = Convert.ToByte(Convert.ToInt16(TxBxGamma.Text) + delta);
|
|||
|
|
|
|||
|
|
if (Encoder == EncoderManufacturer.IONODES_AVML) //HD:IP Mk1 AVML
|
|||
|
|
{
|
|||
|
|
if (delta > 0)
|
|||
|
|
SendVISCA("ANu");
|
|||
|
|
else
|
|||
|
|
SendVISCA("ANd");
|
|||
|
|
}
|
|||
|
|
else if (GammaValue >= 0 && GammaValue <= 6)
|
|||
|
|
{
|
|||
|
|
byte[] viscaGammaDirect = VISCACommand(0x04, 0x5B, GammaValue);
|
|||
|
|
SendVISCA(viscaGammaDirect);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TxBxGamma_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnGammaUp_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
AdjustGamma(1, sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnGammaDown_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
AdjustGamma(-1, sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxGamma_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqGamma, 1, TxBxGamma, false, "AN?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void AdjustContrast(int delta, object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (TxBxContrast.Text == null)
|
|||
|
|
{
|
|||
|
|
TxBxContrast_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int ConValue = int.Parse(TxBxContrast.Text, NumberStyles.HexNumber) + delta;
|
|||
|
|
|
|||
|
|
if (Encoder == EncoderManufacturer.IONODES_AVML) // HD:IP Mk1 AVML
|
|||
|
|
{
|
|||
|
|
if (delta > 0)
|
|||
|
|
SendVISCA("ACu");
|
|||
|
|
else
|
|||
|
|
SendVISCA("ACd");
|
|||
|
|
}
|
|||
|
|
else if (ConValue >= 0 && ConValue <= 20)
|
|||
|
|
{
|
|||
|
|
if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
byte[] viscaWWContrast = VISCACommand(0x05, 0x5D, 0x00, 0x00, 0x00, Convert.ToByte(ConValue));
|
|||
|
|
SendVISCA(viscaWWContrast);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
byte[] viscaContrastDirect = VISCACommand(0x71, 0x40, Convert.ToByte(ConValue));
|
|||
|
|
SendVISCA(viscaContrastDirect);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TxBxContrast_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnContrastPlus_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
AdjustContrast(1, sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnContrastNeg_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
AdjustContrast(-1, sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxContrast_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqContrastWW, 2, TxBxContrast, false, "AC?", 1);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqContrast, 1, TxBxContrast, true, "AC?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (TxBxContrast.Text.Substring(0, 1) == "0")
|
|||
|
|
{
|
|||
|
|
TxBxContrast.Text = TxBxContrast.Text.Substring(1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnExpCompUp_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaExpCompUp);
|
|||
|
|
TxBxExpComp_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnExpCompDown_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaExpCompDown);
|
|||
|
|
TxBxExpComp_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnExpCompReset_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaExpCompReset);
|
|||
|
|
TxBxExpComp_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxExpComp_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqExpComp, 1, TxBxExpComp, false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void AdjustNR(int delta, object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (TxBxNR.Text == null)
|
|||
|
|
{
|
|||
|
|
TxBxNR_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Encoder == EncoderManufacturer.IONODES_AVML)
|
|||
|
|
{
|
|||
|
|
int i = 0;
|
|||
|
|
string[] NRAVMLCommands = new string[4] { "n", "a", "2", "3" };
|
|||
|
|
|
|||
|
|
foreach (string CMD in NRAVMLCommands)
|
|||
|
|
{
|
|||
|
|
if (TxBxNR.Text.Contains(CMD))
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string Cmdtosend = "XN" + NRAVMLCommands[i + delta];
|
|||
|
|
SendVISCA(viscaFirmwareVer, Cmdtosend);
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
i++;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (TxBxNR.Text != "0")
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
int NR_Num = Convert.ToInt16(TxBxNR.Text) + delta;
|
|||
|
|
|
|||
|
|
int limit = 6; // KT&C limits
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
limit = 15; // 0x0F
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (NR_Num > limit)
|
|||
|
|
{
|
|||
|
|
NR_Num = limit;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
byte NRByte = Convert.ToByte(NR_Num);
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
byte[] viscaNRDirectWW = VISCACommand(0x05, 0x53, NRByte, 0x00);
|
|||
|
|
SendVISCA(viscaNRDirectWW);
|
|||
|
|
Thread.Sleep(100);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
byte[] viscaNRDirect = VISCACommand(0x04, 0x53, NRByte);
|
|||
|
|
SendVISCA(viscaNRDirect);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TxBxNR_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnNRUp_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
AdjustNR(1, sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnNRDown_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
AdjustNR(-1, sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxNR_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqNRWW, 2, TxBxNR, false, "XN?", 1);
|
|||
|
|
|
|||
|
|
try // Cut off 3D NR reply
|
|||
|
|
{
|
|||
|
|
TxBxNR.Text = TxBxNR.Text.Substring(0, 1);
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqNR, 1, TxBxNR, false, "XN?", 1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnMirrorOn_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaMirrorOn, "ARm");
|
|||
|
|
BtnMirrorOn.BackColor = Color.LightGreen;
|
|||
|
|
BtnMirrorOff.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnMirrorOff_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaMirrorOff, "ARn");
|
|||
|
|
BtnMirrorOff.BackColor = Color.LightGreen;
|
|||
|
|
BtnMirrorOn.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TkBarLED_MouseUp(object sender, MouseEventArgs e)
|
|||
|
|
{
|
|||
|
|
TkBarLED.Enabled = false;
|
|||
|
|
|
|||
|
|
if (TkBarLED.Value == 0)
|
|||
|
|
{
|
|||
|
|
btnIllumOff_Click(sender, e);
|
|||
|
|
TxBxLEDCurrent.Text = "LED's Off";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (btnIllumOff.BackColor == Color.LightGreen)
|
|||
|
|
{
|
|||
|
|
btnIllumOn_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string LEDCurrent = TxBxLEDCurrent.Text.Remove(TxBxLEDCurrent.Text.Length - 1);
|
|||
|
|
|
|||
|
|
pauseMonitor();
|
|||
|
|
SendCmd("NC@" + LEDCurrent, 1);
|
|||
|
|
CheckLEDPower();
|
|||
|
|
checkRestartMonitor();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TimerLEDCoolDown.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TkBarLED_ValueChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
TxBxLEDCurrent.Text = (TkBarLED.Value / 10.0).ToString("N2") + "A"; // Translates trackbar position to current and displays live
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TimerLEDCoolDown_Tick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
TkBarLED.Enabled = true;
|
|||
|
|
TimerLEDCoolDown.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void PicLogo_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
PicLogo.Enabled = false;
|
|||
|
|
|
|||
|
|
if (AdvancedOpen == false)
|
|||
|
|
{
|
|||
|
|
PasswordForm PasswordForm = new PasswordForm();
|
|||
|
|
this.Enabled = false;
|
|||
|
|
PasswordForm.Show();
|
|||
|
|
PasswordForm.Location = new Point(this.Location.X + (this.Width / 2) - (PasswordForm.Width / 2), this.Location.Y + (this.Height / 2) - (PasswordForm.Height / 2));
|
|||
|
|
|
|||
|
|
while (PasswordForm.Visible == true)
|
|||
|
|
{
|
|||
|
|
Application.DoEvents();
|
|||
|
|
Thread.Sleep(10);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.Enabled = true;
|
|||
|
|
}
|
|||
|
|
else if (starting == false)
|
|||
|
|
{
|
|||
|
|
DialogResult dialogResult = MessageBox.Show("Do you wish to close the advanced menu?", "Close advanced menu", MessageBoxButtons.YesNo);
|
|||
|
|
|
|||
|
|
if (dialogResult == DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
MAVCopy = false;
|
|||
|
|
AdvancedOpen = false;
|
|||
|
|
this.Width = 980;
|
|||
|
|
|
|||
|
|
string[] lines = { serialPort1.PortName, MAVCopy.ToString(), TxBxPSUIP.Text, TxBxZebraIP.Text };
|
|||
|
|
File.WriteAllLines($"{TxtFileDir}COMInfo.txt", lines);
|
|||
|
|
}
|
|||
|
|
PicLogo.Enabled = true;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (CorrectPassword == true)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
this.Width = 1260;
|
|||
|
|
AdvancedOpen = true;
|
|||
|
|
|
|||
|
|
if (selectedCamera == true)
|
|||
|
|
{
|
|||
|
|
TxBxSharp_Click(sender, e);
|
|||
|
|
TxBxGamma_Click(sender, e);
|
|||
|
|
TxBxContrast_Click(sender, e);
|
|||
|
|
|
|||
|
|
TxBxNR_Click(sender, e);
|
|||
|
|
|
|||
|
|
if (BtnExpShtrPri.BackColor == Color.LightGreen || BtnAutoExp.BackColor == Color.LightGreen)
|
|||
|
|
{
|
|||
|
|
TxBxGainLim_Click(sender, e);
|
|||
|
|
TxBxIrisLim_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SendVISCA(viscaInqDIS, 2, TxBxReply, false);
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.Contains("2"))
|
|||
|
|
{
|
|||
|
|
BtnDISOn.BackColor = Color.LightGreen;
|
|||
|
|
BtnDISOff.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("3"))
|
|||
|
|
{
|
|||
|
|
BtnDISOff.BackColor = Color.LightGreen;
|
|||
|
|
BtnDISOn.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
BtnDISOff_Click(sender, e);
|
|||
|
|
BtnDISOff.BackColor = Color.LightGreen;
|
|||
|
|
BtnDISOn.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SendVISCA(viscaInqMirror, 2, TxBxReply, false, "AR?", 1);
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.Contains("2") || TxBxReply.Text.Contains("m") || TxBxReply.Text.Contains("r") || TxBxReply.Text.Contains("y")) // Mirrored 'm' or both mirrored and inverted 'r' or 'y'.
|
|||
|
|
{
|
|||
|
|
BtnMirrorOn.BackColor = Color.LightGreen;
|
|||
|
|
BtnMirrorOff.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("3") || TxBxReply.Text.Contains("n") || TxBxReply.Text.Contains("i")) // Not on 'n' or just inverted 'i'.
|
|||
|
|
{
|
|||
|
|
BtnMirrorOff.BackColor = Color.LightGreen;
|
|||
|
|
BtnMirrorOn.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
BtnMirrorOff_Click(sender, e);
|
|||
|
|
BtnMirrorOff.BackColor = Color.LightGreen;
|
|||
|
|
BtnMirrorOn.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ICRMode();
|
|||
|
|
DayorNight();
|
|||
|
|
BtnQueryFrameRate_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnSetMJPEGANPR.Visible = BtnSetH264.Visible = true;
|
|||
|
|
|
|||
|
|
if (MAVCopy == true)
|
|||
|
|
{
|
|||
|
|
GpBxOSD.Visible = BtnWebpageOV.Visible = BtnWebpageANPR.Visible = BtnSetIPANPR.Visible = BtnSetIPOV.Visible = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
gpBxCamControl.Enabled = GpBxAddCrtls.Enabled = GpBxAdCont.Enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
PicLogo.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnExpCompOn_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaExpCompOn);
|
|||
|
|
BtnExpCompOn.BackColor = Color.LightGreen;
|
|||
|
|
BtnExpCompOff.BackColor = BtnColour;
|
|||
|
|
BtnBrightnessReset.Enabled = BtnExpCompDown.Enabled = BtnExpCompUp.Enabled = TxBxExpComp.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnExpCompOff_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaExpCompOff);
|
|||
|
|
BtnExpCompOff.BackColor = Color.LightGreen;
|
|||
|
|
BtnExpCompOn.BackColor = BtnColour;
|
|||
|
|
BtnBrightnessReset.Enabled = BtnExpCompDown.Enabled = BtnExpCompUp.Enabled = TxBxExpComp.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private static readonly Dictionary<string, string> KTnCShutterMap = new Dictionary<string, string>()
|
|||
|
|
{
|
|||
|
|
{ "00", "1/1" }, { "01", "1/2" }, { "02", "1/4" }, { "03", "1/8" },
|
|||
|
|
{ "04", "1/15" }, { "05", "1/30" }, { "06", "1/60" }, { "07", "1/90" },
|
|||
|
|
{ "08", "1/100" }, { "09", "1/125" }, { "0A", "1/180" }, { "0B", "1/250" },
|
|||
|
|
{ "0C", "1/350" }, { "0D", "1/500" }, { "0E", "1/725" }, { "0F", "1/1000" },
|
|||
|
|
{ "10", "1/1500" }, { "11", "1/2000" }, { "12", "1/3000" }, { "13", "1/4000" },
|
|||
|
|
{ "14", "1/6000" }, { "15", "1/10000" }
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
private static readonly Dictionary<string, string> MC105ShutterMap = new Dictionary<string, string>()
|
|||
|
|
{
|
|||
|
|
{ "00", "1/1" }, { "01", "1/2" }, { "02", "1/4" }, { "03", "1/8" },
|
|||
|
|
{ "04", "1/15" }, { "05", "1/30" }, { "06", "1/60" }, { "07", "1/100" },
|
|||
|
|
{ "08", "1/120" }, { "09", "1/250" }, { "0A", "1/500" }, { "0B", "1/1000" },
|
|||
|
|
{ "0C", "1/2000" }, { "0D", "1/5000" }, { "0E", "1/10000" }, { "0F", "1/20000" },
|
|||
|
|
{ "10", "1/30000" }
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
private static readonly Dictionary<string, string> KTnCIrisMap = new Dictionary<string, string>()
|
|||
|
|
{
|
|||
|
|
{ "00", "Closed" }, { "01", "F32" }, { "02", "F22" }, { "03", "F19" },
|
|||
|
|
{ "04", "F16" }, { "05", "F14" }, { "06", "F11" }, { "07", "F9.6" },
|
|||
|
|
{ "08", "F8" }, { "09", "F6.8" }, { "0A", "F5.6" }, { "0B", "F4.8" },
|
|||
|
|
{ "0C", "F4" }, { "0D", "F3.4" }, { "0E", "F2.8" }, { "0F", "F2.4" },
|
|||
|
|
{ "10", "F2.0" }, { "11", "F1.6" }
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
private static readonly Dictionary<string, string> MC105IrisMap = new Dictionary<string, string>()
|
|||
|
|
{
|
|||
|
|
{ "00", "Closed" }, { "04", "F16.0" }, { "05", "F14.0" }, { "06", "F11.0" },
|
|||
|
|
{ "07", "F9.6" }, { "08", "F8.0" }, { "09", "F6.8" }, { "0A", "F5.6" },
|
|||
|
|
{ "0B", "F4.8" }, { "0C", "F4.0" }, { "0D", "F3.4" }, { "0E", "F2.8" },
|
|||
|
|
{ "0F", "F2.4" }, { "10", "F2.0" }, { "11", "F1.8" }, { "12", "F1.7" }
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
private void ConvertShutter(TextBox TxBx)
|
|||
|
|
{
|
|||
|
|
Dictionary<string, string> map = null;
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.KTnC || CameraModule == Module.HZ5510 || CameraModule == Module.HZ5512)
|
|||
|
|
{
|
|||
|
|
map = KTnCShutterMap;
|
|||
|
|
}
|
|||
|
|
else if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
map = MC105ShutterMap;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (map != null && map.TryGetValue(TxBx.Text, out string value))
|
|||
|
|
{
|
|||
|
|
TxBx.Text = value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ConvertIris(TextBox TxBx)
|
|||
|
|
{
|
|||
|
|
Dictionary<string, string> map = null;
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.KTnC || CameraModule == Module.HZ5510 || CameraModule == Module.HZ5512)
|
|||
|
|
{
|
|||
|
|
map = KTnCIrisMap;
|
|||
|
|
}
|
|||
|
|
else if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
map = MC105IrisMap;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (map != null && map.TryGetValue(TxBx.Text, out string value))
|
|||
|
|
{
|
|||
|
|
TxBx.Text = value;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ConvertGain(TextBox TxBx)
|
|||
|
|
{
|
|||
|
|
if (byte.TryParse(TxBx.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out byte value))
|
|||
|
|
{
|
|||
|
|
int gain;
|
|||
|
|
if (value <= 0x0F)
|
|||
|
|
gain = value * 2;
|
|||
|
|
else
|
|||
|
|
gain = 30 + (value - 0x0F) * 3;
|
|||
|
|
|
|||
|
|
TxBx.Text = $"{gain}dB";
|
|||
|
|
} // if it is an invalid input keep text unchanged
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxShutter_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (txBxShutter.Text.Contains("Stream")) // HD:IP Mk1 stream start message interpting queries
|
|||
|
|
{
|
|||
|
|
txBxShutter_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ConvertShutter(txBxShutter);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxIris_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (txBxIris.Text.Contains("Stream")) // HD:IP Mk1 stream start message interpting queries
|
|||
|
|
{
|
|||
|
|
txBxIris_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ConvertIris(txBxIris);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txBxGain_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (txBxGain.Text.Contains("Stream")) // HD:IP Mk1 stream start message interpting queries
|
|||
|
|
{
|
|||
|
|
txBxGain_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
ConvertGain(txBxGain);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnDefConfig_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
this.Enabled = false;
|
|||
|
|
DefConfig = true;
|
|||
|
|
BtnDefConfig.BackColor = SystemColors.ControlLightLight;
|
|||
|
|
|
|||
|
|
if (Encoder == EncoderManufacturer.IONODES_AVML) // HD:IP Mk1
|
|||
|
|
{
|
|||
|
|
anprSelect();
|
|||
|
|
SendCmd("NZl", 1);
|
|||
|
|
SendCmd("IIo", 1);
|
|||
|
|
SendCmd("AMm", 1);
|
|||
|
|
SendCmd("NCy", 1);
|
|||
|
|
SendCmd("ARy", 1);
|
|||
|
|
SendCmd("AF@30.0", 1);
|
|||
|
|
SendCmd("AI@0A", 1);
|
|||
|
|
checkRxMessage(txBxIris);
|
|||
|
|
SendCmd("AG@05", 1);
|
|||
|
|
checkRxMessage(txBxGain);
|
|||
|
|
SendCmd("AS@0A", 1);
|
|||
|
|
checkRxMessage(txBxShutter);
|
|||
|
|
|
|||
|
|
trackBarZoom.Value = 0;
|
|||
|
|
Thread.Sleep(100);
|
|||
|
|
UpdateZoom();
|
|||
|
|
|
|||
|
|
this.Enabled = true;
|
|||
|
|
BtnDefConfig.BackColor = Color.LightGreen;
|
|||
|
|
DefConfig = false;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (videoViewOV.MediaPlayer.IsPlaying == true) // HD:IP Mk2, FHD:IP Mk2, R49, R48
|
|||
|
|
{
|
|||
|
|
if (CameraSelected == SelectedCam.ANPR)
|
|||
|
|
{
|
|||
|
|
ovSelect(); // Also checks encoder and camera module
|
|||
|
|
CamSetup(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
trackBarZoom.Value = 0;
|
|||
|
|
UpdateZoom();
|
|||
|
|
|
|||
|
|
BtnDay_Click(sender, e); // day mode
|
|||
|
|
BtnFocusMan_Click(sender, e); // Manual focus
|
|||
|
|
ExpAuto_Click(sender, e); // Auto Exposure
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.MC105) // R49 - MC-105
|
|||
|
|
{
|
|||
|
|
byte[] viscaWWMaxShutOn = VISCACommand(0x04, 0x3B, 0x02);
|
|||
|
|
SendVISCA(viscaWWMaxShutOn); // Max shutter on
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWMaxShut = VISCACommand(0x04, 0x2F, 0x00, 0x00, 0x00, 0x0E);
|
|||
|
|
SendVISCA(viscaWWMaxShut); // Max shutter 1/10000
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWMinShutOn = VISCACommand(0x04, 0x12, 0x02);
|
|||
|
|
SendVISCA(viscaWWMinShutOn); // Min shutter on
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWMinShut = VISCACommand(0x04, 0x2E, 0x00, 0x00, 0x00, 0x08);
|
|||
|
|
SendVISCA(viscaWWMinShut); // Min shutter 1/120
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWGainLim = VISCACommand(0x04, 0x2C, 0x02, 0x03);
|
|||
|
|
SendVISCA(viscaWWGainLim); // Gain limit 23
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWIrisLim = VISCACommand(0x04, 0x24, 0x0B, 0x05, 0x0A);
|
|||
|
|
SendVISCA(viscaWWIrisLim); // Min iris F1.7
|
|||
|
|
WaitMs(200);
|
|||
|
|
SendVISCA(viscaFocusManual); // Manual focus
|
|||
|
|
WaitMs(200);
|
|||
|
|
SendVISCA(viscaWDROffWW); // DWDR Off
|
|||
|
|
WaitMs(500);
|
|||
|
|
byte[] viscaWWSharp = VISCACommand(0x04, 0x42, 0x00, 0x00, 0x00, 0x04);
|
|||
|
|
SendVISCA(viscaWWSharp); // Sharpness 4
|
|||
|
|
WaitMs(500);
|
|||
|
|
SendVISCA(viscaExpCompOn); // Exposure comp on
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWExpComp = VISCACommand(0x4E, 0x00, 0x00, 0x00, 0x07);
|
|||
|
|
SendVISCA(viscaWWExpComp); // Exp comp 7
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWBright = VISCACommand(0x05, 0x5E, 0x00, 0x00, 0x00, 0x0A);
|
|||
|
|
SendVISCA(viscaWWBright); // Brightness A
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWGamma = VISCACommand(0x04, 0x5B, 0x02);
|
|||
|
|
SendVISCA(viscaWWGamma); // Gamma 2
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWContrast = VISCACommand(0x05, 0x5D, 0x00, 0x00, 0x00, 0x07);
|
|||
|
|
SendVISCA(viscaWWContrast); // Contrast 7
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWChroma = VISCACommand(0x04, 0x13, 0x00, 0x00, 0x00, 0x0A);
|
|||
|
|
SendVISCA(viscaWWChroma); // Chroma A
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWDNRon = VISCACommand(0x05, 0x53, 0x7F);
|
|||
|
|
SendVISCA(viscaWWDNRon); // DNR on manual independent
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWDNR = VISCACommand(0x05, 0x53, 0x02, 0x00);
|
|||
|
|
SendVISCA(viscaWWDNR); // DNR 2D 2
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWApContLvl = VISCACommand(0x04, 0x42, 0x00, 0x00, 0x00, 0x04);
|
|||
|
|
SendVISCA(viscaWWApContLvl); // Aperture control 4
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWAntiSatOff = VISCACommand(0x04, 0x6B, 0x00, 0x00);
|
|||
|
|
SendVISCA(viscaWWAntiSatOff); // Anti saturation off
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWWhiteBalance = VISCACommand(0x04, 0x35, 0x02);
|
|||
|
|
SendVISCA(viscaWWWhiteBalance); // White balance outdoor
|
|||
|
|
WaitMs(200);
|
|||
|
|
byte[] viscaWWAEResponse = VISCACommand(0x04, 0x5D, 0x30);
|
|||
|
|
SendVISCA(viscaWWAEResponse); // AE repsonse 30s
|
|||
|
|
}
|
|||
|
|
else if (CameraModule == Module.HZ5510) // HD:IP Mk2
|
|||
|
|
{
|
|||
|
|
byte[] viscaSharpnessDirectOV = VISCACommand(0x04, 0x42, 0x00, 0x00, 0x00, 0x05);
|
|||
|
|
SendVISCA(viscaSharpnessDirectOV); // Sharpness = 5
|
|||
|
|
|
|||
|
|
byte[] viscaGammaDirectOV = VISCACommand(0x04, 0x5B, 0x01);
|
|||
|
|
SendVISCA(viscaGammaDirectOV); // Gamma = 1
|
|||
|
|
|
|||
|
|
byte[] viscaContrastDirectOV = VISCACommand(0x71, 0x40, 0x07);
|
|||
|
|
SendVISCA(viscaContrastDirectOV); // Contrast = 7
|
|||
|
|
|
|||
|
|
byte[] viscaAGCDirectOV = VISCACommand(0x70, 0x34, 0x04);
|
|||
|
|
SendVISCA(viscaAGCDirectOV); //AGC max between 0-6 we want 176 on scale 0-255 which is approximetly equivilent to 4.
|
|||
|
|
|
|||
|
|
byte[] viscaGainLimDirect = VISCACommand(0x70, 0x34, 0x25);
|
|||
|
|
SendVISCA(viscaGainLimDirect); // Gain limit 25
|
|||
|
|
|
|||
|
|
byte[] viscaShutterMinDirectA = VISCACommand(0x04, 0x13, 0x00, 0x00, 0x00, 0x08);
|
|||
|
|
SendVISCA(viscaShutterMinDirectA); // Shutter limit 1/100
|
|||
|
|
|
|||
|
|
BtnExpCompOff_Click(sender, e); // Brightness mode off
|
|||
|
|
|
|||
|
|
byte[] viscaIrisLimDirect = VISCACommand(0x70, 0xD3, 0x07, 0x00, 0x07, 0x00, 0x0F, 0x00, 0x0F, 0x00);
|
|||
|
|
SendVISCA(viscaIrisLimDirect); // Iris Limit = just above default to all way open 70-F0.
|
|||
|
|
|
|||
|
|
BtnWDROn_Click(sender, e); // Wide Dynamic Range on
|
|||
|
|
|
|||
|
|
byte[] viscaWDRLvl = VISCACommand(0x70, 0x3A, 0x05);
|
|||
|
|
SendVISCA(viscaWDRLvl); // WDR level = 05
|
|||
|
|
|
|||
|
|
byte[] viscaNRDirectOV = VISCACommand(0x04, 0x53, 0x00);
|
|||
|
|
SendVISCA(viscaNRDirectOV); // Noise reduction off
|
|||
|
|
}
|
|||
|
|
else if (CameraModule == Module.HZ5512) // FHD:IP Mk2
|
|||
|
|
{
|
|||
|
|
byte[] viscaSharpnessDirectOV = VISCACommand(0x04, 0x42, 0x00, 0x00, 0x00, 0x0C);
|
|||
|
|
SendVISCA(viscaSharpnessDirectOV); // Sharpness = C
|
|||
|
|
|
|||
|
|
byte[] viscaGammaDirectOV = VISCACommand(0x04, 0x5B, 0x01);
|
|||
|
|
SendVISCA(viscaGammaDirectOV); // Gamma = 1
|
|||
|
|
|
|||
|
|
byte[] viscaContrastDirectOV = VISCACommand(0x71, 0x40, 0x0B);
|
|||
|
|
SendVISCA(viscaContrastDirectOV); // Contrast = B
|
|||
|
|
|
|||
|
|
byte[] viscaAGCDirectOV = VISCACommand(0x70, 0x34, 0x04);
|
|||
|
|
SendVISCA(viscaAGCDirectOV); // AGC max between 0-6 we want 176 on scale 0-255 which is approximetly equivilent to 4.
|
|||
|
|
|
|||
|
|
byte[] viscaGainLimDirect = VISCACommand(0x04, 0x2C, 0x23);
|
|||
|
|
SendVISCA(viscaGainLimDirect); // Gain limit 23
|
|||
|
|
|
|||
|
|
byte[] viscaShutterMinDirectA = VISCACommand(0x04, 0x13, 0x00, 0x00, 0x00, 0x0A);
|
|||
|
|
SendVISCA(viscaShutterMinDirectA); // Shutter limit 1/180
|
|||
|
|
|
|||
|
|
byte[] viscaAEResponse = VISCACommand(0x04, 0x5D, 0x30);
|
|||
|
|
SendVISCA(viscaAEResponse); // Auto exposure response 30
|
|||
|
|
|
|||
|
|
BtnExpCompOn_Click(sender, e); // Brightness mode on
|
|||
|
|
|
|||
|
|
byte[] viscaExpCompDirectOV = VISCACommand(0x04, 0x4E, 0x00, 0x00, 0x00, 0x02);
|
|||
|
|
SendVISCA(viscaExpCompDirectOV); // Brightness = 2
|
|||
|
|
|
|||
|
|
byte[] viscaSaturation = VISCACommand(0x71, 0x53, 0x10);
|
|||
|
|
SendVISCA(viscaSaturation); // Saturation = 10
|
|||
|
|
|
|||
|
|
byte[] viscaWhiteBalance = VISCACommand(0x04, 0x35, 0x02);
|
|||
|
|
SendVISCA(viscaWhiteBalance); // White balance = 2
|
|||
|
|
|
|||
|
|
byte[] viscaNRDirectOV = VISCACommand(0x04, 0x53, 0x00);
|
|||
|
|
SendVISCA(viscaNRDirectOV); // Noise reduction off
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TxBxSharp_Click(sender, e);
|
|||
|
|
TxBxGamma_Click(sender, e);
|
|||
|
|
TxBxContrast_Click(sender, e);
|
|||
|
|
TxBxExpComp_Click(sender, e);
|
|||
|
|
TxBxNR_Click(sender, e);
|
|||
|
|
TxBxWDRLvl_Click(sender, e);
|
|||
|
|
|
|||
|
|
TxBxGainLim_Click(sender, e);
|
|||
|
|
TxBxIrisLim_Click(sender, e);
|
|||
|
|
TxBxShutLim_Click(sender, e);
|
|||
|
|
|
|||
|
|
FocusNow_Click(sender, e); // focus now
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (videoViewANPR.MediaPlayer.IsPlaying == true)
|
|||
|
|
{
|
|||
|
|
anprSelect(); // Also checks encoder and camera module
|
|||
|
|
CamSetup(sender, e);
|
|||
|
|
|
|||
|
|
trackBarZoom.Value = 0;
|
|||
|
|
UpdateZoom();
|
|||
|
|
|
|||
|
|
SendCmd("NC@1.00", 1);
|
|||
|
|
PwrLow_Click(sender, e); // LED power to 1.00A
|
|||
|
|
btnIllumOn_Click(sender, e);
|
|||
|
|
|
|||
|
|
BtnFocusMan_Click(sender, e); // Manual focus
|
|||
|
|
ExpManual_Click(sender, e); // Manual mode
|
|||
|
|
BtnNight_Click(sender, e); // Night mode
|
|||
|
|
BtnExpCompOff_Click(sender, e); // Brightness mode off
|
|||
|
|
|
|||
|
|
byte[] viscaShutterDirect = VISCACommand(0x04, 0x4A, 0x00, 0x00, 0x00, 0x0F);
|
|||
|
|
SendVISCA(viscaShutterDirect); // Shutter 1/1000th
|
|||
|
|
|
|||
|
|
byte[] viscaIrisDirect = VISCACommand(0x04, 0x4B, 0x00, 0x00, 0x00, 0x0C);
|
|||
|
|
SendVISCA(viscaIrisDirect); // Iris F4
|
|||
|
|
|
|||
|
|
byte[] viscaGainDirect = VISCACommand(0x04, 0x4C, 0x00, 0x00, 0x00, 0x00);
|
|||
|
|
SendVISCA(viscaGainDirect); // Gain 0db
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.HZ5510) // HD:IP Mk2
|
|||
|
|
{
|
|||
|
|
byte[] viscaSharpnessDirectOV = VISCACommand(0x04, 0x42, 0x00, 0x00, 0x00, 0x05);
|
|||
|
|
SendVISCA(viscaSharpnessDirectOV); // Sharpness 5
|
|||
|
|
|
|||
|
|
byte[] viscaContrastDirect = VISCACommand(0x71, 0x40, 0x12);
|
|||
|
|
SendVISCA(viscaContrastDirect); // Contrast 12
|
|||
|
|
}
|
|||
|
|
else if (CameraModule == Module.HZ5512) // FHD:IP Mk2
|
|||
|
|
{
|
|||
|
|
byte[] viscaSharpnessDirectOV = VISCACommand(0x04, 0x42, 0x00, 0x00, 0x00, 0x07);
|
|||
|
|
SendVISCA(viscaSharpnessDirectOV); // Sharpness 7
|
|||
|
|
byte[] viscaContrastDirect = VISCACommand(0x71, 0x40, 0x14);
|
|||
|
|
SendVISCA(viscaContrastDirect); // Contrast 14
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
byte[] viscaGammaDirect = VISCACommand(0x04, 0x5B, 0x03);
|
|||
|
|
SendVISCA(viscaGammaDirect); // Gamma 3
|
|||
|
|
|
|||
|
|
byte[] viscaNRDirect = VISCACommand(0x04, 0x53, 0x00);
|
|||
|
|
SendVISCA(viscaNRDirect); // Noise reduction off
|
|||
|
|
|
|||
|
|
txBxIris_Click(sender, e); // Reset values through btn clicks.
|
|||
|
|
txBxGain_Click(sender, e);
|
|||
|
|
txBxShutter_Click(sender, e);
|
|||
|
|
|
|||
|
|
TxBxSharp_Click(sender, e);
|
|||
|
|
TxBxGamma_Click(sender, e);
|
|||
|
|
TxBxContrast_Click(sender, e);
|
|||
|
|
TxBxNR_Click(sender, e);
|
|||
|
|
|
|||
|
|
FocusNow_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.Enabled = true;
|
|||
|
|
BtnDefConfig.BackColor = Color.LightGreen;
|
|||
|
|
DefConfig = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnFullscreenANPR_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (FullscreenANPR == false)
|
|||
|
|
{
|
|||
|
|
LastLoc = new Point(this.Left, this.Top);
|
|||
|
|
this.Location = new Point(0, 0);
|
|||
|
|
this.FormBorderStyle = FormBorderStyle.None;
|
|||
|
|
ActiveForm.Size = new Size(Screen.FromControl(this).Bounds.Width, Screen.FromControl(this).Bounds.Height);
|
|||
|
|
videoViewANPR.Size = new Size(ActiveForm.Width, ActiveForm.Height);
|
|||
|
|
videoViewANPR.Location = new Point(0, 0);
|
|||
|
|
videoViewANPR.BringToFront();
|
|||
|
|
GpBxANPR.Location = new Point(0, 0);
|
|||
|
|
GpBxANPR.BringToFront();
|
|||
|
|
BtnFullscreenANPR.Text = "Minimise";
|
|||
|
|
BtnLVANPR.Enabled = false;
|
|||
|
|
FullscreenANPR = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (AdvancedOpen == true)
|
|||
|
|
{
|
|||
|
|
this.Size = new Size(1240, 745);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.Size = new Size(960, 745);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (LastLoc.X > 0 && LastLoc.X < this.Width && LastLoc.Y > 0 && LastLoc.Y < this.Height)
|
|||
|
|
{
|
|||
|
|
this.Location = LastLoc;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.Location = new Point(0, 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.FormBorderStyle = FormBorderStyle.FixedDialog;
|
|||
|
|
|
|||
|
|
GpBxANPR.Location = new Point(543, 400);
|
|||
|
|
videoViewANPR.Size = new Size(400, 230);
|
|||
|
|
videoViewANPR.Location = new Point(549, 505);
|
|||
|
|
BtnFullscreenANPR.Text = "Fullscreen";
|
|||
|
|
BtnLVANPR.Enabled = true;
|
|||
|
|
FullscreenANPR = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnFullscreenOV_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (FullscreenOV == false)
|
|||
|
|
{
|
|||
|
|
LastLoc = new Point(this.Left, this.Top);
|
|||
|
|
this.Location = new Point(0, 0);
|
|||
|
|
this.FormBorderStyle = FormBorderStyle.None;
|
|||
|
|
ActiveForm.Size = new Size(Screen.FromControl(this).Bounds.Width, Screen.FromControl(this).Bounds.Height);
|
|||
|
|
videoViewOV.Size = new Size(ActiveForm.Width, ActiveForm.Height);
|
|||
|
|
videoViewOV.Location = new Point(0, 0);
|
|||
|
|
videoViewOV.BringToFront();
|
|||
|
|
GpBxOV.Location = new Point(0, 0);
|
|||
|
|
GpBxOV.BringToFront();
|
|||
|
|
BtnFullscreenOV.Text = "Minimise";
|
|||
|
|
BtnLVOview.Enabled = false;
|
|||
|
|
FullscreenOV = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (AdvancedOpen == true)
|
|||
|
|
{
|
|||
|
|
this.Size = new Size(1240, 745);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.Size = new Size(960, 745);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (LastLoc.X > 0 && LastLoc.X < this.Width && LastLoc.Y > 0 && LastLoc.Y < this.Height)
|
|||
|
|
{
|
|||
|
|
this.Location = LastLoc;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.Location = new Point(0, 0);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.FormBorderStyle = FormBorderStyle.FixedDialog;
|
|||
|
|
GpBxOV.Location = new Point(543, 30);
|
|||
|
|
videoViewOV.Size = new Size(400, 230);
|
|||
|
|
videoViewOV.Location = new Point(548, 136);
|
|||
|
|
BtnFullscreenOV.Text = "Fullscreen";
|
|||
|
|
BtnLVOview.Enabled = true;
|
|||
|
|
FullscreenOV = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void trackBarZoom_ValueChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
txBxZoom2.Text = Convert.ToString(Convert.ToInt16(trackBarZoom.Value / 1638.4));
|
|||
|
|
txBxZoom.Text = trackBarZoom.Value.ToString("X4");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void trackBarFocus_ValueChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
TxBxFocus2.Text = Convert.ToString(Convert.ToInt16((trackBarFocus.Value - 256) / 6502.4));
|
|||
|
|
txBxFocus.Text = trackBarFocus.Value.ToString("X4");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxGainLim_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqGainLim, 1, TxBxGainLim, true);
|
|||
|
|
TkBrGain.Value = Convert.ToInt16(int.Parse(TxBxGainLim.Text, NumberStyles.HexNumber) * 4.6);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnLVOview_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (LVOV == false)
|
|||
|
|
{
|
|||
|
|
ActiveForm.Size = new Size(this.Width + sizedif, this.Height);
|
|||
|
|
videoViewOV.Size = new Size(1113, 780);
|
|||
|
|
|
|||
|
|
videoViewOV.Location = new Point(195, 30);
|
|||
|
|
videoViewOV.BringToFront();
|
|||
|
|
GpBxOV.Location = new Point(195, 30);
|
|||
|
|
GpBxOV.BringToFront();
|
|||
|
|
BtnLVOview.Text = "Minimise";
|
|||
|
|
GpBxAdCont.Location = new Point(GpBxAdCont.Location.X + sizedif, GpBxAdCont.Location.Y);
|
|||
|
|
GpBxFrame.Location = new Point(GpBxFrame.Location.X + sizedif, GpBxFrame.Location.Y);
|
|||
|
|
GpBxMins.Location = new Point(GpBxMins.Location.X + sizedif, GpBxMins.Location.Y);
|
|||
|
|
GpBxOSD.Location = new Point(GpBxOSD.Location.X + sizedif, GpBxOSD.Location.Y);
|
|||
|
|
LVOV = true;
|
|||
|
|
BtnFullscreenOV.Enabled = false;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
GpBxAdCont.Location = new Point(GpBxAdCont.Location.X - sizedif, GpBxAdCont.Location.Y);
|
|||
|
|
GpBxFrame.Location = new Point(GpBxFrame.Location.X - sizedif, GpBxFrame.Location.Y);
|
|||
|
|
GpBxOSD.Location = new Point(GpBxOSD.Location.X - sizedif, GpBxOSD.Location.Y);
|
|||
|
|
GpBxMins.Location = new Point(GpBxMins.Location.X - sizedif, GpBxMins.Location.Y);
|
|||
|
|
|
|||
|
|
if (AdvancedOpen == true)
|
|||
|
|
{
|
|||
|
|
this.Size = new Size(1256, 780);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.Size = new Size(980, 780);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GpBxOV.Location = new Point(543, 30);
|
|||
|
|
videoViewOV.Size = new Size(400, 230);
|
|||
|
|
videoViewOV.Location = new Point(548, 136);
|
|||
|
|
BtnLVOview.Text = "Larger Video";
|
|||
|
|
BtnFullscreenOV.Enabled = true;
|
|||
|
|
LVOV = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnLVANPR_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (LVANPR == false)
|
|||
|
|
{
|
|||
|
|
ActiveForm.Size = new Size(this.Width + sizedif, this.Height);
|
|||
|
|
videoViewANPR.Size = new Size(1113, 780);
|
|||
|
|
videoViewANPR.Location = new Point(195, 30);
|
|||
|
|
videoViewANPR.BringToFront();
|
|||
|
|
GpBxANPR.Location = new Point(195, 30);
|
|||
|
|
GpBxANPR.BringToFront();
|
|||
|
|
BtnLVANPR.Text = "Minimise";
|
|||
|
|
GpBxAdCont.Location = new Point(GpBxAdCont.Location.X + sizedif, GpBxAdCont.Location.Y);
|
|||
|
|
GpBxFrame.Location = new Point(GpBxFrame.Location.X + sizedif, GpBxFrame.Location.Y);
|
|||
|
|
GpBxOSD.Location = new Point(GpBxOSD.Location.X + sizedif, GpBxOSD.Location.Y);
|
|||
|
|
GpBxMins.Location = new Point(GpBxMins.Location.X + sizedif, GpBxMins.Location.Y);
|
|||
|
|
|
|||
|
|
LVANPR = true;
|
|||
|
|
BtnFullscreenANPR.Enabled = false;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
GpBxAdCont.Location = new Point(GpBxAdCont.Location.X - sizedif, GpBxAdCont.Location.Y);
|
|||
|
|
GpBxFrame.Location = new Point(GpBxFrame.Location.X - sizedif, GpBxFrame.Location.Y);
|
|||
|
|
GpBxOSD.Location = new Point(GpBxOSD.Location.X - sizedif, GpBxOSD.Location.Y);
|
|||
|
|
GpBxMins.Location = new Point(GpBxMins.Location.X - sizedif, GpBxMins.Location.Y);
|
|||
|
|
|
|||
|
|
if (AdvancedOpen == true)
|
|||
|
|
{
|
|||
|
|
this.Size = new Size(1256, 780);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.Size = new Size(980, 780);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GpBxANPR.Location = new Point(543, 400);
|
|||
|
|
videoViewANPR.Size = new Size(400, 230);
|
|||
|
|
videoViewANPR.Location = new Point(549, 505);
|
|||
|
|
BtnLVANPR.Text = "Larger Video";
|
|||
|
|
BtnFullscreenANPR.Enabled = true;
|
|||
|
|
LVANPR = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnWebpage_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
CamIP = IPMatch(comboBox_Devices2, txBxManualIpOv);
|
|||
|
|
Process.Start("http://" + CamIP);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnWebpageANPR_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
CamIP = IPMatch(comboBox_Devices, txBxManualIP);
|
|||
|
|
Process.Start("http://" + CamIP);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnPsuOn_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
BtnSetPSU_Click(sender, e); // Makes sure it is off, then sets voltage and current limits.
|
|||
|
|
Thread.Sleep(500);
|
|||
|
|
|
|||
|
|
if (SendDataPsu("OP1 1"))
|
|||
|
|
{
|
|||
|
|
btnPsuOff.BackColor = Color.Transparent;
|
|||
|
|
btnPsuOn.BackColor = Color.Green;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnPsuOff_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (SendDataPsu("OP1 0"))
|
|||
|
|
{
|
|||
|
|
btnPsuOff.BackColor = Color.Green;
|
|||
|
|
btnPsuOn.BackColor = Color.Transparent;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnSetPSU_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
btnPsuOff_Click(sender, e);
|
|||
|
|
SendDataPsu("I1 3.5");
|
|||
|
|
SendDataPsu("V1 15");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private bool SendDataPsu(string dataTx)
|
|||
|
|
{
|
|||
|
|
if (TxBxPSUIP.BackColor == Color.Red)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Not a valid PSU IP address");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Socket psuSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
|||
|
|
|
|||
|
|
if (!psuSocket.Connected)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
IAsyncResult result = psuSocket.BeginConnect(TxBxPSUIP.Text, 9221, null, null);
|
|||
|
|
bool success = result.AsyncWaitHandle.WaitOne(1000, true);
|
|||
|
|
|
|||
|
|
if (!psuSocket.Connected)
|
|||
|
|
{
|
|||
|
|
psuSocket.Close();
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
psuSocket.Close();
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
psuSocket.Send(Encoding.ASCII.GetBytes(dataTx + "\n"));
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
psuSocket.Close();
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void AdjustIrisLimit(int delta, object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (delta < 0)
|
|||
|
|
BtnIrisLimDown.Enabled = true;
|
|||
|
|
else
|
|||
|
|
BtnIrisLimUp.Enabled = true;
|
|||
|
|
|
|||
|
|
if (TxBxIrisLim.Text.Length == 0)
|
|||
|
|
{
|
|||
|
|
TxBxIrisLim_Click(sender, e);
|
|||
|
|
WaitMs(100);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int IrisLimValue = int.Parse(IrisLimitHex, NumberStyles.HexNumber) - delta;
|
|||
|
|
|
|||
|
|
if (!IrisLimDirect(IrisLimValue)) // Sends direct of returns false if iris limit out of range
|
|||
|
|
{
|
|||
|
|
IrisLimitHex = "0A";
|
|||
|
|
IrisLimValue = int.Parse(IrisLimitHex, NumberStyles.HexNumber) - 1;
|
|||
|
|
IrisLimDirect(IrisLimValue);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TxBxIrisLim_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnIrisLimUp_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
AdjustIrisLimit(-1, sender, e); // Limit is reversed
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnIrisLimDown_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
AdjustIrisLimit(1, sender, e); // Limit is reversed
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private bool IrisLimDirect(int IrisLimValue)
|
|||
|
|
{
|
|||
|
|
if (IrisLimValue >= 0 && IrisLimValue <= 20)
|
|||
|
|
{
|
|||
|
|
if (CameraModule == Module.MC105) // Does iris min and max, only min is malleable
|
|||
|
|
{
|
|||
|
|
byte[] viscaIrisLimDirect = VISCACommand(0x05, 0x24, 0x4B, 0x01, 0x00, Convert.ToByte(IrisLimValue), 0x11);
|
|||
|
|
SendVISCA(viscaIrisLimDirect);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
byte[] viscaIrisLimDirect = VISCACommand(0x70, 0xD3, 0x00, 0x00, 0x00, 0x00, Convert.ToByte(IrisLimValue), 0x00, Convert.ToByte(IrisLimValue), 0x00);
|
|||
|
|
SendVISCA(viscaIrisLimDirect);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxIrisLim_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
BtnIrisLimUp.Enabled = BtnIrisLimDown.Enabled = true;
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqIrisLimWW, 4, TxBxIrisLim, true);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaInqIrisLim, 4, TxBxIrisLim, true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try // In case inquiry fails.
|
|||
|
|
{
|
|||
|
|
TxBxIrisLim.Text = TxBxIrisLim.Text.Substring(0, 2);
|
|||
|
|
IrisLimitHex = TxBxIrisLim.Text;
|
|||
|
|
ConvertIris(TxBxIrisLim);
|
|||
|
|
|
|||
|
|
if (TxBxIrisLim.Text == "F22")
|
|||
|
|
{
|
|||
|
|
BtnIrisLimUp.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (TxBxIrisLim.Text == "F2.4")
|
|||
|
|
{
|
|||
|
|
BtnIrisLimDown.Enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void DisableTibboControls()
|
|||
|
|
{
|
|||
|
|
TkBarLED.Enabled = TxBxLEDCurrent.Enabled = GpBxSerial.Enabled = gbBx4ChMonitor.Enabled = gbxIlluminator.Enabled = false;
|
|||
|
|
stopLedMonitor();
|
|||
|
|
|
|||
|
|
richTxBxRxCmd.Text = TxBxRxErrMssg.Text = "";
|
|||
|
|
btnIllumOn.BackColor = btnIllumOff.BackColor = BtnColour;
|
|||
|
|
|
|||
|
|
if (serialPort1.IsOpen)
|
|||
|
|
{
|
|||
|
|
serialPort1.Close();
|
|||
|
|
btnClosePort.BackColor = BtnColour;
|
|||
|
|
btnClosePort.Text = "Open Last Port";
|
|||
|
|
foreach (ToolStripMenuItem item in tsmenuSelectCom.DropDownItems) // clear currently checked items
|
|||
|
|
{
|
|||
|
|
item.Checked = false;
|
|||
|
|
}
|
|||
|
|
tsmenuSelectCom.Text = "Select COM Port";
|
|||
|
|
tsmenuSelectCom.BackColor = BtnColour;
|
|||
|
|
GetPorts();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (selectedPort == "")
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("No port selected", "Port select");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach (ToolStripMenuItem item in tsmenuSelectCom.DropDownItems)
|
|||
|
|
{
|
|||
|
|
if (item.Text == selectedPort)
|
|||
|
|
{
|
|||
|
|
item.Checked = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
item.Checked = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
btnClosePort.Text = "Close Port";
|
|||
|
|
btnClosePort.BackColor = Color.LightGreen;
|
|||
|
|
serialPort1.Open();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void EnableTibboControls()
|
|||
|
|
{
|
|||
|
|
TkBarLED.Enabled = TxBxLEDCurrent.Enabled = GpBxSerial.Enabled = gbBx4ChMonitor.Enabled = gbxIlluminator.Enabled = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxManVISCA_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (TxBxManVISCA.Text == "81 xx xx xx xx FF")
|
|||
|
|
{
|
|||
|
|
TxBxManVISCA.Text = "";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxManVISCA_KeyDown(object sender, KeyEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.KeyValue == 13 && BtnSendVISCA.Enabled == true) // Hit enter and string is valid
|
|||
|
|
{
|
|||
|
|
BtnSendVISCA_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxManVISCA_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
BtnSendVISCA.Enabled = false;
|
|||
|
|
|
|||
|
|
if (RegexVISCA.IsMatch(TxBxManVISCA.Text))
|
|||
|
|
{
|
|||
|
|
BtnSendVISCA.Enabled = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnSendVISCA_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (RegexVISCA.IsMatch(TxBxManVISCA.Text))
|
|||
|
|
{
|
|||
|
|
string ManualVISCAString = TxBxManVISCA.Text.Replace(" ", "").ToUpper();
|
|||
|
|
string AVML_VAR = "#" + ManualVISCAString; // For HD:IP Mk1
|
|||
|
|
|
|||
|
|
byte[] ManVISCA = { 0x01, 0x10, 0x00, Convert.ToByte(ManualVISCAString.Length / 2), 0x00, 0x00, 0x00, 0x01 };
|
|||
|
|
byte[] OtherByteArray = TxBxManVISCA.Text.Split(' ').Select(item => Convert.ToByte(item, 16)).ToArray();
|
|||
|
|
byte[] ManToSend = Combine(ManVISCA, OtherByteArray);
|
|||
|
|
|
|||
|
|
SendVISCA(ManToSend, 0, TxBxRecManVISCA, false, AVML_VAR, 1);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Incorrect format, please use format" + Environment.NewLine + "'81 xx xx xx xx FF'");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static byte[] Combine(byte[] first, byte[] second)
|
|||
|
|
{
|
|||
|
|
byte[] bytes = new byte[first.Length + second.Length];
|
|||
|
|
Buffer.BlockCopy(first, 0, bytes, 0, first.Length);
|
|||
|
|
Buffer.BlockCopy(second, 0, bytes, first.Length, second.Length);
|
|||
|
|
return bytes;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TkBrGain_MouseUp(object sender, MouseEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
byte b = Convert.ToByte(TkBrGain.Value); // b == 0xpq
|
|||
|
|
|
|||
|
|
byte p = (byte)((b >> 4) & 0x0F); // 0x0p (upper nibble)
|
|||
|
|
byte q = (byte)(b & 0x0F); // 0x0q (lower nibble)
|
|||
|
|
|
|||
|
|
byte[] viscaWWGainLim = VISCACommand(0x04, 0x2C, p, q);
|
|||
|
|
SendVISCA(viscaWWGainLim);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
byte[] viscaGainLimDirect = VISCACommand(0x04, 0x2C, Convert.ToByte(TkBrGain.Value));
|
|||
|
|
SendVISCA(viscaGainLimDirect);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TxBxGainLim_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TkBrShutLim_MouseUp(object sender, MouseEventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaMinShutterOn);
|
|||
|
|
|
|||
|
|
byte value = (byte)TkBrShutLim.Value;
|
|||
|
|
|
|||
|
|
// Encode value into two bytes, big-endian
|
|||
|
|
byte high = (byte)((value >> 4) & 0x0F);
|
|||
|
|
byte low = (byte)(value & 0x0F);
|
|||
|
|
|
|||
|
|
byte[] ShutterLimVISCA = VISCACommand(0x04, 0x13, 0x00, 0x00, high, low);
|
|||
|
|
SendVISCA(ShutterLimVISCA);
|
|||
|
|
TxBxShutLim_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxShutLim_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaMinShutterInq, 2, TxBxShutLim, false);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
TkBrShutLim.Value = Convert.ToInt32(TxBxShutLim.Text, 16);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
byte[] viscaShutterMinDirect = VISCACommand(0x04, 0x13, 0x00, 0x00, 0x00, Convert.ToByte(TkBrShutLim.Value));
|
|||
|
|
SendVISCA(viscaShutterMinDirect);
|
|||
|
|
SendVISCA(viscaMinShutterInq, 2, TxBxShutLim, false);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
TkBrShutLim.Value = Convert.ToInt32(TxBxShutLim.Text, 16);
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
ConvertShutter(TxBxShutLim);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnDISOn_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaDISOn);
|
|||
|
|
BtnDISOn.BackColor = Color.LightGreen;
|
|||
|
|
BtnDISOff.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnDISOff_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaDISOff);
|
|||
|
|
BtnDISOff.BackColor = Color.LightGreen;
|
|||
|
|
BtnDISOn.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string IPMatch(ComboBox CmBx, TextBox TxBx)
|
|||
|
|
{
|
|||
|
|
if (RegexIPPattern.IsMatch(CmBx.Text)) // Combobox has valid IP address
|
|||
|
|
{
|
|||
|
|
return CmBx.Text;
|
|||
|
|
}
|
|||
|
|
else if (RegexIPPattern.IsMatch(TxBx.Text)) // Manual textbox has valid IP address
|
|||
|
|
{
|
|||
|
|
return TxBx.Text;
|
|||
|
|
}
|
|||
|
|
else // Don't know what IP address to use
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Please select a camera");
|
|||
|
|
return "False";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnSetH264_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
BtnSetH264.BackColor = SystemColors.ControlLightLight;
|
|||
|
|
|
|||
|
|
CamIP = IPMatch(comboBox_Devices2, txBxManualIpOv);
|
|||
|
|
|
|||
|
|
if (CamIP == "False")
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string Resolution = "1280x720";
|
|||
|
|
string gopSize = "30";
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.HZ5512 || CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
Resolution = "1920x1080";
|
|||
|
|
gopSize = "45";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string responseText = HTTPAPIrequest(CamIP, $"/cgi-bin/action.fcgi?api=set_setup.video.codec&codec0=h264&profile0=High&resolution0={Resolution}&fps0=30&gopsize0={gopSize}&bitctrl0=VBR&image_quality0=mid&bitavr0=10000&ff_mode=60");
|
|||
|
|
|
|||
|
|
if (!responseText.Contains("return_code=0x00000000"))
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("API failure setting H264. Code: " + responseText.Substring(responseText.IndexOf("return_code"), 22));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnSetH264.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnSetMJPEGANPR_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
BtnSetMJPEGANPR.BackColor = SystemColors.ControlLightLight;
|
|||
|
|
|
|||
|
|
CamIP = IPMatch(comboBox_Devices, txBxManualIP);
|
|||
|
|
|
|||
|
|
if (CamIP == "False")
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string Resolution = "1280x720";
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.HZ5512)
|
|||
|
|
{
|
|||
|
|
Resolution = "1920x1080";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string responseText = HTTPAPIrequest(CamIP, $"/cgi-bin/action.fcgi?api=set_setup.video.codec&codec0=mjpeg&resolution0={Resolution}&fps0=15&jpegqual=65&ff_mode=60");
|
|||
|
|
|
|||
|
|
if (!responseText.Contains("return_code=0x00000000"))
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("API failure setting MJPEG. Code: " + responseText.Substring(responseText.IndexOf("return_code"), 22));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnSetMJPEGANPR.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnSetIPOV_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SetIP("112", "254", comboBox_Devices2, txBxManualIpOv, BtnSetIPOV);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnSetIPANPR_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SetIP("111", "254", comboBox_Devices, txBxManualIP, BtnSetIPANPR);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SetIP(string IP, string gateway, ComboBox CBx, TextBox TxBx, Button Btn)
|
|||
|
|
{
|
|||
|
|
Btn.BackColor = SystemColors.ControlLightLight;
|
|||
|
|
|
|||
|
|
CamIP = IPMatch(CBx, TxBx);
|
|||
|
|
|
|||
|
|
if (CamIP == "False")
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string responseText = HTTPAPIrequest(CamIP, $"/cgi-bin/action.fcgi?api=set_setup.network.ipsetup&dhcpon=no&ipaddr=192.168.1.{IP}&subnet=255.255.255.0&gateway=192.168.1.{gateway}");
|
|||
|
|
|
|||
|
|
if (!responseText.Contains("return_code=0x00000000"))
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("API failure setting IP. Code: " + responseText.Substring(responseText.IndexOf("return_code"), 22));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Btn.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxGainLim_KeyDown(object sender, KeyEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (e.KeyValue == 13 && TxBxGainLim.Text.Length < 3 && MAVCopy == true)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
TkBrGain.Value = Convert.ToInt16(TxBxGainLim.Text, 16);
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnWDROn_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaWDROnWW); // Wide Dynamic Range on
|
|||
|
|
SendVISCA(viscaWDRManualWW); // Manual mode
|
|||
|
|
SendVISCA(viscaWDRInqWW, 1, TxBxReply, false);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaWDROn); // Wide Dynamic Range on
|
|||
|
|
SendVISCA(viscaWDRInq, 2, TxBxReply, false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnWDRLvlDown.Enabled = BtnWDRLvlUp.Enabled = true;
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.Contains("2"))
|
|||
|
|
{
|
|||
|
|
BtnWDROn.BackColor = Color.LightGreen;
|
|||
|
|
BtnWDROff.BackColor = SystemColors.ControlLightLight;
|
|||
|
|
BtnBrightnessReset.Enabled = BtnExpCompDown.Enabled = BtnExpCompOff.Enabled = BtnExpCompOn.Enabled = BtnExpCompUp.Enabled =
|
|||
|
|
TxBxExpComp.Enabled = btnIrisClose.Enabled = txBxIris.Enabled = btnIrisUp.Enabled = BtnGainDown.Enabled =
|
|||
|
|
txBxGain.Enabled = BtnGainUp.Enabled = BtnShutterDown.Enabled = txBxShutter.Enabled = BtnShutterUp.Enabled = false;
|
|||
|
|
txBxShutter.Text = txBxGain.Text = txBxIris.Text = "-";
|
|||
|
|
TxBxWDRLvl_Click(sender, e);
|
|||
|
|
BtnExpManual.BackColor = BtnAutoExp.BackColor = BtnExpShtrPri.BackColor = BtnColour;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnWDROff_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaWDROffWW); // Wide Dynamic Range on
|
|||
|
|
SendVISCA(viscaWDRInqWW, 1, TxBxReply, false);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaWDROff); // Wide Dynamic Range on
|
|||
|
|
SendVISCA(viscaWDRInq, 2, TxBxReply, false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnWDRLvlDown.Enabled = BtnWDRLvlUp.Enabled = false;
|
|||
|
|
TxBxWDRLvl.Text = "-";
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.Contains("3"))
|
|||
|
|
{
|
|||
|
|
BtnWDROff.BackColor = Color.LightGreen;
|
|||
|
|
BtnWDROn.BackColor = SystemColors.ControlLightLight;
|
|||
|
|
BtnBrightnessReset.Enabled = BtnExpCompDown.Enabled = BtnExpCompOff.Enabled = BtnExpCompOn.Enabled = BtnExpCompUp.Enabled =
|
|||
|
|
TxBxExpComp.Enabled = btnIrisClose.Enabled = txBxIris.Enabled = btnIrisUp.Enabled = BtnGainDown.Enabled =
|
|||
|
|
txBxGain.Enabled = BtnGainUp.Enabled = BtnShutterDown.Enabled = txBxShutter.Enabled = BtnShutterUp.Enabled = true;
|
|||
|
|
SendVISCA(viscaInqExpMode, 2, TxBxReply, false, "AM?", 1);
|
|||
|
|
|
|||
|
|
if (TxBxReply.Text.Contains("0"))
|
|||
|
|
{
|
|||
|
|
BtnAutoExp.BackColor = Color.LightGreen;
|
|||
|
|
BtnExpManual.BackColor = BtnExpShtrPri.BackColor = BtnColour;
|
|||
|
|
btnIrisClose.Enabled = txBxIris.Enabled = btnIrisUp.Enabled = BtnGainDown.Enabled = txBxGain.Enabled =
|
|||
|
|
BtnGainUp.Enabled = BtnShutterDown.Enabled = txBxShutter.Enabled = BtnShutterUp.Enabled = false;
|
|||
|
|
txBxShutter.Text = txBxGain.Text = txBxIris.Text = "-";
|
|||
|
|
TxBxGainLim.Enabled = TkBrGain.Enabled = true;
|
|||
|
|
TxBxGainLim_Click(sender, e);
|
|||
|
|
TxBxShutLim_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("3"))
|
|||
|
|
{
|
|||
|
|
BtnExpManual.BackColor = Color.LightGreen;
|
|||
|
|
BtnAutoExp.BackColor = BtnExpShtrPri.BackColor = BtnColour;
|
|||
|
|
btnIrisClose.Enabled = txBxIris.Enabled = btnIrisUp.Enabled = BtnGainDown.Enabled = txBxGain.Enabled =
|
|||
|
|
BtnGainUp.Enabled = BtnShutterDown.Enabled = txBxShutter.Enabled = BtnShutterUp.Enabled = true;
|
|||
|
|
TxBxGainLim.Enabled = TkBrGain.Enabled = false;
|
|||
|
|
TxBxGainLim.Text = "-";
|
|||
|
|
txBxIris_Click(sender, e);
|
|||
|
|
txBxGain_Click(sender, e);
|
|||
|
|
txBxShutter_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
else if (TxBxReply.Text.Contains("A"))
|
|||
|
|
{
|
|||
|
|
BtnExpShtrPri.BackColor = Color.LightGreen;
|
|||
|
|
BtnAutoExp.BackColor = BtnExpManual.BackColor = BtnColour;
|
|||
|
|
btnIrisClose.Enabled = txBxIris.Enabled = btnIrisUp.Enabled = BtnGainDown.Enabled = txBxGain.Enabled = BtnGainUp.Enabled = false;
|
|||
|
|
BtnShutterDown.Enabled = txBxShutter.Enabled = BtnShutterUp.Enabled = TxBxGainLim.Enabled = TkBrGain.Enabled = true;
|
|||
|
|
txBxGain.Text = txBxIris.Text = "-";
|
|||
|
|
txBxShutter_Click(sender, e);
|
|||
|
|
TxBxGainLim_Click(sender, e);
|
|||
|
|
TxBxShutLim_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnCMSet_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendCmd("CM@GE67SA", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnCMQuery_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
SendCmd("CM?", 1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private int Clamp(int val, int min, int max)
|
|||
|
|
{
|
|||
|
|
if (val.CompareTo(min) < 0) return min;
|
|||
|
|
else if (val.CompareTo(max) > 0) return max;
|
|||
|
|
else return val;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void WWDWDRChange(bool wider, object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
int WDRValueBright = int.Parse(TxBxWDRLvl.Text.Substring(0, TxBxWDRLvl.Text.IndexOf(" ")), NumberStyles.HexNumber);
|
|||
|
|
int WDRValueDark = int.Parse(TxBxWDRLvl.Text.Substring(TxBxWDRLvl.Text.LastIndexOf(" ") + 1), NumberStyles.HexNumber);
|
|||
|
|
|
|||
|
|
if (wider)
|
|||
|
|
{
|
|||
|
|
WDRValueBright -= 1;
|
|||
|
|
WDRValueDark += 1;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
WDRValueBright += 1;
|
|||
|
|
WDRValueDark -= 1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WDRValueBright = Clamp(WDRValueBright, 1, 15);
|
|||
|
|
WDRValueDark = Clamp(WDRValueDark, 1, 15);
|
|||
|
|
|
|||
|
|
byte BrightByte = Convert.ToByte(WDRValueBright);
|
|||
|
|
byte DarkByte = Convert.ToByte(WDRValueDark);
|
|||
|
|
|
|||
|
|
byte[] viscaWWDWDRBright = VISCACommand(0x04, 0x1A, 0x50, 0x00, BrightByte);
|
|||
|
|
SendVISCA(viscaWWDWDRBright);
|
|||
|
|
byte[] viscaWWDWDRDark = VISCACommand(0x04, 0x1A, 0x40, 0x00, DarkByte);
|
|||
|
|
SendVISCA(viscaWWDWDRDark);
|
|||
|
|
Thread.Sleep(100);
|
|||
|
|
TxBxWDRLvl_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnWDRLvlUp_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
AdjustWDRLevel(+1, sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnWDRLvlDown_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
AdjustWDRLevel(-1, sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void AdjustWDRLevel(int delta, object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (TxBxWDRLvl.Text == null)
|
|||
|
|
{
|
|||
|
|
TxBxWDRLvl_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
WWDWDRChange(delta > 0, sender, e);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int WDRValue;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
WDRValue = Convert.ToInt16(TxBxWDRLvl.Text) + delta;
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
WDRValue = int.Parse(TxBxWDRLvl.Text, NumberStyles.HexNumber) + delta;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (WDRValue >= 0 && WDRValue <= 29)
|
|||
|
|
{
|
|||
|
|
byte Lvl = Convert.ToByte(WDRValue);
|
|||
|
|
byte[] viscaWDRLvl = VISCACommand(0x70, 0x3A, Lvl);
|
|||
|
|
SendVISCA(viscaWDRLvl);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TxBxWDRLvl_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxWDRLvl_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (CameraModule == Module.KTnC || CameraModule == Module.HZ5510 || CameraModule == Module.HZ5512)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaWDRLevelInq, 1, TxBxWDRLvl, true);
|
|||
|
|
}
|
|||
|
|
else if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaWDRLvllInqBWW, 1, TxBxReply, true); // Bright
|
|||
|
|
SendVISCA(viscaWDRLvllInqDWW, 1, TxBxWDRLvl, true); // Dark
|
|||
|
|
TxBxWDRLvl.Text = TxBxReply.Text + " - " + TxBxWDRLvl.Text;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void PrintToZebra(string stingToPrint)
|
|||
|
|
{
|
|||
|
|
if (TxBxZebraIP.BackColor == Color.Red)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Not a valid Zebra IP address");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
TcpClient client = new TcpClient(); // Open connection
|
|||
|
|
client.Connect(TxBxZebraIP.Text, 9100);
|
|||
|
|
StreamWriter writer = new StreamWriter(client.GetStream()); // Write ZPL String to connection
|
|||
|
|
writer.Write(stingToPrint);
|
|||
|
|
writer.Flush();
|
|||
|
|
writer.Close(); // Close Connection
|
|||
|
|
client.Close();
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Failed to print");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void UpdateSpreadSheet(string model)
|
|||
|
|
{
|
|||
|
|
string streamPath = @"G:\Shared drives\MAV Production GUI's\RMA GUI\client_secret_RMA.json";
|
|||
|
|
string credPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
|||
|
|
string[] Scopes = { SheetsService.Scope.Spreadsheets };
|
|||
|
|
|
|||
|
|
UserCredential credential;
|
|||
|
|
|
|||
|
|
using (FileStream stream = new FileStream(streamPath, FileMode.Open, FileAccess.Read))
|
|||
|
|
{
|
|||
|
|
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(GoogleClientSecrets.FromStream(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SheetsService service = new SheetsService(new BaseClientService.Initializer()
|
|||
|
|
{
|
|||
|
|
HttpClientInitializer = credential,
|
|||
|
|
ApplicationName = "Google Sheets API .NET Quickstart",
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
string spreadsheetId = "12wl8BF5AXRMNNgs7_S8Ipneur9AG2iI0jQFzf75J4Wc"; // HD:IP Mk2 by default
|
|||
|
|
string camdesc = "Camera - MAV HD:IP MK2, Dual Zoom 10x HD";
|
|||
|
|
|
|||
|
|
if (model == "YT65JG")
|
|||
|
|
{
|
|||
|
|
spreadsheetId = "1nrdMrUnmO4WrZkZCKgnGlCRxFniQ4YhgYPShPN0bygM"; // FHD:IP Mk2
|
|||
|
|
camdesc = "Camera - Rapier FHD:IP Dual Zoom 12x FHD/1080p IP Encoders.";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
IList<IList<object>> values = service.Spreadsheets.Values.Get(spreadsheetId, "B1:B").Execute().Values;
|
|||
|
|
|
|||
|
|
if (values != null && values.Count > 0)
|
|||
|
|
{
|
|||
|
|
int nextRow = values.Count + 1;
|
|||
|
|
string lastSerialNumberLocation = "B" + Convert.ToString(values.Count) + ":B" + Convert.ToString(values.Count);
|
|||
|
|
values = service.Spreadsheets.Values.Get(spreadsheetId, lastSerialNumberLocation).Execute().Values;
|
|||
|
|
|
|||
|
|
if (values != null && values.Count > 0)
|
|||
|
|
{
|
|||
|
|
string lastSerialNumberString = "";
|
|||
|
|
|
|||
|
|
foreach (IList<object> row in values)
|
|||
|
|
{
|
|||
|
|
lastSerialNumberString = Convert.ToString(row[0]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
int newSerialNumberInt = Convert.ToInt32(lastSerialNumberString.Substring(1).Replace(" ", "")) + 1;
|
|||
|
|
newSerialNumberString = "K" + Convert.ToString(newSerialNumberInt);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
TestFail("Integer conversion failure");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string date = DateTime.Now.ToString().Substring(0, 10);
|
|||
|
|
|
|||
|
|
List<object> oblistAF = new List<object>() { model, newSerialNumberString, camdesc, date, SoftwareVer };
|
|||
|
|
ValueRange ValueRange = new ValueRange { Values = new List<IList<object>> { oblistAF } };
|
|||
|
|
SpreadsheetsResource.ValuesResource.UpdateRequest Update = service.Spreadsheets.Values.Update(ValueRange, spreadsheetId, "A" + nextRow + ":F" + nextRow);
|
|||
|
|
Update.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.RAW;
|
|||
|
|
Update.Execute();
|
|||
|
|
|
|||
|
|
ValueRange ValueRangeNotes = new ValueRange { Values = new List<IList<object>> { new List<object>() { "GUI Version: " + GUIVersion } } };
|
|||
|
|
SpreadsheetsResource.ValuesResource.UpdateRequest UpdateNotes = service.Spreadsheets.Values.Update(ValueRangeNotes, spreadsheetId, "K" + nextRow);
|
|||
|
|
UpdateNotes.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.RAW;
|
|||
|
|
UpdateNotes.Execute();
|
|||
|
|
|
|||
|
|
ValueRange ValueRangeESV = new ValueRange { Values = new List<IList<object>> { new List<object>() { EncoderSoftVer } } };
|
|||
|
|
SpreadsheetsResource.ValuesResource.UpdateRequest UpdateESV = service.Spreadsheets.Values.Update(ValueRangeESV, spreadsheetId, "P" + nextRow);
|
|||
|
|
UpdateESV.ValueInputOption = SpreadsheetsResource.ValuesResource.UpdateRequest.ValueInputOptionEnum.RAW;
|
|||
|
|
UpdateESV.Execute();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private bool CheckCamReboot(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
bool camFound = false;
|
|||
|
|
timerCheckReboot.Enabled = true;
|
|||
|
|
|
|||
|
|
while (camFound == false && timerCheckReboot.Enabled == true)
|
|||
|
|
{
|
|||
|
|
Application.DoEvents();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (PingIP("192.168.1.111") && PingIP("192.168.1.112"))
|
|||
|
|
{
|
|||
|
|
WaitMs(5000);
|
|||
|
|
DiscoverEncoders(sender, e);
|
|||
|
|
|
|||
|
|
bool Found111 = false;
|
|||
|
|
bool Found112 = false;
|
|||
|
|
|
|||
|
|
foreach (object OBJ in comboBox_Devices.Items)
|
|||
|
|
{
|
|||
|
|
if (OBJ.ToString() == "192.168.1.111")
|
|||
|
|
{
|
|||
|
|
Found111 = true;
|
|||
|
|
}
|
|||
|
|
else if (OBJ.ToString() == "192.168.1.112")
|
|||
|
|
{
|
|||
|
|
Found112 = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Found111 == true && Found112 == true)
|
|||
|
|
{
|
|||
|
|
camFound = true;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Found111 = Found112 = false; // If both aren't found at the same time, continue waiting.
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
Thread.Sleep(50);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return camFound;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private bool PingIP(string ipAddress)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Ping myPing = new Ping();
|
|||
|
|
PingReply reply = myPing.Send(ipAddress, 500);
|
|||
|
|
if (reply != null && reply.Status.ToString() == "Success")
|
|||
|
|
{
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void FillMonitor(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
BtnFillMon.BackColor = Color.FromArgb(192, 255, 255);
|
|||
|
|
bool TestGood = true;
|
|||
|
|
timerMonitor.Interval = 100; // Run monitor and check values.
|
|||
|
|
BtnStartMon_Click(sender, e);
|
|||
|
|
|
|||
|
|
while (monitorCount != 9)
|
|||
|
|
{
|
|||
|
|
WaitMs(10);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
cancelMonitor = true;
|
|||
|
|
WaitMs(100);
|
|||
|
|
timerMonitor.Interval = 500;
|
|||
|
|
this.Refresh();
|
|||
|
|
|
|||
|
|
double Ch1Voltage;
|
|||
|
|
double Ch2Voltage;
|
|||
|
|
double Ch1Current;
|
|||
|
|
double Ch2Current;
|
|||
|
|
double Ch1Duty;
|
|||
|
|
double Ch2Duty;
|
|||
|
|
double Framerate;
|
|||
|
|
double Temperature;
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Ch1Voltage = Convert.ToDouble(txBxLedVCh1.Text.Substring(0, 4));
|
|||
|
|
Ch2Voltage = Convert.ToDouble(txBxLedVCh2.Text.Substring(0, 4));
|
|||
|
|
Ch1Current = Convert.ToDouble(txBxLedICh1.Text.Substring(0, 4));
|
|||
|
|
Ch2Current = Convert.ToDouble(txBxLedICh2.Text.Substring(0, 4));
|
|||
|
|
Ch1Duty = Convert.ToDouble(txBxDutyCh1.Text.Substring(0, 4));
|
|||
|
|
Ch2Duty = Convert.ToDouble(txBxDutyCh2.Text.Substring(0, 4));
|
|||
|
|
Framerate = Convert.ToDouble(txBxFrame.Text.Substring(0, 4));
|
|||
|
|
Temperature = Convert.ToInt16(txBxPcbTemp.Text.Substring(0, txBxPcbTemp.Text.IndexOf("°")));
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Could not convert monitor to readable values");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
int Vmin = 28;
|
|||
|
|
int Vmax = 37;
|
|||
|
|
double Imin = 3.3;
|
|||
|
|
double Imax = 3.6;
|
|||
|
|
|
|||
|
|
if (Ch1Duty < 1.5 || Ch1Duty >= 1.8)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Channel 1 Duty cycle out of specification " + txBxDutyCh1.Text);
|
|||
|
|
TestGood = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Ch2Duty < 1.5 || Ch2Duty >= 1.8)
|
|||
|
|
{
|
|||
|
|
txBxDutyCh2.BackColor = Color.Red;
|
|||
|
|
txBxDutyCh2.ForeColor = Color.White;
|
|||
|
|
MessageBox.Show("Channel 2 Duty cycle out of specification " + txBxDutyCh2.Text);
|
|||
|
|
TestGood = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Ch1Duty != 1.80) // 1.8uS means its maxed so V and I is irrelevant because duty is maxed out
|
|||
|
|
{
|
|||
|
|
if (Ch1Voltage < Vmin || Ch1Voltage > Vmax)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Channel 1 Voltage out of specification V = " + Ch1Voltage);
|
|||
|
|
TestGood = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Ch1Current < Imin || Ch1Current > Imax)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Channel 1 LED current out of specification " + Ch1Current + "A");
|
|||
|
|
TestGood = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Ch2Duty != 1.80) // 1.8uS means its maxed so V and I is irrelevant because duty is maxed out
|
|||
|
|
{
|
|||
|
|
if (Ch2Voltage < Vmin || Ch2Voltage > Vmax)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Channel 2 Voltage out of specification V = " + Ch2Voltage);
|
|||
|
|
TestGood = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Ch2Current < Imin || Ch2Current > Imax)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Channel 2 LED current out of specification " + Ch2Current + "A");
|
|||
|
|
TestGood = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Math.Abs(Framerate - 30) >= 0.5)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Frame rate out of specification FPS= " + txBxFrame.Text);
|
|||
|
|
TestGood = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Temperature <= 5 || Temperature >= 71)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Temperature out of specification = " + txBxPcbTemp.Text);
|
|||
|
|
TestGood = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (TxBxGigEANPRStatus.BackColor == Color.Red || TxBxGigEOviewStatus.BackColor == Color.Red || TxBxGigETibboStatus.BackColor == Color.Red || TxBxGigEOutStatus.BackColor == Color.Red || TxBxGigER48Status.BackColor == Color.Red)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Switch speeds are not correct, see red monitor box");
|
|||
|
|
TestGood = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (TestGood == true)
|
|||
|
|
{
|
|||
|
|
BtnFillMon.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnFillMon_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
FillMonitor(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TestFail(string errMssg)
|
|||
|
|
{
|
|||
|
|
DialogResult dialogResult = MessageBox.Show(errMssg + Environment.NewLine + "Do you wish to continue?", "Test Fail!", MessageBoxButtons.YesNo);
|
|||
|
|
|
|||
|
|
if (dialogResult == DialogResult.No)
|
|||
|
|
{
|
|||
|
|
Application.Restart();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string CheckEncoderFirmwareVer(string CamIPAddress)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string responseText = HTTPAPIrequest(CamIPAddress, "/cgi-bin/action.fcgi?api=get_setup.system.info");
|
|||
|
|
int startIndex = responseText.IndexOf("swver") + 7;
|
|||
|
|
int EndIndex = responseText.IndexOf(Environment.NewLine, startIndex);
|
|||
|
|
|
|||
|
|
return responseText.Substring(startIndex, EndIndex - startIndex);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
return "UNKNOWN";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private string HTTPAPIrequest(string IP, string url)
|
|||
|
|
{
|
|||
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://ADMIN:1234@" + IP + url);
|
|||
|
|
request.Credentials = new NetworkCredential("ADMIN", "1234");
|
|||
|
|
StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream(), Encoding.ASCII);
|
|||
|
|
return reader.ReadToEnd();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void SIGCheck(VideoView VLCVV)
|
|||
|
|
{
|
|||
|
|
SendVISCA(viscaExpManual, "AMm"); // Exposure manual without dialog box on button click.
|
|||
|
|
|
|||
|
|
byte[] viscaShutterDirect = VISCACommand(0x04, 0x4A, 0x00, 0x00, 0x00, 0x09);
|
|||
|
|
SendVISCA(viscaShutterDirect); //Shutter 1/125th
|
|||
|
|
|
|||
|
|
byte[] viscaGainDirect = VISCACommand(0x04, 0x4C, 0x00, 0x00, 0x00, 0x01);
|
|||
|
|
SendVISCA(viscaGainDirect); //Gain 2db
|
|||
|
|
|
|||
|
|
byte[] viscaIrisDirect = VISCACommand(0x04, 0x4B, 0x00, 0x00, 0x00, 0x0F);
|
|||
|
|
SendVISCA(viscaIrisDirect); //Iris F2.4
|
|||
|
|
|
|||
|
|
Thread.Sleep(3000);
|
|||
|
|
VLCVV.MediaPlayer.TakeSnapshot(0, $"{TxtFileDir}CONTROL.jpg", 1280, 720); // Control image with default brightness
|
|||
|
|
|
|||
|
|
byte[] viscaShutterDirectLow = VISCACommand(0x04, 0x4A, 0x00, 0x00, 0x00, 0x04);
|
|||
|
|
SendVISCA(viscaShutterDirectLow); //Shutter 1/15th
|
|||
|
|
|
|||
|
|
Thread.Sleep(3000);
|
|||
|
|
VLCVV.MediaPlayer.TakeSnapshot(0, $"{TxtFileDir}SHUTTER.jpg", 1280, 720); // Brighter through shutter
|
|||
|
|
|
|||
|
|
SendVISCA(viscaShutterDirect); // Shutter 1/125th, back to control
|
|||
|
|
|
|||
|
|
byte[] viscaGainDirectLow = VISCACommand(0x04, 0x4C, 0x00, 0x00, 0x01, 0x04);
|
|||
|
|
SendVISCA(viscaGainDirectLow); // Gain 45db
|
|||
|
|
|
|||
|
|
Thread.Sleep(3000);
|
|||
|
|
VLCVV.MediaPlayer.TakeSnapshot(0, $"{TxtFileDir}GAIN.jpg", 1280, 720); // Brighter through gain
|
|||
|
|
|
|||
|
|
SendVISCA(viscaGainDirect); // Gain 2db, back to control
|
|||
|
|
|
|||
|
|
byte[] viscaIrisDirectSmall = VISCACommand(0x04, 0x4B, 0x00, 0x00, 0x00, 0x04);
|
|||
|
|
SendVISCA(viscaIrisDirectSmall); // Iris F16
|
|||
|
|
|
|||
|
|
Thread.Sleep(3000);
|
|||
|
|
VLCVV.MediaPlayer.TakeSnapshot(0, $"{TxtFileDir}IRIS.jpg", 1280, 720); // Darker through iris
|
|||
|
|
|
|||
|
|
Bitmap bmp = new Bitmap($"{TxtFileDir}CONTROL.jpg");
|
|||
|
|
ImageStatisticsHSL hslStatistics = new ImageStatisticsHSL(bmp);
|
|||
|
|
double luminanceCONTROL = Convert.ToDouble(hslStatistics.Luminance.Mean);
|
|||
|
|
|
|||
|
|
Bitmap bmp2 = new Bitmap($"{TxtFileDir}SHUTTER.jpg");
|
|||
|
|
ImageStatisticsHSL hslStatistics2 = new ImageStatisticsHSL(bmp2);
|
|||
|
|
double luminanceSHUTTER = Convert.ToDouble(hslStatistics2.Luminance.Mean);
|
|||
|
|
|
|||
|
|
Bitmap bmp3 = new Bitmap($"{TxtFileDir}IRIS.jpg");
|
|||
|
|
ImageStatisticsHSL hslStatistics3 = new ImageStatisticsHSL(bmp3);
|
|||
|
|
double luminanceIRIS = Convert.ToDouble(hslStatistics3.Luminance.Mean);
|
|||
|
|
|
|||
|
|
Bitmap bmp4 = new Bitmap($"{TxtFileDir}GAIN.jpg");
|
|||
|
|
ImageStatisticsHSL hslStatistics4 = new ImageStatisticsHSL(bmp4);
|
|||
|
|
double luminanceGAIN = Convert.ToDouble(hslStatistics4.Luminance.Mean);
|
|||
|
|
|
|||
|
|
if (!(luminanceSHUTTER > luminanceCONTROL + 0.05)) // Shutter 1/15th brighter than 1/500th
|
|||
|
|
{
|
|||
|
|
TestFail("Cannot control shutter control brightness:" + luminanceCONTROL + Environment.NewLine + "Shutter brightness: " + luminanceSHUTTER);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!(luminanceCONTROL > luminanceIRIS + 0.05)) // Shutter F16 darker than F2.4
|
|||
|
|
{
|
|||
|
|
TestFail("Cannot control iris control brightness:" + luminanceCONTROL + Environment.NewLine + "Iris brightness: " + luminanceIRIS);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!(luminanceGAIN > luminanceCONTROL + 0.05)) // Gain 28dB brighter than 0dB
|
|||
|
|
{
|
|||
|
|
TestFail("Cannot control gain control brightness:" + luminanceCONTROL + Environment.NewLine + "Gain brightness: " + luminanceGAIN);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnFinalTest_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!videoViewANPR.MediaPlayer.IsPlaying && !videoViewOV.MediaPlayer.IsPlaying && !serialPort1.IsOpen)
|
|||
|
|
{
|
|||
|
|
TestFail("Make sure video is playing and COM port is open before starting test.");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (TxBxPSUIP.BackColor == Color.Red || TxBxZebraIP.BackColor == Color.Red)
|
|||
|
|
{
|
|||
|
|
TestFail("Make sure PSU and Zebra IP's are correct before starting test.");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
richTxBxRxCmd.Text = TxBxRxErrMssg.Text = ""; // Clear serial boxes.
|
|||
|
|
|
|||
|
|
SendCmd("NC@3.50", 1); // LED's on high for test.
|
|||
|
|
SendCmd("MS0", 1);
|
|||
|
|
|
|||
|
|
CamIP = IPMatch(comboBox_Devices2, txBxManualIpOv); // Check encoder firmware version
|
|||
|
|
|
|||
|
|
if (CamIP == "False")
|
|||
|
|
{
|
|||
|
|
TestFail("Overview camera not playing");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string EncoderSoftwareVersion = CheckEncoderFirmwareVer(CamIP);
|
|||
|
|
|
|||
|
|
if (!EncoderSoftwareVersion.Contains(EncoderSoftVer))
|
|||
|
|
{
|
|||
|
|
TestFail("Overview Encoder is not up to date, responds " + EncoderSoftwareVersion + " and should be " + EncoderSoftVer);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CamIP = IPMatch(comboBox_Devices, txBxManualIP);
|
|||
|
|
|
|||
|
|
if (CamIP == "False")
|
|||
|
|
{
|
|||
|
|
TestFail("ANPR camera not playing");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
EncoderSoftwareVersion = CheckEncoderFirmwareVer(CamIP);
|
|||
|
|
|
|||
|
|
if (!EncoderSoftwareVersion.Contains(EncoderSoftVer))
|
|||
|
|
{
|
|||
|
|
TestFail("ANPR Encoder is not up to date, responds " + EncoderSoftwareVersion + " and should be " + EncoderSoftVer);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnANPR_Click(sender, e);
|
|||
|
|
SendVISCA(viscaFirmwareVer, 8, TxBxReply, true);
|
|||
|
|
|
|||
|
|
string FWverComp = "118"; // HD:IP Mk2
|
|||
|
|
if (CameraModule == Module.HZ5512) // FHD:IP
|
|||
|
|
{
|
|||
|
|
FWverComp = "218";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
string fwversion = TxBxReply.Text;
|
|||
|
|
|
|||
|
|
if (!fwversion.Contains(FWverComp))
|
|||
|
|
{
|
|||
|
|
TestFail("ANPR camera module not updated. Needs to be " + FWverComp + ", getting back " + rxMssgVISCA);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SIGCheck(videoViewANPR);
|
|||
|
|
|
|||
|
|
BtnOV_Click(sender, e);
|
|||
|
|
ExpManual_Click(sender, e); // In prep for SIG check
|
|||
|
|
SendVISCA(viscaFirmwareVer, 8, TxBxReply, true);
|
|||
|
|
|
|||
|
|
fwversion = TxBxReply.Text;
|
|||
|
|
|
|||
|
|
if (!fwversion.Contains(FWverComp))
|
|||
|
|
{
|
|||
|
|
TestFail("OV camera module not updated. Needs to be " + FWverComp + ", getting back " + rxMssgVISCA);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SIGCheck(videoViewOV);
|
|||
|
|
|
|||
|
|
FillMonitor(sender, e); // Fills in monitor and checks it is within specification.
|
|||
|
|
|
|||
|
|
BtnDefConfig_Click(sender, e); // Fills in default camera config.
|
|||
|
|
|
|||
|
|
while (timerFocus.Enabled == true)
|
|||
|
|
{
|
|||
|
|
Application.DoEvents();
|
|||
|
|
Thread.Sleep(10);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnSetH264_Click(sender, e); // Click MJPEG/H264 and IP buttons.
|
|||
|
|
BtnSetMJPEGANPR_Click(sender, e);
|
|||
|
|
|
|||
|
|
SetIP("111", "1", comboBox_Devices, txBxManualIP, BtnSetIPANPR); // Temporary gateway
|
|||
|
|
SetIP("112", "1", comboBox_Devices2, txBxManualIpOv, BtnSetIPOV); // Temporary gateway
|
|||
|
|
|
|||
|
|
MessageBox.Show("Make sure to click 'apply' on H264/MJPEG settings on both encoders before continuing");
|
|||
|
|
WaitMs(1000);
|
|||
|
|
|
|||
|
|
SendCmd("NPn", 1); // Put LED's back to normal
|
|||
|
|
SendCmd("MS0", 1);
|
|||
|
|
WaitMs(5000);
|
|||
|
|
|
|||
|
|
btnClosePort_Click(sender, e);
|
|||
|
|
|
|||
|
|
WaitMs(1000);
|
|||
|
|
btnPsuOff_Click(sender, e); // Reboot camera and wait
|
|||
|
|
DialogResult diagCont = MessageBox.Show("Check there is NO continuity between chassis ground and negative of PSU.", "", MessageBoxButtons.YesNo);
|
|||
|
|
DialogResult diagCont2 = MessageBox.Show("Check there is NO continuity between chassis ground and positive of PSU.", "", MessageBoxButtons.YesNo);
|
|||
|
|
|
|||
|
|
if (diagCont == DialogResult.No || diagCont2 == DialogResult.No)
|
|||
|
|
{
|
|||
|
|
TestFail("Continuity test failed, open it up and snip the pins of IC1 on power board");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
WaitMs(5000);
|
|||
|
|
btnPsuOn_Click(sender, e);
|
|||
|
|
WaitMs(15000);
|
|||
|
|
|
|||
|
|
if (CheckCamReboot(sender, e) == false)
|
|||
|
|
{
|
|||
|
|
DialogResult dialogResult = MessageBox.Show("Couldn't find cameras, wait longer?", "", MessageBoxButtons.YesNo);
|
|||
|
|
|
|||
|
|
if (dialogResult == DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
dialogResult = MessageBox.Show("Do you want to reboot cameras?", "", MessageBoxButtons.YesNo);
|
|||
|
|
|
|||
|
|
if (dialogResult == DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
WaitMs(1000);
|
|||
|
|
btnPsuOff_Click(sender, e); //Reboot camera and wait
|
|||
|
|
WaitMs(5000);
|
|||
|
|
btnPsuOn_Click(sender, e);
|
|||
|
|
WaitMs(15000);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (CheckCamReboot(sender, e) == false)
|
|||
|
|
{
|
|||
|
|
TestFail("Encoders not found on 192.168.1.111 & 192.168.1.112");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
TestFail("Encoders not found on 192.168.1.111 & 192.168.1.112");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Change IP's to new ones and start stream.
|
|||
|
|
Media rtsp2 = new Media(libVLC, "rtsp://ADMIN:1234@192.168.1.111:554/live/main", FromType.FromLocation);
|
|||
|
|
videoViewANPR.MediaPlayer.Play(rtsp2);
|
|||
|
|
comboBox_Devices.Text = "192.168.1.111";
|
|||
|
|
|
|||
|
|
Media rtsp1 = new Media(libVLC, "rtsp://ADMIN:1234@192.168.1.112:554/live/main", FromType.FromLocation);
|
|||
|
|
videoViewOV.MediaPlayer.Play(rtsp1);
|
|||
|
|
comboBox_Devices2.Text = "192.168.1.112";
|
|||
|
|
|
|||
|
|
//Get codec settings and check they have saved over reboot.
|
|||
|
|
string responseText = HTTPAPIrequest("192.168.1.112", "/cgi-bin/action.fcgi?api=get_setup.video.codec");
|
|||
|
|
|
|||
|
|
string[] StringsToCheckOV = { "codec0=h264", "resolution0=1280x720", "fps0=30", "profile0=High", "gopsize0=30", "bitctrl0=VBR", "image_quality0=mid", "bitavr0=10000", "ff_mode=60" };
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.HZ5512)
|
|||
|
|
{
|
|||
|
|
StringsToCheckOV[1] = "resolution0=1920x1080";
|
|||
|
|
}
|
|||
|
|
bool StringNotFoundOV = StringsToCheckOV.Any(s => !responseText.Contains(s));
|
|||
|
|
|
|||
|
|
if (StringNotFoundOV == true) // One or more strings not found
|
|||
|
|
{
|
|||
|
|
StringReader readerstringreaderthatreadsstrings = new StringReader(responseText);
|
|||
|
|
string line = readerstringreaderthatreadsstrings.ReadLine();
|
|||
|
|
string responseTextculled = null;
|
|||
|
|
|
|||
|
|
while (line != null)
|
|||
|
|
{
|
|||
|
|
if (line.Contains("0=") || line.Contains("ff_mode"))
|
|||
|
|
{
|
|||
|
|
responseTextculled += line;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
line = readerstringreaderthatreadsstrings.ReadLine();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
MessageBox.Show("codec0=h264" + Environment.NewLine + StringsToCheckOV[1] + Environment.NewLine + "fps0=30" + Environment.NewLine + "profile0=High" + Environment.NewLine + "gopsize0=30" + Environment.NewLine + "bitctrl0=VBR" + Environment.NewLine + "image_quality0=mid" + Environment.NewLine + "bitavr0=10000" + Environment.NewLine + "ff_mode=60" + Environment.NewLine + Environment.NewLine + responseTextculled);
|
|||
|
|
TestFail("H264 settings not saved to Overview camera");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
responseText = HTTPAPIrequest("192.168.1.111", "/cgi-bin/action.fcgi?api=get_setup.video.codec");
|
|||
|
|
|
|||
|
|
string[] StringsToCheckANPR = { "codec0=mjpeg", "resolution0=1280x720", "fps0=15", "jpegqual=65", "ff_mode=60" };
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.HZ5512)
|
|||
|
|
{
|
|||
|
|
StringsToCheckANPR[1] = "resolution0=1920x1080";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
bool StringNotFoundANPR = StringsToCheckANPR.Any(s => !responseText.Contains(s));
|
|||
|
|
|
|||
|
|
if (StringNotFoundANPR == true) // One or more strings not found
|
|||
|
|
{
|
|||
|
|
StringReader readerstringreaderthatreadsstrings = new StringReader(responseText);
|
|||
|
|
string line = readerstringreaderthatreadsstrings.ReadLine();
|
|||
|
|
string responseTextculled = null;
|
|||
|
|
|
|||
|
|
while (line != null)
|
|||
|
|
{
|
|||
|
|
if (line.Contains("0=") || line.Contains("ff_mode") || line.Contains("jpegqual"))
|
|||
|
|
{
|
|||
|
|
responseTextculled += line;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
line = readerstringreaderthatreadsstrings.ReadLine();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
MessageBox.Show("codec0=mjpeg" + Environment.NewLine + StringsToCheckANPR[1] + Environment.NewLine + "fps0=15" + Environment.NewLine + "jpegqual=65" + Environment.NewLine + "ff_mode=60" + Environment.NewLine + Environment.NewLine + responseTextculled);
|
|||
|
|
TestFail("MJPEG settings not saved to ANPR camera");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Set NTP time server IP address
|
|||
|
|
responseText = HTTPAPIrequest("192.168.1.112", "/cgi-bin/action.fcgi?api=set_setup.system.datetime_cgi&ntpserver=192.168.1.102&timeformat=0&ntpon=1&dateformat=2");
|
|||
|
|
|
|||
|
|
if (!responseText.Contains("WEB_ERR_RET_SUCCESS"))
|
|||
|
|
{
|
|||
|
|
TestFail("OV NTP not set " + Environment.NewLine + responseText);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
responseText = HTTPAPIrequest("192.168.1.111", "/cgi-bin/action.fcgi?api=set_setup.system.datetime_cgi&ntpserver=192.168.1.102&timeformat=0&ntpon=1&dateformat=2");
|
|||
|
|
|
|||
|
|
if (!responseText.Contains("WEB_ERR_RET_SUCCESS"))
|
|||
|
|
{
|
|||
|
|
TestFail("ANPR NTP not set " + Environment.NewLine + responseText);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Set motion to off
|
|||
|
|
responseText = HTTPAPIrequest("192.168.1.112", "/cgi-bin/action.fcgi?api=get_setup.event.smartmotion&enable=off");
|
|||
|
|
|
|||
|
|
if (!responseText.Contains("WEB_ERR_RET_SUCCESS"))
|
|||
|
|
{
|
|||
|
|
TestFail("OV motion sensor not set off " + Environment.NewLine + responseText);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
responseText = HTTPAPIrequest("192.168.1.111", "/cgi-bin/action.fcgi?api=get_setup.event.smartmotion&enable=off");
|
|||
|
|
|
|||
|
|
if (!responseText.Contains("WEB_ERR_RET_SUCCESS"))
|
|||
|
|
{
|
|||
|
|
TestFail("ANPR motion sensor not set off " + Environment.NewLine + responseText);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Set privacy mask to off
|
|||
|
|
responseText = HTTPAPIrequest("192.168.1.112", "/cgi-bin/action.fcgi?api=get_setup.live.privacymask_polygon&maskarea0=0&maskarea1=0&maskarea2=0&maskarea3=0&maskarea4=0&maskarea5=0&maskarea6=0&maskarea7=0");
|
|||
|
|
|
|||
|
|
if (!responseText.Contains("WEB_ERR_RET_SUCCESS"))
|
|||
|
|
{
|
|||
|
|
TestFail("OV privacy mask not set off " + Environment.NewLine + responseText);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
responseText = HTTPAPIrequest("192.168.1.111", "/cgi-bin/action.fcgi?api=get_setup.live.privacymask_polygon&maskarea0=0&maskarea1=0&maskarea2=0&maskarea3=0&maskarea4=0&maskarea5=0&maskarea6=0&maskarea7=0");
|
|||
|
|
|
|||
|
|
if (!responseText.Contains("WEB_ERR_RET_SUCCESS"))
|
|||
|
|
{
|
|||
|
|
TestFail("ANPR privacy mask not set off " + Environment.NewLine + responseText);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Set RTSP & HTTP port
|
|||
|
|
responseText = HTTPAPIrequest("192.168.1.112", "/cgi-bin/action.fcgi?api=get_setup.network.service&httpport=80&rtspport=554");
|
|||
|
|
|
|||
|
|
if (!responseText.Contains("80") || !responseText.Contains("554"))
|
|||
|
|
{
|
|||
|
|
TestFail("OV privacy mask not set off " + Environment.NewLine + responseText);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
responseText = HTTPAPIrequest("192.168.1.111", "/cgi-bin/action.fcgi?api=get_setup.network.service&httpport=80&rtspport=554");
|
|||
|
|
|
|||
|
|
if (!responseText.Contains("80") || !responseText.Contains("554"))
|
|||
|
|
{
|
|||
|
|
TestFail("ANPR privacy mask not set off " + Environment.NewLine + responseText);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
btnClosePort_Click(sender, e); // Re-establish connection to COM port
|
|||
|
|
SendCmd("CK0", 1);
|
|||
|
|
|
|||
|
|
richTxBxRxCmd.Text = TxBxRxErrMssg.Text = ""; // Clear serial boxes.
|
|||
|
|
|
|||
|
|
SendCmd("QV?", 1); // Camera control board
|
|||
|
|
SendCmd("qV?", 1); // LED driver
|
|||
|
|
|
|||
|
|
SoftwareVer = richTxBxRxCmd.Text.Substring(richTxBxRxCmd.Text.IndexOf("QV@") + 3, 2) + " & " + richTxBxRxCmd.Text.Substring(richTxBxRxCmd.Text.LastIndexOf("QV@") + 3, 2);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
TestFail("Failed to read software versions");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
SendCmd("CS?", 1);
|
|||
|
|
WaitMs(1000); // Wait for LPC to respond
|
|||
|
|
SendCmd("CS?", 1); // Try again because we are seeing no replies after reconneciton?
|
|||
|
|
|
|||
|
|
if (richTxBxRxCmd.Text.Substring(richTxBxRxCmd.Text.IndexOf("CS@") + 3, 7) != "???????")
|
|||
|
|
{
|
|||
|
|
DialogResult dialogResult = MessageBox.Show("Is this camera an RMA?", "", MessageBoxButtons.YesNo);
|
|||
|
|
|
|||
|
|
if (dialogResult == DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
DialogResult dialogResultprint = MessageBox.Show("Do you want to reprint the label?", "", MessageBoxButtons.YesNo);
|
|||
|
|
|
|||
|
|
if (dialogResultprint == DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
GE67SALbl = GE67SALbl.Replace("1004XXX", " " + richTxBxRxCmd.Text.Substring(richTxBxRxCmd.Text.IndexOf("CS@") + 3, 7));
|
|||
|
|
GE67SALbl = GE67SALbl.Replace("05/03", SoftwareVer); // Editing label to include software versions.
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.HZ5512)
|
|||
|
|
{
|
|||
|
|
GE67SALbl = GE67SALbl.Replace("GE67SA-M3", "YT65JG"); // Editing label to model number.
|
|||
|
|
GE67SALbl = GE67SALbl.Replace("HD:IP", "FHD:IP"); // Editing label to model description.
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
PrintToZebra(GE67SALbl);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
IsRMA = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
TestFail("Failed to check serial number");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (IsRMA == false)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string model = "GE67SA";
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.HZ5512)
|
|||
|
|
{
|
|||
|
|
model = "YT65JG";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
SendCmd($"CM@{model}", 0);
|
|||
|
|
WaitMs(100);
|
|||
|
|
SendCmd($"CM@{model}", 1);
|
|||
|
|
UpdateSpreadSheet(model); // Get next serial number & put new camera in SS.
|
|||
|
|
SendCmd("CS@" + newSerialNumberString.Substring(1), 1);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
TestFail("Failed to set model and serial");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
PrintToZebra(MadeInGb);
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.HZ5512)
|
|||
|
|
{
|
|||
|
|
YT65JGLbl = YT65JGLbl.Replace("K1004XXX", newSerialNumberString); // Editing label to serial number.
|
|||
|
|
PrintToZebra(YT65JGLbl);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
GE67SALbl = GE67SALbl.Replace("K1004XXX", newSerialNumberString); // Editing label to serial number.
|
|||
|
|
GE67SALbl = GE67SALbl.Replace("05/03", SoftwareVer); // Editing label to include software versions.
|
|||
|
|
PrintToZebra(GE67SALbl);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
TestFail("Cannot print labels");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BtnSetIPANPR_Click(sender, e); // gateway to 254
|
|||
|
|
BtnSetIPOV_Click(sender, e); // gateway to 254
|
|||
|
|
|
|||
|
|
MessageBox.Show("Set Tibbo to 192.168.1.113 NOW");
|
|||
|
|
|
|||
|
|
BtnFinalTest.BackColor = Color.LightGreen;
|
|||
|
|
MessageBox.Show("Final test passed");
|
|||
|
|
Application.Restart();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void timerCheckReboot_Tick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
timerCheckReboot.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btnTestZebra_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (TxBxSerialPrint.Text != "K– – – – – – –" && TxBxSerialPrint.Text.Length == 8 && TxBxSerialPrint.Text.Substring(0, 1) == "K")
|
|||
|
|
{
|
|||
|
|
DialogResult dialogResult = MessageBox.Show("Is correct serial number corrected?", "Serial number", MessageBoxButtons.YesNo);
|
|||
|
|
|
|||
|
|
if (dialogResult == DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
if (CameraModule == Module.HZ5512)
|
|||
|
|
{
|
|||
|
|
YT65JGLbl = YT65JGLbl.Replace("K1004XXX", " " + TxBxSerialPrint.Text);
|
|||
|
|
PrintToZebra(YT65JGLbl);
|
|||
|
|
|
|||
|
|
YT65JGLbl = "^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR2,2~SD15^JUS^LRN^CI0^XZ" + Environment.NewLine +
|
|||
|
|
"^XA" + Environment.NewLine +
|
|||
|
|
"^MMT" + Environment.NewLine +
|
|||
|
|
"^PW384" + Environment.NewLine +
|
|||
|
|
"^LL0096" + Environment.NewLine +
|
|||
|
|
"^LS0" + Environment.NewLine +
|
|||
|
|
"^FO256,0^GFA,01536,01536,00016,:Z64:" + Environment.NewLine +
|
|||
|
|
"eJzN072K20AQB/ARW6gRp1aCYL2CzDU2BJtUeQ2BC7cBF+eAyCpsiBuB2gSO82skTZAwRM1hv4LMQVRGxzYSLJ6sOa2+sFPfdD+W0ez+tQvw+ougoDe09B3MLhsMb+9XaIF32U74AYPZnSVqzx/X0iu79ceBabyY+P/xMsnwfuCwsRO+T2J8aOaBobtkRjv76xvFcnz/e9U5X8+yvIJWrBPJ0O9K+rxpVB02p4UW2ap/YJLz/CBSfiK1075hKuy9A+SX2dg6e6RsC+vLCMiDXvfr8RK8OT/GnvKfnmGe3bzRopN7xSPyFUBnP4zaM7I52xr4m1HPjw06R1hlt7Uz41PPVeG53jSwd8FlTwxLEGSlykv61LVr2NK7xgnPE6YXI5XP0EA3MU0Ky7xsmW8l7pAja1yeFtK7dl36qXFs5nJ+YN2+7JdkfUMVYLKVH1HzKjmtYzJ567tOwhEbr/v2S9dsDcizPUzDkQvKx66JJvSC6Azr/IY+H1iLdPaZZ623OtM6JlFreb/XyMC0H73Llu9jLCqmxVfshNSl+RMWteX7dGnKB5brmbL1LFKmHa6ajrcaHjv9PYNBtU3KvydBa5ZydZ9e/Jf/VEbhxIBRpf7nwK+p/gEmr4ir:A94D" + Environment.NewLine +
|
|||
|
|
"^FO0,0^GFA,01280,01280,00020,:Z64:" + Environment.NewLine +
|
|||
|
|
"eJztz7ENAyEMQFGjKygZgVFuNBiNUxbhdAsQpQgFwrFDlARwkzr3JTePAhvg/8LkMhisKoGOjTRS4BAv9PIyw+Zp9vI2y7bRXAvYMFiuvR3NVt9sDTaaI8OS3ce8DWyKzMG3JbLVS1Yns0GwrUxm9t54P/59NH0T7J4mW1Cy2BnfpgZLTwuTgWh+NicZnJ392gMKlLLa:A7F4" + Environment.NewLine +
|
|||
|
|
$"^FT159,84^A0N,25,24^FH\\^FDK1004XXX^FS" + Environment.NewLine +
|
|||
|
|
"^FT26,56^A0N,14,14^FH\\^FDModel:^FS" + Environment.NewLine +
|
|||
|
|
$"^FT159,32^A0N,25,28^FH\\^FDFHD:IP Mk2^FS" + Environment.NewLine +
|
|||
|
|
"^FT159,56^A0N,14,14^FH\\^FDSerial Number:^FS" + Environment.NewLine +
|
|||
|
|
$"^FT26,84^A0N,25,24^FH\\^FDYT65JG-M2^FS" + Environment.NewLine +
|
|||
|
|
"^PQ1,0,1,Y^XZ";
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
GE67SALbl = GE67SALbl.Replace("K1004XXX", " " + TxBxSerialPrint.Text);
|
|||
|
|
PrintToZebra(GE67SALbl);
|
|||
|
|
|
|||
|
|
GE67SALbl = "CT~~CD,~CC^~CT~" +
|
|||
|
|
"^XA ~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR2,2~SD30^JUS^LRN^CI0^XZ" +
|
|||
|
|
"^XA" +
|
|||
|
|
"^MMT" +
|
|||
|
|
"^PW320" +
|
|||
|
|
"^LL0096" +
|
|||
|
|
"^LS0" +
|
|||
|
|
@"^FT39,41^A0N,31,26^FH\^FDGE67SA-M3 SN:K1004XXX^FS" +
|
|||
|
|
@"^FT48,78^A0N,31,26^FH\^FDHD:IP Mk2 SW05/03^FS" +
|
|||
|
|
"^PQ1,0,1,Y^XZ";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Serial number in incorrect format, K followed by 7 digits");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnPrintGB_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
PrintToZebra(MadeInGb);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxSerialPrint_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (TxBxSerialPrint.Text == "K– – – – – – –")
|
|||
|
|
{
|
|||
|
|
TxBxSerialPrint.Text = "K";
|
|||
|
|
TxBxSerialPrint.SelectionStart = 1;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void videoViewOV_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
BtnLVOview_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void videoViewANPR_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
BtnLVANPR_Click(sender, e);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxZebraIP_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (RegexIPPattern.IsMatch(TxBxZebraIP.Text))
|
|||
|
|
{
|
|||
|
|
TxBxZebraIP.BackColor = SystemColors.Window;
|
|||
|
|
TxBxZebraIP.ForeColor = SystemColors.WindowText;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
TxBxZebraIP.BackColor = Color.Red;
|
|||
|
|
TxBxZebraIP.ForeColor = SystemColors.Window;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TxBxPSUIP_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (RegexIPPattern.IsMatch(TxBxPSUIP.Text))
|
|||
|
|
{
|
|||
|
|
TxBxPSUIP.BackColor = SystemColors.Window;
|
|||
|
|
TxBxPSUIP.ForeColor = SystemColors.WindowText;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
TxBxPSUIP.BackColor = Color.Red;
|
|||
|
|
TxBxPSUIP.ForeColor = SystemColors.Window;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TimerOVPlaying_Tick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!videoViewOV.MediaPlayer.IsPlaying)
|
|||
|
|
{
|
|||
|
|
videoViewOV.MediaPlayer.Stop();
|
|||
|
|
if (OVstartup == true)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
OVStreamUrl = OVStreamUrl.Replace("554", "553"); // Try other RTSP port
|
|||
|
|
remoteEPOV = new IPEndPoint(IPAddress.Parse(CamIP), 52381);
|
|||
|
|
Media rtsp1 = new Media(libVLC, OVStreamUrl, FromType.FromLocation);
|
|||
|
|
videoViewOV.MediaPlayer.Play(rtsp1);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Endpoint and VLC error: " + ex.ToString());
|
|||
|
|
}
|
|||
|
|
OVstartup = false;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
TxBxRxErrMssg.Text = "OV stopped playing at " + DateTime.Now;
|
|||
|
|
TimerOVPlaying.Enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TimerANPRPlaying_Tick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!videoViewANPR.MediaPlayer.IsPlaying)
|
|||
|
|
{
|
|||
|
|
if (ANPRstartup == true)
|
|||
|
|
{
|
|||
|
|
videoViewANPR.MediaPlayer.Stop();
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
ANPRStreamUrl = ANPRStreamUrl.Replace("554", "553"); // Try other RTSP port
|
|||
|
|
remoteEPANPR = new IPEndPoint(IPAddress.Parse(CamIP), 52381);
|
|||
|
|
Media rtsp1 = new Media(libVLC, ANPRStreamUrl, FromType.FromLocation);
|
|||
|
|
videoViewANPR.MediaPlayer.Play(rtsp1);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("Endpoint and VLC error: " + ex.ToString());
|
|||
|
|
}
|
|||
|
|
ANPRstartup = false;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
TxBxRxErrMssg.Text = "ANPR stopped playing at " + DateTime.Now;
|
|||
|
|
TimerANPRPlaying.Enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnR49Save_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (CameraModule == Module.MC105)
|
|||
|
|
{
|
|||
|
|
WWSave = true;
|
|||
|
|
SendVISCA(viscaSaveWW);
|
|||
|
|
WWSave = false;
|
|||
|
|
BtnR49Save.BackColor = Color.LightGreen;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void TimerWWSave_Tick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
WWSave = true;
|
|||
|
|
SendVISCA(viscaSaveWW);
|
|||
|
|
TimerWWSave.Enabled = WWSave = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private static readonly byte[] VISCA_HEADER = { 0x01, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x81, 0x01 }; // Common header
|
|||
|
|
|
|||
|
|
public static byte[] VISCACommand(params byte[] payload)
|
|||
|
|
{
|
|||
|
|
// Replace byte 3 with the correct length value
|
|||
|
|
VISCA_HEADER[3] = (byte)(3 + payload.Length); // + 3 for 81 01 & FF not included in payload
|
|||
|
|
|
|||
|
|
// Build the final command by concatenating the header, payload, and 0xFF byte
|
|||
|
|
return VISCA_HEADER.Concat(payload).Append((byte)0xFF).ToArray();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private static readonly byte[] VISCA_HEADER_INQ = { 0x01, 0x10, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x81, 0x09 };
|
|||
|
|
public static byte[] VISCAInquiry(params byte[] payload)
|
|||
|
|
{
|
|||
|
|
// Replace byte 3 with the correct length value
|
|||
|
|
VISCA_HEADER_INQ[3] = (byte)(3 + payload.Length); // + 3 for 81 01 & FF not included in payload
|
|||
|
|
|
|||
|
|
// Build the final command by concatenating the header, payload, and 0xFF byte
|
|||
|
|
return VISCA_HEADER_INQ.Concat(payload).Append((byte)0xFF).ToArray();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void BtnTest_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
Stopwatch stopWatchTest = new Stopwatch();
|
|||
|
|
stopWatchTest.Start();
|
|||
|
|
|
|||
|
|
// Test for Yunex
|
|||
|
|
string NTPAPI = "/services/system.ion?action=triggerntpsync";
|
|||
|
|
|
|||
|
|
if (CameraModule == Module.HZ5512 || CameraModule == Module.HZ5510)
|
|||
|
|
{
|
|||
|
|
NTPAPI = "/cgi-bin/action.fcgi?api=set_setup.ntp.sync";
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
while (true)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
string Resp = HTTPAPIrequest(comboBox_Devices.Text, NTPAPI);
|
|||
|
|
Console.WriteLine("NTP Sync Response: " + Resp);
|
|||
|
|
|
|||
|
|
TimeSpan t = DateTime.UtcNow - new DateTime(1970, 1, 1);
|
|||
|
|
int secondsSinceEpoch = (int)t.TotalSeconds;
|
|||
|
|
string UnixTime = Convert.ToString(secondsSinceEpoch);
|
|||
|
|
|
|||
|
|
using (StreamWriter AL = File.AppendText($"{TxtFileDir}NTPLog.txt"))
|
|||
|
|
{
|
|||
|
|
AL.WriteLine("NTP Sync result: " + UnixTime + Environment.NewLine + Resp);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!Resp.Contains("result=1"))
|
|||
|
|
{
|
|||
|
|
using (StreamWriter AL = File.AppendText($"{TxtFileDir}NTPLog.txt"))
|
|||
|
|
{
|
|||
|
|
AL.WriteLine(Environment.NewLine + Environment.NewLine + "NTP ERROR!!!" + Environment.NewLine + Environment.NewLine);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Application.DoEvents();
|
|||
|
|
Thread.Sleep(120000);
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
using (StreamWriter AL = File.AppendText($"{TxtFileDir}NTPLog.txt"))
|
|||
|
|
{
|
|||
|
|
AL.WriteLine("Unhandled Exception ERROR: " + ex.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//GBSerialNumPrint.Visible = !GBSerialNumPrint.Visible;
|
|||
|
|
|
|||
|
|
stopWatchTest.Stop();
|
|||
|
|
TimeSpan ts = stopWatchTest.Elapsed;
|
|||
|
|
string elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
|
|||
|
|
Console.WriteLine("RunTime " + elapsedTime);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|