Esempio n. 1
0
        void LoadSetting(OSDSetting setting)
        {
            for (int i = 0; i < OSDItemList.Avaliable.Length; i++)
            {
                /*bool alt = false;
                 * foreach (var a in OSDItemList.Alternates)
                 *  if (OSDItemList.Avaliable[i] == a.Key && setting.IsEnabled(a.Value))
                 *  {
                 *      LIST_items.SetItemChecked(i, false);
                 *      alt = true;
                 *  }
                 *
                 * if (!alt)*/
                LIST_items.SetItemChecked(i, setting.IsEnabled(OSDItemList.Avaliable[i]));
            }

            foreach (var r in adreadings)
            {
                r[0].reading = r[1].reading = 0;
                r[0].value   = r[1].value = 0;
            }
            rbMetric.Checked   = setting.GetOption(OSDOption.M_ISO);
            rbImperial.Checked = !rbMetric.Checked;

            cbFunction_SelectedIndexChanged(this, new EventArgs());

            osd.Setting = setting;
            osd.Draw();
        }
Esempio n. 2
0
        public int GetSetting(out OSDSetting setting)
        {
            int ok = -1;

            setting = null;
            try
            {
                EnterCLI();
                Write("s");


                if (ReadByte() == 's')
                {
                    int    size = ReadByte();
                    byte[] buf  = new byte[size + 1];

                    int tl = 0;
                    while ((tl += Read(buf, tl, size + 1 - tl)) < size + 1)
                    {
                        //toolStripProgressBar1.Value = tl * 100 / (size + 1);
                    }

                    byte ck = 0;
                    for (int i = 0; i < size; i++)
                    {
                        ck = (byte)(ck + buf[i]);
                    }

                    if (ck == buf[size])
                    {
                        setting = new OSDSetting();
                        ok      = setting.FromBytes(buf, 0) ? 0 : 1;
                    }
                }

                // Close();
            }
            catch (Exception)
            {
            }
            return(ok);
        }
