Exemplo n.º 1
0
        public WinForms()
        {
            InitializeComponent();

            Instance            = this;
            MainV2.speechEngine = new Speech();
        }
Exemplo n.º 2
0
        public WinForms()
        {
            InitializeComponent();

            size = Device.Info.ScaledScreenSize;
            size = Device.Info.PixelScreenSize;

            size = new Forms.Size(900, 540); // 1.66 - remove back and home pane

            Instance            = this;
            MainV2.speechEngine = new Speech();
        }
Exemplo n.º 3
0
        public WinForms()
        {
            InitializeComponent();

            size = Device.Info.ScaledScreenSize;
            size = Device.Info.PixelScreenSize;

            var scale = size.Width / size.Height; // 1.77 1.6  1.33


            size = new Forms.Size(540 * scale, 540);
            if (size.Width < 960)
            {
                size = new Forms.Size(960, 960 / scale);
            }

            Instance            = this;
            MainV2.speechEngine = new Speech();

            // init seril port type
            SerialPort.DefaultType = (self, s, i) =>
            {
                return(Task.Run(async() =>
                {
                    Log.Info(TAG, "SerialPort.DefaultType in " + s + " " + i);

                    // no valid portname to start
                    if (String.IsNullOrEmpty(s))
                    {
                        Log.Info(TAG, "SerialPort.DefaultType passthrough s = null");
                        return self._baseport;
                    }
                    else
                    {
                        var dil = await Test.UsbDevices.GetDeviceInfoList();

                        var di = dil.Where(a => a.board == s);

                        if (di.Count() > 0)
                        {
                            Log.Info(TAG, "SerialPort.DefaultType found device " + di.First().board + " search " + s);
                            return await Test.UsbDevices.GetUSB(di.First());
                        }
                    }

                    Log.Info(TAG, "SerialPort.DefaultType passthrough no board match");
                    return self._baseport;
                }).Result);
            };

            // report back device list
            SerialPort.GetCustomPorts = () =>
            {
                var list1 = Task.Run(async() =>
                {
                    var list = await Test.BlueToothDevice.GetDeviceInfoList();
                    return(list.Select(a => a.board).ToList());
                }).Result;

                var list2 = Task.Run(async() =>
                {
                    var list = await Test.UsbDevices.GetDeviceInfoList();
                    return(list.Select(a => a.board).ToList());
                }).Result;

                list1.AddRange(list2);
                return(list1);
            };

            // support for fw upload
            MissionPlanner.GCSViews.ConfigurationView.ConfigFirmwareManifest.ExtraDeviceInfo += () =>
            {
                return(Task.Run(async() => { return await Test.UsbDevices.GetDeviceInfoList(); }).Result);
            };

            MissionPlanner.GCSViews.ConfigurationView.ConfigFirmware.ExtraDeviceInfo += () =>
            {
                return(Task.Run(async() => { return await Test.UsbDevices.GetDeviceInfoList(); }).Result);
            };
        }
