示例#1
0
 void configure_Completed(object sender, Configure.CompletedEventArgs e)
 {
     string label;
     string info;
     if (e.Error != null)        // Internal exception
     {
         label = "ERROR";
         info = e.Error.ToString();
         Mode = DeviceStatus.DeviceMode.Error;
     }
     else if (e.ExitCode < 0)   // External error code
     {
         label = "ERROR";
         info = "" + e.ExitCode + " " + (e.ErrorMessages == null ? "" : e.ErrorMessages);
         Mode = DeviceStatus.DeviceMode.Error;
     }
     else if (e.ExitCode > 0)   //
     {
         label = "FAIL";
         info = "" + e.Error + " " + (e.ErrorMessages == null ? "" : e.ErrorMessages);
         OmDevice omdev = GetDevice();
         if (omdev != null) { omdev.SetLed(OmApi.OM_LED_STATE.OM_LED_BLUE); }
         Mode = DeviceStatus.DeviceMode.Failed;
     }
     else
     {
         label = "OK";
         info = "";
         Console.WriteLine("Configuration stopped - OK");
         OmDevice omdev = GetDevice();
         if (omdev != null) { omdev.SetLed(OmApi.OM_LED_STATE.OM_LED_MAGENTA); }
         Mode = DeviceStatus.DeviceMode.Complete;
     }
     this.Info = info;
     Console.WriteLine("Configuration stopped - " + label + "," + info);
     Log("" + DateTime.Now.ToString() + "," + Id + "," + label);
     Changed = true;
 }
示例#2
0
            public bool StartConfigure(int startDays, int startHour, int durationDays, int endHour)
            {
                // See if a charging device should be configured
                if (Mode != DeviceStatus.DeviceMode.Charging) { return false; }

                Mode = DeviceStatus.DeviceMode.Configuring;

                // Create the command-line-interface wrapper
                Configure configure;
                string configCommand = @"omapi-examples.exe";
                string args = "record -id $id -startdays $startdays -starthour $starthour -durationdays $durationdays -endhour $endhour";
                string basePath;

                //basePath = AppDomain.CurrentDomain.BaseDirectory;
                basePath = Path.GetDirectoryName(Application.ExecutablePath);
                configCommand = Path.Combine(basePath, configCommand);

                configure = new Configure(configCommand, args);
                configure.Completed += configure_Completed;

                // Begin background configure
                configure.ConfigureAsync(Id, startDays, startHour, durationDays, endHour);

                return true;
            }