Example #1
0
        public static bool Trigger(string cameraShortName, int blueIrisHttpPort, string blueIrisUser, string blueIrisPassword)
        {
            BlueIris bi = new BlueIris(blueIrisHttpPort, blueIrisUser, blueIrisPassword);

            if (bi.Login())
            {
                bool success = bi.Trigger(cameraShortName);
                bi.Logout();
                return(success);
            }
            return(false);
        }
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());
         }
     }
 }