Example #1
0
 private void LoadData()
 {
     try
     {
         DahuaPTZSettings settings = new DahuaPTZSettings();
         txtIP.Text          = settings.ip;
         txtUser.Text        = settings.user;
         txtPassword.Text    = settings.password;
         nudPanAmount.Value  = settings.panAmount;
         nudTiltAmount.Value = settings.tiltAmount;
         nudZoomAmount.Value = settings.zoomAmount;
         cbPresetSet.Checked = settings.allowPresetSetting;
         cbTriggerCameraAfterPresetCalled.Checked = settings.triggerAfterPreset;
         nudSecondsBeforeTrigger.Value            = (decimal)(settings.triggerDelayMS / 1000.0);
         txtCameraShortName.Text = settings.cameraShortName;
         nudBIPort.Value         = settings.blueIrisHttpPort;
         txtBIUser.Text          = settings.blueIrisUser;
         txtBIPassword.Text      = settings.blueIrisPassword;
     }
     catch (Exception)
     {
     }
 }
Example #2
0
 static void Main(string[] args)
 {
     if (args.Length == 0)
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         Application.Run(new Form1());
     }
     else
     {
         //for (int i = 0; i < args.Length; i++)
         //    File.AppendAllText("LastCommand.txt", DateTime.Now.ToString() + " " + args[i] + Environment.NewLine);
         try
         {
             DahuaPTZSettings settings = new DahuaPTZSettings();
             DahuaPTZ         ptz      = new DahuaPTZ(settings.ip, settings.user, settings.password);
             string           arg      = args[0];
             if (arg == "UP")
             {
                 ptz.Move(0, settings.tiltAmount * -1000, 0);
             }
             else if (arg == "DOWN")
             {
                 ptz.Move(0, settings.tiltAmount * 1000, 0);
             }
             else if (arg == "LEFT")
             {
                 ptz.Move(settings.panAmount * -1000, 0, 0);
             }
             else if (arg == "RIGHT")
             {
                 ptz.Move(settings.panAmount * 1000, 0, 0);
             }
             else if (arg == "ZOOMIN")
             {
                 ptz.Move(0, 0, settings.zoomAmount);
             }
             else if (arg == "ZOOMOUT")
             {
                 ptz.Move(0, 0, -settings.zoomAmount);
             }
             else if (arg == "HOME")
             {
                 ptz.PositionABS(0, 0, 0);
             }
             else if (arg.StartsWith("PRESET,"))
             {
                 string[] parts = arg.Split(',');
                 if (parts.Length == 2)
                 {
                     int preset = int.Parse(parts[1]);
                     ptz.GotoPreset(preset);
                 }
                 else if (parts.Length == 3)
                 {
                     int preset = int.Parse(parts[1]);
                     if (parts[2] == "SET")
                     {
                         if (settings.allowPresetSetting)
                         {
                             ptz.SetPreset(preset);
                         }
                     }
                     else if (parts[2] == "CALL")
                     {
                         ptz.GotoPreset(preset);
                         if (settings.triggerAfterPreset)
                         {
                             SetAllowUnsafeHeaderParsing20();
                             EventWaitHandle ewh = new EventWaitHandle(false, EventResetMode.ManualReset);
                             ewh.WaitOne(settings.triggerDelayMS);
                             BlueIris.Trigger(settings.cameraShortName, settings.blueIrisHttpPort, settings.blueIrisUser, settings.blueIrisPassword);
                         }
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             File.AppendAllText("DahuaPTZControl_Errors.txt", ex.ToString());
         }
     }
 }