Пример #1
0
 private void UserPin(byte pin, bool set)
 {
     programMode = ProgramModes.Pin;
     Pin         = pin;
     SetUserPin  = set;
     if (set)
     {
         if (pin < Load.Pins.Length)
         {
             name = string.Format("Set {0}", Load.Pins[pin]);
         }
         else
         {
             name = "Set all user pins";
         }
     }
     else
     {
         if (pin < Load.Pins.Length)
         {
             name = string.Format("Reset {0}", Load.Pins[pin]);
         }
         else
         {
             name = "Reset all user pins";
         }
     }
 }
Пример #2
0
        // creates constant mode program item
        private void constant(Modes mode, double?value, string durationString, TimeUnits timeUnit)
        {
            this.programMode    = ProgramModes.Constant;
            this.mode           = mode;
            this.durationString = durationString;
            this.timeUnit       = timeUnit;
            this.value          = value;
            this.skipEnabled    = false;

            // compute duration in seconds
            Converters.TimeConverter timeConverter = new Converters.TimeConverter();
            this.duration = (double)(timeConverter.ConvertBack(durationString, typeof(double), timeUnit, System.Globalization.CultureInfo.CurrentCulture));

            // string representation for GUI
            switch (mode)
            {
            case Modes.Current:
            {
                if (value != null)
                {
                    this.name = "Constant current " + ((double)value).ToString(NUMBER_FORMAT) + " A, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Constant current (use previous), " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.Power_CC:
            {
                if (value != null)
                {
                    this.name = "Constant power (CC) " + ((double)value).ToString(NUMBER_FORMAT) + " W, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Constant power (CC, use previous), " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.Power_CV:
            {
                if (value != null)
                {
                    this.name = "Constant power (CV) " + ((double)value).ToString(NUMBER_FORMAT) + " W, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Constant power (CV, use previous), " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.Resistance_CC:
            {
                if (value != null)
                {
                    this.name = "Constant resistance (CC) " + ((double)value).ToString(NUMBER_FORMAT) + " Ω, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Constant resistance (CC, use previous), " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.Resistance_CV:
            {
                if (value != null)
                {
                    this.name = "Constant resistance (CV) " + ((double)value).ToString(NUMBER_FORMAT) + " Ω, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Constant resistance (CV, use previous), " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.Voltage:
            {
                if (value != null)
                {
                    this.name = "Constant voltage " + ((double)value).ToString(NUMBER_FORMAT) + " V, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Constant voltage (use previous), " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.VoltageSoftware:
            {
                if (value != null)
                {
                    this.name = "Constant SW controlled voltage " + ((double)value).ToString(NUMBER_FORMAT) + " V, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Constant SW controlled voltage (use previous), " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.MPPT:
            {
                if (value != null)
                {
                    //this.name = "Maximum power point tracker from " + ((double)value).ToString(NUMBER_FORMAT) + " A, " + durationString + " " + timeUnit.ToString();
                    this.name = "Maximum power point tracker from " + ((double)value).ToString(NUMBER_FORMAT) + " V, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    //this.name = "Maximum power point tracker (use previous current), " + durationString + " " + timeUnit.ToString();
                    this.name = "Maximum power point tracker (use previous voltage), " + durationString + " " + timeUnit.ToString();
                }

                break;
            }

            case Modes.SimpleAmmeter:
            {
                name = "Simple ammeter, " + durationString + " " + timeUnit.ToString();
                break;
            }
            }
        }
Пример #3
0
        // creates ramp mode program item
        private void ramp(Modes mode, double?startingValue, double finalValue, string durationString, TimeUnits timeUnit)
        {
            this.programMode    = ProgramModes.Ramp;
            this.mode           = mode;
            this.durationString = durationString;
            this.timeUnit       = timeUnit;
            this.startingValue  = startingValue;
            this.finalValue     = finalValue;

            // compute duration in seconds
            Converters.TimeConverter timeConverter = new Converters.TimeConverter();
            this.duration = (double)(timeConverter.ConvertBack(durationString, typeof(double), timeUnit, System.Globalization.CultureInfo.CurrentCulture));

            // string representation for GUI
            switch (mode)
            {
            case Modes.Current:
            {
                if (startingValue != null)
                {
                    this.name = "Ramp current " + ((double)startingValue).ToString(NUMBER_FORMAT) + " –> " + finalValue.ToString(NUMBER_FORMAT) + " A, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Ramp current (use previous) –> " + finalValue.ToString(NUMBER_FORMAT) + " A, " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.Power_CC:
            {
                if (startingValue != null)
                {
                    this.name = "Ramp power (CC) " + ((double)startingValue).ToString(NUMBER_FORMAT) + " –> " + finalValue.ToString(NUMBER_FORMAT) + " W, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Ramp power (CC, use previous) –> " + finalValue.ToString(NUMBER_FORMAT) + " W, " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.Power_CV:
            {
                if (startingValue != null)
                {
                    this.name = "Ramp power (CV) " + ((double)startingValue).ToString(NUMBER_FORMAT) + " –> " + finalValue.ToString(NUMBER_FORMAT) + " W, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Ramp power (CV, use previous) –> " + finalValue.ToString(NUMBER_FORMAT) + " W, " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.Resistance_CC:
            {
                if (startingValue != null)
                {
                    this.name = "Ramp resistance (CC) " + ((double)startingValue).ToString(NUMBER_FORMAT) + " –> " + finalValue.ToString(NUMBER_FORMAT) + " Ω, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Ramp resistance (CC, use previous) –> " + finalValue.ToString(NUMBER_FORMAT) + " Ω, " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.Resistance_CV:
            {
                if (startingValue != null)
                {
                    this.name = "Ramp resistance (CV) " + ((double)startingValue).ToString(NUMBER_FORMAT) + " –> " + finalValue.ToString(NUMBER_FORMAT) + " Ω, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Ramp resistance (CV, use previous) –> " + finalValue.ToString(NUMBER_FORMAT) + " Ω, " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.Voltage:
            {
                if (startingValue != null)
                {
                    this.name = "Ramp voltage " + ((double)startingValue).ToString(NUMBER_FORMAT) + " –> " + finalValue.ToString(NUMBER_FORMAT) + " V, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Ramp voltage (use previous) –> " + finalValue.ToString(NUMBER_FORMAT) + " V, " + durationString + " " + timeUnit.ToString();
                }
                break;
            }

            case Modes.VoltageSoftware:
            {
                if (startingValue != null)
                {
                    this.name = "Ramp SW controlled voltage " + ((double)startingValue).ToString(NUMBER_FORMAT) + " –> " + finalValue.ToString(NUMBER_FORMAT) + " V, " + durationString + " " + timeUnit.ToString();
                }
                else
                {
                    this.name = "Ramp SW controlled voltage (use previous) –> " + finalValue.ToString(NUMBER_FORMAT) + " V, " + durationString + " " + timeUnit.ToString();
                }
                break;
            }
            }
        }
Пример #4
0
    private void Init(string[] args)
    {
        string[] coords            = { "" };
        bool     enabledConsoleLog = false;

        Logger.LogLevels logLevel  = Logger.LogLevels.INFO;
        List <LogTarget> logTagets = new List <LogTarget>()
        {
            new FileLogTarget("MyLogFile.log", createEmptyLogFile: true)
        };

        foreach (string arg in args)
        {
            string[] argData = arg.Split('=', 2);

            string command = argData[0].Trim();

            if (command.StartsWith("/consoleLog") && argData.Length > 1)
            {
                if (string.Equals(argData[1].Trim().ToLower(), "true"))
                {
                    logTagets.Add(new ConsoleLogTarget()); enabledConsoleLog = true;
                }
                continue;
            }

            if (command.StartsWith("/logLevel") && argData.Length > 1)
            {
                if (!Enum.TryParse <Logger.LogLevels>(argData[1].Trim(), true, out logLevel))
                {
                    logLevel = Logger.LogLevels.INFO;
                }
                continue;
            }

            if (command.StartsWith("/mode") && argData.Length > 1)
            {
                if (!Enum.TryParse <ProgramModes>(argData[1].Trim(), true, out programMode))
                {
                    programMode = ProgramModes.BOT;
                }
                continue;
            }

            if (command.StartsWith("/setwin") && argData.Length > 1)
            {
                coords = argData[1].Split(',');
                if (coords.Length == 4)
                {
                    Span <string> coordinates = new Span <string>(coords);
                    SeConsoleWindowPosition(coordinates);
                }

                continue;
            }
        }

        LogManager.LogLevel = logLevel;
        LogManager.LogTargets.AddRange(logTagets);

        if (logger.IsInfoLevelLog)
        {
            logger.Info($"Command line args: \"{string.Join(" ",args)}\"");
        }
        if (logger.IsInfoLevelLog)
        {
            logger.Info($"Program configured data: /mode={programMode} /consoleLog={enabledConsoleLog.ToString().ToLower()} /logLevel={logLevel.ToString().ToUpper()} /setwin={string.Join(",", coords)}");
        }

        ShowBoard = false;
        engine    = new Engine();
    }