Example #1
0
        public void CreateAndParse()
        {
            // declare expected values
            short        expected_color_increment = 10;
            ColorSchemes expected_color_scheme    = ColorSchemes.Rainbow;
            short        expected_pattern_delay   = 20;
            PatternModes expected_pattern_mode    = PatternModes.Rider;
            short        expected_pattern_spacing = 4;
            // create settings struct
            FirmwareSettings settings = new FirmwareSettings
            {
                ColorIncrement = expected_color_increment,
                ColorScheme    = expected_color_scheme,
                PatternDelay   = expected_pattern_delay,
                PatternMode    = expected_pattern_mode,
                PatternSpacing = expected_pattern_spacing
            };
            // create firmware command
            FirmwareCommand command = new FirmwareCommand(settings);
            // get firmware command base-64 string
            string text = command.ToString();
            // parse command from base-64 string
            FirmwareCommand parsed_command = FirmwareCommand.Parse(text);

            // make assertions
            Assert.AreEqual(expected_color_increment, parsed_command.Settings.ColorIncrement, "Color increment mismatch");
            Assert.AreEqual(expected_color_scheme, parsed_command.Settings.ColorScheme, "Color scheme mismatch");
            Assert.AreEqual(expected_pattern_delay, parsed_command.Settings.PatternDelay, "Pattern delay mismatch");
            Assert.AreEqual(expected_pattern_mode, parsed_command.Settings.PatternMode, "Pattern mode mismatch");
            Assert.AreEqual(expected_pattern_spacing, parsed_command.Settings.PatternSpacing, "Pattern spacing mismatch");
            return;
        }
Example #2
0
 private void OnAutoCheckChanged(bool newValue)
 {
     new Thread(delegate()
     {
         lock (writeLock){
             FirmwareSettings.GeneralSettings.CheckForSwUpdatesAtStartUp = newValue;
             FirmwareSettings.Save();
         }
     }).Start();
 }
Example #3
0
 public IVLConfig()
 {
     UserSettings             = new UserSettings();
     AnnotationColorSelection = new AnnotationColorSelection();
     FirmwareSettings         = new FirmwareSettings();
     PostProcessingSettings   = new PostProcessingSettings();
     CameraSettings           = new CameraSettings();
     PrinterSettings          = new PrinterSettings();
     ImageStorageSettings     = new ImageStorageSettings();
     UISettings = new UISettings();
 }
Example #4
0
 private void OnAutoConnectChanged(bool newValue)
 {
     if (!newValue && autoCheck.Checked)
     {
         autoCheck.OnEnterPressed();
     }
     new Thread(delegate()
     {
         lock (writeLock){
             FirmwareSettings.GeneralSettings.ConnectToWiFiAtStartUp = newValue;
             FirmwareSettings.Save();
         }
     }).Start();
 }
Example #5
0
 public Settings()
 {
     UserSettings             = new UserSettings();
     AnnotationColorSelection = new AnnotationColorSelection();
     FirmwareSettings         = new FirmwareSettings();
     PostProcessingSettings   = new PostProcessingSettings();
     CameraSettings           = new CameraSettings();
     PrinterSettings          = new PrinterSettings();
     ImageStorageSettings     = new ImageStorageSettings();
     UISettings          = new UISettings();
     ImageNameSettings   = new ImageNameSettings();
     EmailSettings       = new EmailSettings();
     ReportSettings      = new ReportSettings();
     PrinterPPSettings   = new PrinterPPSettings();
     MotorOffSetSettings = new AdvanceSettings.MotorOffSetSettings();
 }
 public override void RemoveFocus(IChildItem item)
 {
     base.RemoveFocus(item);
     if (item is ItemWithDialog <QuestionDialog> )
     {
         if (questionDialog.Dialog.IsPositiveSelected)
         {
             FirmwareSettings.GeneralSettings.ConnectToWiFiAtStartUp     = true;
             FirmwareSettings.GeneralSettings.CheckForSwUpdatesAtStartUp = true;
             FirmwareSettings.Save();
         }
     }
     else
     {
         if (this.Checked)
         {
             questionDialog.SetFocus(this);
         }
     }
 }
