예제 #1
0
        public static RovioMcuReport Parse(RovioResponse dic)
        {
            RovioMcuReport report = new RovioMcuReport();

            //0E0100000000000000000003CB744B
            string responses = dic["responses"];

            byte[] data = new byte[responses.Length / 2];
            for (int i = 0; i < data.Length; i++)
            {
                data[i] = byte.Parse(responses.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);
            }

            int offset = 0;
            //Length of the packet
            int length = data[offset]; offset += 1;

            //NOT IN USE
            offset += 1;
            //Direction of rotation of left wheel since last read (bit 2)
            int leftWheelDirection = data[offset]; offset += 1;
            //Number of left wheel encoder ticks since last read
            int leftWheelTicks = data[offset] + data[offset + 1] * 256; offset += 2;
            //Direction of rotation of right wheel since last read (bit 2)
            int rightWheelDirection = data[offset]; offset += 1;
            //Number of right wheel encoder ticks since last read
            int rightWheelTicks = data[offset] + data[offset + 1] * 256; offset += 2;
            //Direction of rotation of rear wheel since last read (bit 2)
            int rearWheelDirection = data[offset]; offset += 1;
            //Number of rear wheel encoder ticks since last read
            int rearWheelTicks = data[offset] + data[offset + 1] * 256; offset += 2;

            //NOT IN USE
            offset += 1;
            //Head position
            int headPosition = data[offset]; offset += 1;
            //Battery
            //  0x7F: Battery Full (0x7F or higher for new battery)
            //  0x??: Orange light in Rovio head. ( to be define)
            //  0x6A: Very low battery (Hungry, danger, very low battery level)
            //  libNS need take control to go home and charging
            //  0x64: Shutdown level (MCU will cut off power for protecting the battery)
            int battery = data[offset]; offset += 1;
            //status
            //bit 0 : Light LED (head) status, 0: OFF, 1: ON
            //bit 1 : IR-Radar power status. 0: OFF, 1: ON
            //bit 2 : IR-Radar detector status: 0: fine, 1: barrier detected.
            //bit 3-5: Charger staus
            //        0x00 : nothing happen
            //        0x01 : charging completed.
            //        0x02 : in charging
            //        0x04 : something wrong, error occur.
            //bit 6,7: undefined, do not use.
            byte status = data[offset]; offset += 1;

            report.HeadLight = ((status & 0x01) == 0x01) ? HeadLightState.On : HeadLightState.Off;

            return(report);
        }
예제 #2
0
        public static RovioMcuReport Parse(RovioResponse dic)
        {
            RovioMcuReport report = new RovioMcuReport();

            //0E0100000000000000000003CB744B
            string responses = dic["responses"];
            byte[] data = new byte[responses.Length / 2];
            for(int i=0;i<data.Length; i++)
                data[i] = byte.Parse(responses.Substring(i * 2, 2), System.Globalization.NumberStyles.HexNumber);

            int offset = 0;
            //Length of the packet
            int length = data[offset]; offset += 1;
            //NOT IN USE
            offset += 1;
            //Direction of rotation of left wheel since last read (bit 2)
            int leftWheelDirection = data[offset]; offset +=1;
            //Number of left wheel encoder ticks since last read
            int leftWheelTicks = data[offset] + data[offset + 1] * 256; offset += 2;
            //Direction of rotation of right wheel since last read (bit 2)
            int rightWheelDirection = data[offset]; offset +=1;
            //Number of right wheel encoder ticks since last read
            int rightWheelTicks = data[offset] + data[offset + 1] * 256; offset += 2;
            //Direction of rotation of rear wheel since last read (bit 2)
            int rearWheelDirection = data[offset]; offset +=1;
            //Number of rear wheel encoder ticks since last read
            int rearWheelTicks = data[offset] + data[offset + 1] * 256; offset += 2;
            //NOT IN USE
            offset += 1;
            //Head position
            int headPosition = data[offset]; offset += 1;
            //Battery
            //  0x7F: Battery Full (0x7F or higher for new battery)
            //  0x??: Orange light in Rovio head. ( to be define)
            //  0x6A: Very low battery (Hungry, danger, very low battery level)
            //  libNS need take control to go home and charging
            //  0x64: Shutdown level (MCU will cut off power for protecting the battery)
            int battery = data[offset]; offset += 1;
            //status
            //bit 0 : Light LED (head) status, 0: OFF, 1: ON
            //bit 1 : IR-Radar power status. 0: OFF, 1: ON
            //bit 2 : IR-Radar detector status: 0: fine, 1: barrier detected.
            //bit 3-5: Charger staus
            //        0x00 : nothing happen
            //        0x01 : charging completed.
            //        0x02 : in charging
            //        0x04 : something wrong, error occur.
            //bit 6,7: undefined, do not use.
            byte status = data[offset]; offset += 1;

            report.HeadLight = ((status & 0x01) == 0x01) ? HeadLightState.On : HeadLightState.Off;

            return report;
        }