Exemplo n.º 4
0
        public WinForms()
        {
            InitializeComponent();

            size = Device.Info.ScaledScreenSize;
            size = Device.Info.PixelScreenSize;

            Xamarin.Forms.Platform.WinForms.Forms.UIThread = Thread.CurrentThread.ManagedThreadId;

            var scale = size.Width / size.Height; // 1.77 1.6  1.33

            if (scale < 1)
            {
                size = new Forms.Size(960, 960 * scale);
            }
            else
            {
                size = new Forms.Size(540 * scale, 540);
                if (size.Width < 960)
                {
                    size = new Forms.Size(960, 960 / scale);
                }
            }

            if (Device.RuntimePlatform == Device.macOS || Device.RuntimePlatform == Device.UWP)
            {
                size = Device.Info.PixelScreenSize;
                // scale if higher than full hd
                if (size.Width > 1920)
                {
                    size.Width  /= 2;
                    size.Height /= 2;
                }
            }

            Instance = this;
            try
            {
                MainV2.speechEngine = new Speech();
            } catch {}

            RestoreFiles();

            // init seril port type
            SerialPort.DefaultType = (self, s, i) =>
            {
                if (Device.RuntimePlatform == Device.macOS)
                {
                    Log.Info(TAG, "SerialPort.DefaultType in " + s + " " + i + " for " + Device.RuntimePlatform);
                    return(new MonoSerialPort());
                }

                return(Task.Run(async() =>
                {
                    Log.Info(TAG, "SerialPort.DefaultType in " + s + " " + i);

                    // no valid portname to start
                    if (String.IsNullOrEmpty(s))
                    {
                        Log.Info(TAG, "SerialPort.DefaultType passthrough s = null");
                        return self._baseport;
                    }
                    else
                    {
                        if (s.StartsWith("BT_"))
                        {
                            var bt = await Test.BlueToothDevice.GetDeviceInfoList();

                            var di = bt.Where(a => a.board == s);

                            if (di.Count() > 0)
                            {
                                Log.Info(TAG, "SerialPort.DefaultType found device " + di.First().board + " search " + s);
                                return await Test.BlueToothDevice.GetBT(di.First());
                            }
                        }

                        if (s.StartsWith("GPS"))
                        {
                            var com = new CommsInjection();
                            Task.Run(async() => {
                                while (true)
                                {
                                    var(lat, lng, alt) = await Test.GPS.GetPosition();
                                    var latdms = (int)lat + (lat - (int)lat) * .6f;
                                    var lngdms = (int)lng + (lng - (int)lng) * .6f;

                                    var line = string.Format(CultureInfo.InvariantCulture,
                                                             "$GP{0},{1:HHmmss.ff},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14}", "GGA",
                                                             DateTime.Now.ToUniversalTime(),
                                                             Math.Abs(latdms * 100).ToString("0000.00", CultureInfo.InvariantCulture), lat < 0 ? "S" : "N",
                                                             Math.Abs(lngdms * 100).ToString("00000.00", CultureInfo.InvariantCulture), lng < 0 ? "W" : "E",
                                                             1, 10,
                                                             1, alt.ToString("0.00", CultureInfo.InvariantCulture), "M", 0, "M", "0.0", "0");

                                    var checksum = GetChecksum(line);
                                    com.AppendBuffer(ASCIIEncoding.ASCII.GetBytes(line + "*" + checksum + "\r\n"));

                                    await Task.Delay(200);
                                }
                            });

                            return com;
                        }

                        {
                            var dil = await Test.UsbDevices.GetDeviceInfoList();

                            var di = dil.Where(a => a.board == s);

                            if (di.Count() > 0)
                            {
                                Log.Info(TAG,
                                         "SerialPort.DefaultType found device " + di.First().board + " search " + s);
                                return await Test.UsbDevices.GetUSB(di.First());
                            }
                        }
                    }

                    Log.Info(TAG, "SerialPort.DefaultType passthrough no board match");
                    return self._baseport;
                }).Result);
            };

            // report back device list
            SerialPort.GetCustomPorts = () =>
            {
                var list1 = Task.Run(async() =>
                {
                    var list = await Test.BlueToothDevice.GetDeviceInfoList();
                    return(list.Select(a => a.board).ToList());
                }).Result;

                var list2 = Task.Run(async() =>
                {
                    var list = await Test.UsbDevices.GetDeviceInfoList();
                    return(list.Select(a => a.board).ToList());
                }).Result;

                list1.AddRange(list2);
                if (Device.RuntimePlatform == Device.Android)
                {
                    list1.Add("GPS");
                }

                return(list1);
            };

            /*
             * // support for fw upload
             * MissionPlanner.GCSViews.ConfigurationView.ConfigFirmwareManifest.ExtraDeviceInfo += () =>
             * {
             * return Task.Run(async () => { return await Test.UsbDevices.GetDeviceInfoList(); }).Result;
             * };
             *
             * MissionPlanner.GCSViews.ConfigurationView.ConfigFirmware.ExtraDeviceInfo += () =>
             * {
             * return Task.Run(async () => { return await Test.UsbDevices.GetDeviceInfoList(); }).Result;
             * };*/
        }
