/// <summary>
        /// Saves the current settings to unit memory
        /// </summary>
        /// <returns>True if save is successful, false if failed.</returns>
        public bool SettingsSave()
        {
            string workingLine;

            return(_port.SendCommandSingleTest("&s", "&s", out workingLine, echoComTraffic: _echoComTraffic));
        }
Example #2
0
        /// <summary>
        /// Gets a ControlsObject that represents the current status of all CVLS Controls
        /// </summary>
        /// <returns>The current ControlsObject</returns>
        public ControlsObject GetAll()
        {
            var    i = 0;
            string line;

            if (!_port.SendCommandSingleTest("&*c", "&*c", out line, true))
            {
                return(null);
            }

            var tokens = line.Split(',');

            if (tokens.Length != 56)
            {
                return(null);
            }

            var controlsBuilder = new ControlsObject.Builder();

            #region LED Settings

            var ledBuilder = new LedObject.Builder
            {
                DemoMode    = tokens[i++] == "1",
                TriggerMode = tokens[i++] == "1" ? TriggerModes.Combined : TriggerModes.Independent,
                KnobMode    = (KnobControl)int.Parse(tokens[i++]),
                ChannelMode = tokens[i++] == "1" ? ChannelModes.Single : ChannelModes.Quad,
                Enable      = tokens[i++] == "1",
                Power       = int.Parse(tokens[i++]) * 0.1
            };

            for (var j = 1; j <= 4; j++)
            {
                ledBuilder.Channel((Enums.Channels)j, new LedChannelObject.Builder
                {
                    Enabled          = tokens[i++] == "1",
                    Power            = int.Parse(tokens[i++]) * 0.1,
                    ShutdownPolarity = tokens[i++] == "1" ? SignalPolarity.ActiveHigh : SignalPolarity.ActiveLow
                }.Build());
            }

            controlsBuilder.Led = ledBuilder.Build();

            #endregion

            #region Continuous Strobe

            var continuousStrobeBuilder = new ContinuousStrobeObject.Builder
            {
                Enable      = tokens[i++] == "1",
                ChannelMode = tokens[i++] == "1" ? ChannelModes.Single : ChannelModes.Quad,
                Frequency   = int.Parse(tokens[i++])
            };

            for (var j = 1; j <= 4; j++)
            {
                continuousStrobeBuilder.Channel((Enums.Channels)j, new ContinuousStrobeChannelObject.Builder
                {
                    DutyCycle    = int.Parse(tokens[i++]) * 0.1,
                    PhaseShift   = int.Parse(tokens[i++]) * 0.1,
                    WavePolarity = tokens[i++] == "1" ? SignalPolarity.ActiveHigh : SignalPolarity.ActiveLow
                }.Build());
            }

            controlsBuilder.ContinuousStrobe = continuousStrobeBuilder.Build();

            #endregion

            #region Triggered Strobe

            var triggeredStrobeBuilder = new TriggeredStrobeObject.Builder
            {
                Enable      = tokens[i++] == "1",
                TriggerMode = tokens[i++] == "1" ? TriggerModes.Combined : TriggerModes.Independent,
                ChannelMode = tokens[i++] == "1" ? ChannelModes.Single : ChannelModes.Quad
            };

            for (var j = 1; j <= 4; j++)
            {
                triggeredStrobeBuilder.Channel((Enums.Channels)j, new TriggeredStrobeChannelObject.Builder
                {
                    Delay    = int.Parse(tokens[i++]),
                    OnTime   = int.Parse(tokens[i++]),
                    EdgeType = tokens[i++] == "1" ? EdgeTypes.FallingEdge : EdgeTypes.RisingEdge
                }.Build());
            }

            controlsBuilder.TriggeredStrobe = triggeredStrobeBuilder.Build();

            #endregion

            #region Equalizer Settings

            controlsBuilder.Equalizer = new EqualizerObject.Builder
            {
                Enable      = tokens[i++] == "1",
                Delay       = int.Parse(tokens[i++]),
                Target      = int.Parse(tokens[i++]),
                LightOutput = int.Parse(tokens[i++]),
                PowerOutput = double.Parse(tokens[i++])
            }.Build();

            #endregion

            #region Fan Settings

            controlsBuilder.Fan = new FanObject.Builder
            {
                ManualOverride = tokens[i++] == "1",
                Speed          = int.Parse(tokens[i]) * 0.1
            }.Build();

            #endregion

            return(controlsBuilder.Build());
        }