예제 #3
0
            internal override void Load(Dictionary <FlashParameters, Int32> flashParameters, RovioStatusReport report, RovioMcuReport mcuReport)
            {
                RovioAPI api = owner.rovio.API;

                this.brightness       = report.brightness;
                this.resolutionId     = report.ResolutionId;
                this.videoCompression = report.VideoCompression;
                this.frameRate        = report.frame_rate;
                this.acFrequency      = report.ACFrequency;

                this.modified = false;
            }
예제 #4
0
            internal override void Load(Dictionary <FlashParameters, Int32> flashParameters, RovioStatusReport report, RovioMcuReport mcuReport)
            {
                MailSettings settings = owner.rovio.API.GetMail();

                this.enabled      = settings.Enabled;
                this.mailServer   = settings.MailServer;
                this.port         = settings.Port;
                this.sender       = settings.Sender;
                this.receiver     = settings.Receiver;
                this.subject      = settings.Subject;
                this.body         = settings.Body;
                this.userName     = settings.UserName;
                this.password     = settings.Password;
                this.authRequired = settings.AuthRequired;
                this.interval     = settings.Interval;

                this.modified = false;
            }
예제 #5
0
            internal override void Load(Dictionary<FlashParameters, Int32> flashParameters, RovioStatusReport report, RovioMcuReport mcuReport)
            {
                //此处跟Rovio Web设置保持一致,范围是1-10, 1为最慢
                this.movementSpeed = RovioAPI.GetDouble(
                    flashParameters[FlashParameters.MovementSpeed], 1, 10, 0.5);
                this.turnSpeed = RovioAPI.GetDouble(
                    flashParameters[FlashParameters.TurnSpeed], 1, 10, 0.5);
                this.rotSpeed = RovioAPI.GetDouble(
                    flashParameters[FlashParameters.RotSpeed], 1, 10, 0.8);

                this.modified = false;
            }
예제 #6
0
        /// <summary>
        /// Returns MCU report including wheel encoders and IR obstacle avoidance.
        /// </summary>
        /// <returns></returns>
        public RovioMcuReport GetMCUReport()
        {
            RovioResponse dic = MovementControl(Commands.GetMCUReport);

            return(RovioMcuReport.Parse(dic));
        }
예제 #7
0
 internal abstract void Load(Dictionary<FlashParameters, Int32> flashParameters, RovioStatusReport report, RovioMcuReport mcuReport);
예제 #8
0
            internal override void Load(Dictionary<FlashParameters, Int32> flashParameters, RovioStatusReport report, RovioMcuReport mcuReport)
            {
                MailSettings settings = owner.rovio.API.GetMail();
                this.enabled = settings.Enabled;
                this.mailServer = settings.MailServer;
                this.port = settings.Port;
                this.sender = settings.Sender;
                this.receiver = settings.Receiver;
                this.subject = settings.Subject;
                this.body = settings.Body;
                this.userName = settings.UserName;
                this.password = settings.Password;
                this.authRequired = settings.AuthRequired;
                this.interval = settings.Interval;

                this.modified = false;
            }