Exemplo n.º 5
0
        public WinForms()
        {
            InitializeComponent();

            size = Device.Info.ScaledScreenSize;
            size = Device.Info.PixelScreenSize;

            Xamarin.Forms.Platform.WinForms.Forms.UIThread = Thread.CurrentThread.ManagedThreadId;

            var scale = size.Width / size.Height; // 1.77 1.6  1.33

            if (scale < 1)
            {
                size = new Forms.Size(960, 960 * scale);
            }
            else
            {
                size = new Forms.Size(540 * scale, 540);
                if (size.Width < 960)
                {
                    size = new Forms.Size(960, 960 / scale);
                }
            }

            if (Device.RuntimePlatform == Device.macOS || Device.RuntimePlatform == Device.UWP)
            {
                size = Device.Info.PixelScreenSize;
                // scale if higher than full hd
                if (size.Width > 1920)
                {
                    size.Width  /= 2;
                    size.Height /= 2;
                }
            }

            Instance = this;
            try
            {
                MainV2.speechEngine = new Speech();
            } catch {}

            RestoreFiles();

            // init seril port type
            SerialPort.DefaultType = (self, s, i) =>
            {
                if (Device.RuntimePlatform == Device.macOS)
                {
                    Log.Info(TAG, "SerialPort.DefaultType in " + s + " " + i + " for " + Device.RuntimePlatform);
                    return(new MonoSerialPort());
                }

                return(Task.Run(async() =>
                {
                    Log.Info(TAG, "SerialPort.DefaultType in " + s + " " + i);

                    // no valid portname to start
                    if (String.IsNullOrEmpty(s))
                    {
                        Log.Info(TAG, "SerialPort.DefaultType passthrough s = null");
                        return self._baseport;
                    }
                    else
                    {
                        if (s.StartsWith("BT_"))
                        {
                            var bt = await Test.BlueToothDevice.GetDeviceInfoList();

                            var di = bt.Where(a => a.board == s);

                            if (di.Count() > 0)
                            {
                                Log.Info(TAG, "SerialPort.DefaultType found device " + di.First().board + " search " + s);
                                return await Test.BlueToothDevice.GetBT(di.First());
                            }
                        }

                        {
                            var dil = await Test.UsbDevices.GetDeviceInfoList();

                            var di = dil.Where(a => a.board == s);

                            if (di.Count() > 0)
                            {
                                Log.Info(TAG,
                                         "SerialPort.DefaultType found device " + di.First().board + " search " + s);
                                return await Test.UsbDevices.GetUSB(di.First());
                            }
                        }
                    }

                    Log.Info(TAG, "SerialPort.DefaultType passthrough no board match");
                    return self._baseport;
                }).Result);
            };

            // report back device list
            SerialPort.GetCustomPorts = () =>
            {
                var list1 = Task.Run(async() =>
                {
                    var list = await Test.BlueToothDevice.GetDeviceInfoList();
                    return(list.Select(a => a.board).ToList());
                }).Result;

                var list2 = Task.Run(async() =>
                {
                    var list = await Test.UsbDevices.GetDeviceInfoList();
                    return(list.Select(a => a.board).ToList());
                }).Result;

                list1.AddRange(list2);
                return(list1);
            };

            /*
             * // support for fw upload
             * MissionPlanner.GCSViews.ConfigurationView.ConfigFirmwareManifest.ExtraDeviceInfo += () =>
             * {
             * return Task.Run(async () => { return await Test.UsbDevices.GetDeviceInfoList(); }).Result;
             * };
             *
             * MissionPlanner.GCSViews.ConfigurationView.ConfigFirmware.ExtraDeviceInfo += () =>
             * {
             * return Task.Run(async () => { return await Test.UsbDevices.GetDeviceInfoList(); }).Result;
             * };*/
        }