Example #3
0
        /// <summary>
        /// Gets a StatusObject that represents the current status of the CVLS Unit
        /// </summary>
        /// <returns>The current StatusObject</returns>
        public StatusObject GetAll()
        {
            var statusObjectBuilder = new StatusObject.Builder();

            var    i = 0;
            string line;

            if (!_port.SendCommandSingleTest("&*s", "&*s", out line, true))
            {
                return(null);
            }

            var tokens = line.Split(',');

            if (tokens.Length != 25)
            {
                return(null);
            }

            try
            {
                #region Parse Data Stream

                statusObjectBuilder.TemperatureLed = new TemperatureObject.Builder
                {
                    Temperature      = double.Parse(tokens[i++].Split(' ')[0]),
                    Status           = (StatusIndicators)int.Parse(tokens[i++]),
                    ThermistorStatus = (StatusIndicators)int.Parse(tokens[i++])
                }.Build();

                statusObjectBuilder.TemperatureBoard = new TemperatureObject.Builder
                {
                    Temperature      = double.Parse(tokens[i++].Split(' ')[0]),
                    Status           = (StatusIndicators)int.Parse(tokens[i++]),
                    ThermistorStatus = (StatusIndicators)int.Parse(tokens[i++])
                }.Build();

                statusObjectBuilder.VoltageRefOut = new VoltageObject.Builder
                {
                    Voltage = double.Parse(tokens[i++].Split(' ')[0]),
                    Status  = (StatusIndicators)int.Parse(tokens[i++])
                }.Build();

                statusObjectBuilder.VoltageInput = new VoltageObject.Builder
                {
                    Voltage = double.Parse(tokens[i++].Split(' ')[0]),
                    Status  = (StatusIndicators)int.Parse(tokens[i++])
                }.Build();

                statusObjectBuilder.Fan = new FanStatusObject.Builder
                {
                    Speed  = int.Parse(tokens[i++].Split(' ')[0]),
                    Status = (StatusIndicators)int.Parse(tokens[i++])
                }.Build();

                var systemObjectBuilder = new SystemObject.Builder
                {
                    SystemMode = (SystemMode)int.Parse(tokens[i++])
                };

                statusObjectBuilder.Equalizer = new EqualizerStatusObject.Builder
                {
                    Mode   = (EqualizerStatus)int.Parse(tokens[i++]),
                    Status = (StatusIndicators)int.Parse(tokens[i++])
                }.Build();

                systemObjectBuilder.LightFeedBack     = int.Parse(tokens[i++]);
                systemObjectBuilder.LastCommandSource = (CommandSource)int.Parse(tokens[i++]);
                systemObjectBuilder.UserMode          = (UserMode)int.Parse(tokens[i++]);
                systemObjectBuilder.KnobMode          = (KnobControl)int.Parse(tokens[i++]);
                systemObjectBuilder.Time   = new TimeObject(uint.Parse(tokens[i++]));
                statusObjectBuilder.System = systemObjectBuilder.Build();

                statusObjectBuilder.Memory = new MemoryObject.Builder
                {
                    CustomerSettings = uint.Parse(tokens[i++]),
                    FactorySettings  = uint.Parse(tokens[i++]),
                    Firmware         = uint.Parse(tokens[i++]),
                    Exceptions       = uint.Parse(tokens[i++])
                }.Build();

                statusObjectBuilder.Identification = new IdentificationObject.Builder
                {
                    SerialFull = tokens[i],
                    Serial     = uint.Parse(tokens[i].Split(':')[1]),
                    Model      = tokens[i].Split(':')[0]
                }.Build();

                #endregion
            }
            catch
            {
                return(null);
            }

            return(statusObjectBuilder.Build());
        }
Example #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool ClearLogs()
        {
            string workingLine;

            return(_port.SendCommandSingleTest("&o3", "&o3", out workingLine, echoComTraffic: _echoComTraffic));
        }