Example #7
0
        public static void Main(string[] args)
        {
            Lcd.Instance.DrawBitmap(monoLogo, new Point((int)(Lcd.Width - monoLogo.Width) / 2, 5));
            Rectangle textRect = new Rectangle(new Point(0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point(Lcd.Width, Lcd.Height - 2));

            Lcd.Instance.WriteTextBox(Font.SmallFont, textRect, "Initializing...", true, Lcd.Alignment.Center);
            Lcd.Instance.Update();
            WiFiDevice.TurnOff();
            if (!Directory.Exists(ProgramPathSdCard))
            {
                Directory.CreateDirectory(ProgramPathSdCard);
            }

            // JIT work-around remove when JIT problem is fixed
            System.Threading.Thread.Sleep(10);
            Console.WriteLine("JIT workaround - please remove!!!");
            Lcd.Instance.WriteTextBox(Font.SmallFont, textRect, "Checking WiFi...", true, Lcd.Alignment.Center);
            Lcd.Instance.Update();
            //WiFiDevice.IsLinkUp ();
            Lcd.Instance.WriteTextBox(Font.SmallFont, textRect, "Starting Mono Runtime...", true, Lcd.Alignment.Center);
            Lcd.Instance.Update();
            string monoVersion = "Unknown";
            Type   type        = Type.GetType("Mono.Runtime");

            if (type != null)
            {
                MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
                if (displayName != null)
                {
                    monoVersion = (string)displayName.Invoke(null, null);
                }
                Console.WriteLine("Mono Version" + monoVersion);
            }
            string monoCLR = System.Reflection.Assembly.GetExecutingAssembly().ImageRuntimeVersion;

            // JIT work-around end but look for more below

            //Load settings
            Lcd.Instance.WriteTextBox(Font.SmallFont, textRect, "Loading settings...", true, Lcd.Alignment.Center);
            Lcd.Instance.Update();
            settings = settings.Load();
            if (settings != null)
            {
                Lcd.Instance.WriteTextBox(Font.SmallFont, textRect, "Applying settings...", true, Lcd.Alignment.Center);
                Lcd.Instance.Update();
                settings.Save();                // JIT work-around
                WriteWpaSupplicantConfiguration(settings.WiFiSettings.SSID, settings.WiFiSettings.Password, settings.WiFiSettings.Encryption);
                if (settings.WiFiSettings.ConnectAtStartUp)
                {
                    Lcd.Instance.WriteTextBox(Font.SmallFont, textRect, "Connecting to WiFi...", true, Lcd.Alignment.Center);
                    Lcd.Instance.Update();
                    if (WiFiDevice.TurnOn(60000))
                    {
                        WiFiDevice.GetIpAddress();                         // JIT work-around
                        if (settings.GeneralSettings.CheckForSwUpdatesAtStartUp)
                        {
                            ShowUpdatesDialogs();
                        }
                        else
                        {
                            var dialog = new InfoDialog("Connected Successfully " + WiFiDevice.GetIpAddress(), true);
                            dialog.Show();
                        }
                    }
                    else
                    {
                        var dialog = new InfoDialog("Failed to connect to WiFI Network", true);
                        dialog.Show();
                    }
                }
            }
            else
            {
                var dialog = new InfoDialog("Failed to load settings", true);
                dialog.Show();
                settings = new FirmwareSettings();
            }

            //Keep showing the menu even if user press esc
            while (true)
            {
                ShowMainMenu();
            }
        }
Example #8
0
 public ApplicationConfiguration()
 {
     FirmwareSettings = new FirmwareSettings();
     RedirectIP       = "192.168.178.20";
 }
Example #9
0
 public abstract bool Init(LoadFlags loadFlags, ref LoadData loadData, ref FirmwareSettings fwSettings);
Example #10
0
        public static void Main(string[] args)
        {
            if (!File.Exists(SuspendFile))
            {
                File.Create(SuspendFile);
            }
            FileSystemWatcher watcher = new FileSystemWatcher();

            watcher.Path                = Path.GetDirectoryName(SuspendFile);
            watcher.NotifyFilter        = NotifyFilters.LastWrite;
            watcher.Filter              = Path.GetFileName(SuspendFile);
            watcher.Changed            += OnSuspendFileChanged;
            watcher.EnableRaisingEvents = true;

            Menu menu = new Menu("Main Menu");

            menu.AddItem(new ItemWithProgramList("Programs", false));
            menu.AddItem(new ItemWiFiOptions());
            menu.AddItem(new ItemWithSettings());
            menu.AddItem(new ItemWithUpdateDialog());
            //menu.AddItem(new ItemWithWebserver ());
            menu.AddItem(new ItemWithBrickInfo());
            menu.AddItem(new ItemWithTurnOff());

            container = new FirmwareMenuContainer(menu);

            Bitmap monoLogo = Bitmap.FromResouce(Assembly.GetExecutingAssembly(), "monologo.bitmap");

            Lcd.DrawBitmap(monoLogo, new Point((int)(Lcd.Width - monoLogo.Width) / 2, 5));
            Rectangle textRect = new Rectangle(new Point(0, Lcd.Height - (int)Font.SmallFont.maxHeight - 2), new Point(Lcd.Width, Lcd.Height - 2));

            Lcd.WriteTextBox(Font.SmallFont, textRect, "Initializing...", true, Lcd.Alignment.Center);
            Lcd.Update();
            WiFiDevice.TurnOff();
            ProgramManager.CreateSDCardFolder();
            Lcd.WriteTextBox(Font.SmallFont, textRect, "Loading settings...", true, Lcd.Alignment.Center);
            Lcd.Update();
            FirmwareSettings.Load();
            Lcd.WriteTextBox(Font.SmallFont, textRect, "Applying settings...", true, Lcd.Alignment.Center);
            Lcd.Update();
            if (FirmwareSettings.GeneralSettings.ConnectToWiFiAtStartUp)
            {
                Lcd.WriteTextBox(Font.SmallFont, textRect, "Connecting to WiFi...", true, Lcd.Alignment.Center);
                Lcd.Update();
                if (WiFiDevice.TurnOn(FirmwareSettings.WiFiSettings.SSID, FirmwareSettings.WiFiSettings.Password, FirmwareSettings.WiFiSettings.Encryption, 40000))
                {
                    if (FirmwareSettings.GeneralSettings.CheckForSwUpdatesAtStartUp)
                    {
                        container.Show(3);                          //show the menu container with the update dialog
                        return;
                    }
                    else
                    {
                        var dialog = new InfoDialog("Connected Successfully " + WiFiDevice.GetIpAddress());
                        dialog.Show();
                    }
                }
                else
                {
                    var dialog = new InfoDialog("Failed to connect to WiFI Network");
                    dialog.Show();
                }
            }
            container.Show();
        }
Example #11
0
 public abstract bool Init(LoadFlags flags, FirmwareSettings fwSettings);
 private void UpdateSelectedValues()
 {
     this.Settings = this.device?.Settings ?? new FirmwareSettings();
     return;
 }
 private void OnEncryptionOptionChanged(string option)
 {
     FirmwareSettings.WiFiSettings.Encryption = option != "None";
     FirmwareSettings.Save();
 }
 private void OnPasswordChanged(string password)
 {
     FirmwareSettings.WiFiSettings.Password = password;
     FirmwareSettings.Save();
 }
 private void OnSsidChanged(string ssidName)
 {
     FirmwareSettings.WiFiSettings.SSID = ssidName;
     FirmwareSettings.Save();
 }