예제 #9
0
 internal abstract void Load(Dictionary <FlashParameters, Int32> flashParameters, RovioStatusReport report, RovioMcuReport mcuReport);
예제 #10
0
        public void Load()
        {
            RovioAPI           api       = rovio.API;
            MovementController movement  = api.Movement;
            CameraController   camera    = api.Camera;
            RovioStatusReport  report    = movement.GetReport();
            RovioMcuReport     mcuReport = movement.GetMCUReport();
            Dictionary <FlashParameters, Int32> flashParameters = movement.ReadAllParameters();


            this.Name     = api.GetName();
            this.DateTime = api.GetTime();

            this.MaintainAspectRatio = RovioAPI.GetBoolean(flashParameters[FlashParameters.MaintainAspectRatio]);

            ///// <summary>
            ///// i_LR
            ///// </summary>
            //latency = 4,

            this.PlayerType = (VideoPlayers)flashParameters[FlashParameters.video_player];
            ///// <summary>
            ///// i_UPnP  upnp just enabled
            ///// </summary>
            //upnp_just_enabled = 6,
            ///// <summary>
            ///// i_SS    show status
            ///// </summary>
            //show_online_status = 7,
            ///// <summary>
            ///// i_MIIP1  manual ip
            ///// </summary>
            //manual_internetip = 8,
            ///// <summary>
            ///// i_MIIP2   manual ip
            ///// </summary>
            //manual_internetip2 = 9,
            ///// <summary>
            ///// i_VIA    verify internet access
            ///// </summary>
            //net_verify_access = 10,
            this.FirmwareAlert = RovioAPI.GetBoolean(
                flashParameters[FlashParameters.firmware_alert]);
            ///// <summary>
            ///// i_AVF    auto set video frequency
            ///// </summary>
            //video_freq = 12,

            this.IrDetectEnabled = ((report.Flags & RovioFlags.IRDetectorActivated) == RovioFlags.IRDetectorActivated);

            this.HeadLight  = mcuReport.HeadLight;
            this.BlueLights = (BlueLightState)RovioAPI.GetByte(flashParameters[FlashParameters.BlueLights], (byte)BlueLightState.All);
            this.NightMode  = (NightMode)RovioAPI.GetByte(flashParameters[FlashParameters.NightMode], (byte)NightMode.Normal);

            this.SpeakerVolume    = report.speaker_volume;
            this.MicrophoneVolume = report.mic_volume;

            groupVideo.Load(flashParameters, report, mcuReport);
            groupMovement.Load(flashParameters, report, mcuReport);
            groupMail.Load(flashParameters, report, mcuReport);
        }
예제 #11
0
            internal override void Load(Dictionary<FlashParameters, Int32> flashParameters, RovioStatusReport report, RovioMcuReport mcuReport)
            {
                RovioAPI api = owner.rovio.API;

                this.brightness = report.brightness;
                this.resolutionId = report.ResolutionId;
                this.videoCompression = report.VideoCompression;
                this.frameRate = report.frame_rate;
                this.acFrequency = report.ACFrequency;

                this.modified = false;
            }
예제 #12
0
            internal override void Load(Dictionary <FlashParameters, Int32> flashParameters, RovioStatusReport report, RovioMcuReport mcuReport)
            {
                //此处跟Rovio Web设置保持一致,范围是1-10, 1为最慢
                this.movementSpeed = RovioAPI.GetDouble(
                    flashParameters[FlashParameters.MovementSpeed], 1, 10, 0.5);
                this.turnSpeed = RovioAPI.GetDouble(
                    flashParameters[FlashParameters.TurnSpeed], 1, 10, 0.5);
                this.rotSpeed = RovioAPI.GetDouble(
                    flashParameters[FlashParameters.RotSpeed], 1, 10, 0.8);

                this.modified = false;
            }