Esempio n. 3
0
        private void loadFromFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog()
            {
                Filter = "*.osd|*.osd"
            };
            bool ok = false;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    using (Stream f = ofd.OpenFile())
                    {
                        OSDSetting setting = new OSDSetting();
                        byte[]     buf     = new byte[128];
                        f.Read(buf, 0, 4);
                        if (Encoding.ASCII.GetString(buf, 0, 4) == "HOSD")
                        {
                            f.Read(buf, 0, 4);
                            f.Read(buf, 0, BitConverter.ToInt32(buf, 0));
                            if (ok = setting.FromBytes(buf, 0))
                            {
                                LoadSetting(setting);
                            }
                        }
                        if (!ok)
                        {
                            MessageBox.Show(this, rmMessages.GetString("Invalid_File_Format"), rmMessages.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                catch
                {
                    MessageBox.Show(this, rmMessages.GetString("Read_Setting_Failed"), rmMessages.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            osd.Draw();
        }
Esempio n. 4
0
        public bool UploadSetting(OSDSetting setting)
        {
            byte[] data = setting.ToBytes();
            byte[] buf  = new byte[data.Length + 2];
            buf[0] = (byte)data.Length;
            Array.Copy(data, 0, buf, 1, data.Length);

            int ck = 0;

            for (int i = 0; i < data.Length; i++)
            {
                ck += data[i];
            }
            buf[buf.Length - 1] = (byte)ck;

            bool ok = true;

            try
            {
                EnterCLI();
                Write("S");
                if (ReadByte() == 'S')
                {
                    Write(buf, 0, buf.Length);

                    int ack = ReadByte();
                    if (ack != '!')
                    {
                        //MessageBox.Show("write setting error");
                        ok = false;
                    }
                }
                //    Close();
            }
            catch (Exception)
            {
            }
            return(ok);
        }
Esempio n. 5
0
        //static byte apm_mav_system = 7;
        //static byte apm_mav_component = 0;
        //static boolean enable_mav_request = 0;




        public ArduOSD()
        {
            Setting = new OSDSetting();

        }
Esempio n. 6
0
        private void loadFromFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog() { Filter = "*.osd|*.osd" };
            bool ok = false;

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    using (Stream f = ofd.OpenFile())
                    {
                        OSDSetting setting = new OSDSetting();
                        byte[] buf = new byte[128];
                        f.Read(buf, 0, 4);
                        if (Encoding.ASCII.GetString(buf, 0, 4) == "HOSD")
                        {
                            f.Read(buf, 0, 4);
                            f.Read(buf, 0, BitConverter.ToInt32(buf, 0));
                            if (ok = setting.FromBytes(buf, 0))
                                LoadSetting(setting);
                        }
                        if (!ok)
                            MessageBox.Show(this, rmMessages.GetString("Invalid_File_Format"), rmMessages.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch
                {
                    MessageBox.Show(this, rmMessages.GetString("Read_Setting_Failed"), rmMessages.GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            osd.Draw();
        }
Esempio n. 7
0
        void LoadSetting(OSDSetting setting)
        {
            for (int i = 0; i < OSDItemList.Avaliable.Length; i++)
            {
                /*bool alt = false;
                foreach (var a in OSDItemList.Alternates)
                    if (OSDItemList.Avaliable[i] == a.Key && setting.IsEnabled(a.Value))
                    {
                        LIST_items.SetItemChecked(i, false);
                        alt = true;
                    }

                if (!alt)*/
                LIST_items.SetItemChecked(i, setting.IsEnabled(OSDItemList.Avaliable[i]));
            }

            foreach (var r in adreadings)
            {
                r[0].reading = r[1].reading = 0;
                r[0].value = r[1].value = 0;
            }
            rbMetric.Checked = setting.GetOption(OSDOption.M_ISO);
            rbImperial.Checked = !rbMetric.Checked;

            cbFunction_SelectedIndexChanged(this, new EventArgs());

            osd.Setting = setting;
            osd.Draw();
        }
Esempio n. 8
0
        public bool UploadSetting(OSDSetting setting)
        {
            byte[] data = setting.ToBytes();
            byte[] buf = new byte[data.Length + 2];
            buf[0] = (byte)data.Length;
            Array.Copy(data, 0, buf, 1, data.Length);

            int ck = 0;
            for (int i = 0; i < data.Length; i++)
                ck += data[i];
            buf[buf.Length - 1] = (byte)ck;

            bool ok = true;
            try
            {
                EnterCLI();
                Write("S");
                if (ReadByte() == 'S')
                {
                    Write(buf, 0, buf.Length);

                    int ack = ReadByte();
                    if (ack != '!')
                    {
                        //MessageBox.Show("write setting error");
                        ok = false;
                    }
                }
                //    Close();
            }
            catch (Exception)
            {
            }
            return ok;
        }
Esempio n. 9
0
        public int GetSetting(out OSDSetting setting)
        {
            int ok = -1;
            setting = null;
            try
            {
                EnterCLI();
                Write("s");


                if (ReadByte() == 's')
                {
                    int size = ReadByte();
                    byte[] buf = new byte[size + 1];

                    int tl = 0;
                    while ((tl += Read(buf, tl, size + 1 - tl)) < size + 1)
                    {
                        //toolStripProgressBar1.Value = tl * 100 / (size + 1);
                    }

                    byte ck = 0;
                    for (int i = 0; i < size; i++)
                        ck = (byte)(ck + buf[i]);

                    if (ck == buf[size])
                    {
                        setting = new OSDSetting();
                        ok = setting.FromBytes(buf, 0) ? 0 : 1;
                    }
                }

                // Close();
            }
            catch (Exception)
            {
            }
            return ok;
        }
Esempio n. 10
0
        //static byte apm_mav_system = 7;
        //static byte apm_mav_component = 0;
        //static boolean enable_mav_request = 0;



        public ArduOSD()
        {
            Setting = new OSDSetting();
        }