Пример #1
0
        public Configuration()
        {
            UseFreedomUnits = Properties.Settings.Default.UseFreedomUnits;
            MaxCurrentAmps  = 0;
            LowCutoffVolts  = 0;

            UseSpeedSensor = false;
            UseDisplay     = false;
            UsePushWalk    = false;

            WheelSizeInch         = 0;
            NumWheelSensorSignals = 0;
            MaxSpeedKph           = 0;

            PasStartDelayPulses      = 0;
            PasStopDelayMilliseconds = 0;

            ThrottleStartMillivolts = 0;
            ThrottleEndMillivolts   = 0;
            ThrottleStartPercent    = 0;

            AssistModeSelection = AssistModeSelect.Off;
            AssistStartupLevel  = 0;

            for (int i = 0; i < StandardAssistLevels.Length; ++i)
            {
                StandardAssistLevels[i] = new AssistLevel();
            }

            for (int i = 0; i < SportAssistLevels.Length; ++i)
            {
                SportAssistLevels[i] = new AssistLevel();
            }
        }
Пример #2
0
        public bool ParseFromBuffer(byte[] buffer)
        {
            if (buffer.Length != ByteSize)
            {
                return(false);
            }

            using (var s = new MemoryStream(buffer))
            {
                var br = new BinaryReader(s);

                UseFreedomUnits = br.ReadBoolean();

                MaxCurrentAmps = br.ReadByte();
                LowCutoffVolts = br.ReadByte();
                MaxSpeedKph    = br.ReadByte();

                UseSpeedSensor = br.ReadBoolean();
                UseDisplay     = br.ReadBoolean();
                UsePushWalk    = br.ReadBoolean();

                WheelSizeInch         = br.ReadUInt16() / 10f;
                NumWheelSensorSignals = br.ReadByte();

                PasStartDelayPulses      = br.ReadByte();
                PasStopDelayMilliseconds = br.ReadByte() * 10u;

                ThrottleStartMillivolts = br.ReadUInt16();
                ThrottleEndMillivolts   = br.ReadUInt16();
                ThrottleStartPercent    = br.ReadByte();

                AssistModeSelection = (AssistModeSelect)br.ReadByte();
                AssistStartupLevel  = br.ReadByte();

                for (int i = 0; i < 10; ++i)
                {
                    StandardAssistLevels[i].Type = (AssistType)br.ReadByte();
                    StandardAssistLevels[i].MaxCurrentPercent  = br.ReadByte();
                    StandardAssistLevels[i].MaxThrottlePercent = br.ReadByte();
                    StandardAssistLevels[i].MaxCadencePercent  = br.ReadByte();
                    StandardAssistLevels[i].MaxSpeedPercent    = br.ReadByte();
                }

                for (int i = 0; i < 10; ++i)
                {
                    SportAssistLevels[i].Type = (AssistType)br.ReadByte();
                    SportAssistLevels[i].MaxCurrentPercent  = br.ReadByte();
                    SportAssistLevels[i].MaxThrottlePercent = br.ReadByte();
                    SportAssistLevels[i].MaxCadencePercent  = br.ReadByte();
                    SportAssistLevels[i].MaxSpeedPercent    = br.ReadByte();
                }
            }

            return(true);
        }
Пример #3
0
        public void CopyFrom(Configuration cfg)
        {
            UseFreedomUnits          = cfg.UseFreedomUnits;
            MaxCurrentAmps           = cfg.MaxCurrentAmps;
            LowCutoffVolts           = cfg.LowCutoffVolts;
            UseSpeedSensor           = cfg.UseSpeedSensor;
            UseDisplay               = cfg.UseDisplay;
            UsePushWalk              = cfg.UsePushWalk;
            WheelSizeInch            = cfg.WheelSizeInch;
            NumWheelSensorSignals    = cfg.NumWheelSensorSignals;
            MaxSpeedKph              = cfg.MaxSpeedKph;
            PasStartDelayPulses      = cfg.PasStartDelayPulses;
            PasStopDelayMilliseconds = cfg.PasStopDelayMilliseconds;
            ThrottleStartMillivolts  = cfg.ThrottleStartMillivolts;
            ThrottleEndMillivolts    = cfg.ThrottleEndMillivolts;
            ThrottleStartPercent     = cfg.ThrottleStartPercent;
            AssistModeSelection      = cfg.AssistModeSelection;
            AssistStartupLevel       = cfg.AssistStartupLevel;

            for (int i = 0; i < Math.Min(cfg.StandardAssistLevels.Length, 10); ++i)
            {
                StandardAssistLevels[i].Type = cfg.StandardAssistLevels[i].Type;
                StandardAssistLevels[i].MaxCurrentPercent  = cfg.StandardAssistLevels[i].MaxCurrentPercent;
                StandardAssistLevels[i].MaxThrottlePercent = cfg.StandardAssistLevels[i].MaxThrottlePercent;
                StandardAssistLevels[i].MaxCadencePercent  = cfg.StandardAssistLevels[i].MaxCadencePercent;
                StandardAssistLevels[i].MaxSpeedPercent    = cfg.StandardAssistLevels[i].MaxSpeedPercent;
            }

            for (int i = 0; i < Math.Min(cfg.SportAssistLevels.Length, 10); ++i)
            {
                SportAssistLevels[i].Type = cfg.SportAssistLevels[i].Type;
                SportAssistLevels[i].MaxCurrentPercent  = cfg.SportAssistLevels[i].MaxCurrentPercent;
                SportAssistLevels[i].MaxThrottlePercent = cfg.SportAssistLevels[i].MaxThrottlePercent;
                SportAssistLevels[i].MaxCadencePercent  = cfg.SportAssistLevels[i].MaxCadencePercent;
                SportAssistLevels[i].MaxSpeedPercent    = cfg.SportAssistLevels[i].MaxSpeedPercent;
            }
        }