Exemple #1
0
        static async Task Main(string[] args)
        {
            // Standard .NET Core Host
            var hostBuilder = new HostBuilder();

            hostBuilder.ConfigureLogging(_ =>
            {
                _.AddConsole();
            });
            hostBuilder.UseEnvironment("Development");
            var host          = hostBuilder.Build();
            var loggerFactory = host.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;

            // Boot Dolittle
            var result = Bootloader.Configure(_ =>
            {
                _.UseLoggerFactory(loggerFactory);
                _.Development();
            }).Start();

            // Get our IFoo service
            var foo = result.Container.Get <IFoo>();

            await host.RunAsync();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Interpreter.Init(registers: 32);

            var mini = Interpreter.Instance;

            StandardAPI.output = Console.WriteLine; // change output method
            StandardAPI.input  = Console.ReadLine;  // change input method

            Bootloader.CreateReference();
            FileAPI.CreateReference();
            StandardAPI.Load(mini);

            while (mini.Ready)
            {
                if (mini.IsLabelDefinition)
                {
                    Console.Write(">> ");
                }
                else
                {
                    Console.Write("\n> ");
                }

                mini.Run(Console.ReadLine());
                mini.ResetLineNum();
            }

            Console.WriteLine("bye");
        }
Exemple #3
0
        public void containerTest1()
        {
            IBootloader loader = new Bootloader();

            var ml1 = new MListener1();
            var ml2 = new MListener2()
            {
                Activated = true
            };

            loader.Filters.register(ml1);
            loader.Filters.register(ml2);

            Assert.AreEqual(2, loader.Filters.Count);
            Assert.AreEqual(1, loader.ActivatedFilters.Count());

            var enumerator = loader.ActivatedFilters.GetEnumerator();

            Assert.AreEqual(true, enumerator.MoveNext());
            Assert.AreEqual(ml2.Id, enumerator.Current.Id);

            loader.unregister();
            Assert.AreEqual(0, loader.Filters.Count);
            Assert.AreEqual(0, loader.ActivatedFilters.Count());
        }
Exemple #4
0
        public NVForm()
        {
            InitializeComponent();

            usbController         = new UsbController();
            usbController.Notify += HandleDevices;
            usbController.StartWorker();

            bootloaders = Bootloader.GetBootloaders();

            foreach (var bl in bootloaders)
            {
                deviceBootloader.Items.Add(bl.Title);
            }

            if (bootloaders.Length > 0)
            {
                deviceBootloader.SelectedIndex = 0;
            }

            var random = new Random(Guid.NewGuid().GetHashCode());

            nvUnlockCode.Text = new string(Enumerable.Repeat("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 16)
                                           .Select(s => s[random.Next(s.Length)]).ToArray());
        }
Exemple #5
0
        public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
        {
            try
            {
                var serialDate = GetSerialDate(serial_number);
                switch (eeprom[printerProfile.EEPROMConstants.GetEepromInfo("FANTYPE").EepromAddr])
                {
                case 0:
                case byte.MaxValue:
                    FanConstValues.FanType index = FanConstValues.FanType.HengLiXin;
                    if (serialDate >= 150602)
                    {
                        index = FanConstValues.FanType.Shenzhew;
                    }

                    FanConstValues.FanValues fanConstant = FanConstValues.FanConstants[index];
                    var num    = (byte)index;
                    var offset = fanConstant.Offset;
                    var scale  = fanConstant.Scale;
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANTYPE").EepromAddr, BitConverter.GetBytes(num));
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANOFFSET").EepromAddr, BitConverter.GetBytes(offset));
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANSCALE").EepromAddr, BitConverter.GetBytes(scale));
                    break;
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogErrorMsg("Exception in FirstrunUpdateDefaulFan.CheckForUpdate " + ex.Message, "Exception");
                return(false);
            }
            return(true);
        }
Exemple #6
0
        public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
        {
            try
            {
                var str        = serial_number.Substring(0, 13);
                var eepromAddr = (int)printerProfile.EEPROMConstants.GetEepromInfo("ExtruderCurrent").EepromAddr;
                if (!(str == "BK15033001100") && !(str == "BK15040201050") && (!(str == "BK15040301050") && !(str == "BK15040602050")) && (!(str == "BK15040801050") && !(str == "BK15040802100") && (!(str == "GR15032702100") && !(str == "GR15033101100"))) && (!(str == "GR15040601100") && !(str == "GR15040701100") && !(str == "OR15032701100")))
                {
                    if (!(str == "SL15032601050"))
                    {
                        goto label_7;
                    }
                }
                if (BitConverter.ToUInt16(eeprom, eepromAddr) != 500)
                {
                    ushort num = 500;
                    bootloader_conn.WriteToEEPROM((ushort)eepromAddr, BitConverter.GetBytes(num));
                    eeprom = bootloader_conn.ReadAllReadableEEPROM();
                    return(BitConverter.ToUInt16(eeprom, eepromAddr) == 500);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogErrorMsg("Exception in FirstRunUpdateSetBatchto500ma.CheckForUpdate " + ex.Message, "Exception");
                return(false);
            }
label_7:
            return(true);
        }
        /// <param name="loader"></param>
        /// <param name="pin"></param>
        public VersionFrm(Bootloader loader, ITransfer pin)
        {
            manager = new Manager(loader.Env);
            _pin    = pin;

            InitializeComponent();
            Icon = Resource.Package_32;

            editorStepGen._.WordWrap   = false;
            editorStepGen._.IsReadOnly = true;
            editorStepGen._.FontSize   = 9.25f;
            editorStepGen.setBackgroundFromString("#F4F4F4");

            editorFinalScript.colorize(TextEditor.ColorSchema.SBEScripts);
            editorFinalScript.codeCompletionInit(new Inspector(loader.Soba), loader.Soba.EvMSBuild);
            editorFinalScript.CodeCompletionEnabled = true;
            editorFinalScript._.WordWrap            = false;

            tabControlMain.Top     = -22;
            tabControlMain.Height += 22;
            tcRevNumber.SizeMode   = TabSizeMode.Fixed;
            tcReplType.SizeMode    = TabSizeMode.Fixed;
            btnPrevStep.Visible    = false;

            string spath = loader.Env.SolutionPath ?? Settings.WPath;

            ftbInputNum.Dialog.InitialDirectory                 = ftbOutputFile.Dialog.InitialDirectory
                                                                = ftbReplFile.Dialog.InitialDirectory
                                                                = spath.DirectoryPathFormat();
        }
Exemple #8
0
 private void StartBootloaderMode()
 {
     m_oBootloaderConnection = new Bootloader(SerialPort, MyPrinterProfile.ProductConstants.m_yPaddingByte, MyPrinterProfile.ProductConstants.chipData, MyPrinterProfile.EEPROMConstants.EndOfBootloaderReadableEEPROM, MyPrinterProfile.EEPROMConstants.BytesPerEEPROMAddress);
     CurrentBootloaderStep   = BootloaderController.BootLoaderStep.Startup;
     Status = PrinterStatus.Bootloader_StartingUp;
     m_oBootloaderConnection.FlushIncomingBytes();
 }
Exemple #9
0
        internal static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadException += (sender, e) => Fail(e.Exception);

            try
            {
                var evl = new API.EventLevel();
                evl.load(GetSln(args), new Dictionary <string, string>());

                var pUnkReserved = new object();
                evl.solutionOpened(pUnkReserved, 0);
                {
                    Application.Run(new EventsFrm(Bootloader.Init(evl.Environment)));
                }
                evl.solutionClosed(pUnkReserved);
            }
            catch (Exception ex)
            {
                Fail(ex);
            }
        }
Exemple #10
0
        static async Task Main()
        {
            var hostBuilder = new HostBuilder();

            hostBuilder.ConfigureLogging(_ => _.AddConsole());
            hostBuilder.UseEnvironment("Development");
            var host          = hostBuilder.Build();
            var loggerFactory = host.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;

            var result = Bootloader.Configure(_ =>
            {
                _.UseLoggerFactory(loggerFactory);
                _.Development();
            }).Start();

            var logger = result.Container.Get <Dolittle.Logging.ILogger>();

            logger.Information("Booted");

            // await HeadConnectionLifecycle.Connected.ConfigureAwait(false);
            var commandContextManager   = result.Container.Get <ICommandContextManager>();
            var executionContextManager = result.Container.Get <IExecutionContextManager>();
            var commandCoordinator      = result.Container.Get <ICommandCoordinator>();

            executionContextManager.CurrentFor(TenantId.Development);

            logger.Information("Handle command");

            var commandResult = commandCoordinator.Handle(new MyCommand());

            logger.Information("Success : {Result}", commandResult.Success);

            await host.RunAsync().ConfigureAwait(false);
        }
Exemple #11
0
        static void Main(string[] args)
        {
            var before = DateTime.Now;

            Console.WriteLine("Start Dolittle");

            var bootResult = Bootloader.Configure(_ => _
                                                  .WithEntryAssembly(typeof(Program).Assembly)
                                                  .WithAssembliesSpecifiedIn(typeof(Program).Assembly)
                                                  .SynchronousScheduling()
                                                  .NoLogging()
                                                  //.UseLogAppender(new CustomLogAppender())
                                                  ).Start();

            var container = bootResult.Container;
            var logger    = container.Get <ILogger>();
            var after     = DateTime.Now;
            var delta     = after.Subtract(before);

            Console.WriteLine($"We're running - took {delta.TotalSeconds}");

            var executionContextManager = container.Get <IExecutionContextManager>();

            executionContextManager.CurrentFor(TenantId.Development);

            var interop = container.Get <IJSRuntime>();

            interop.Invoke("window._dolittleLoaded");
        }
Exemple #12
0
        static async Task Main()
        {
            var hostBuilder = new HostBuilder();

            hostBuilder.ConfigureLogging(_ => _.AddConsole());
            hostBuilder.UseEnvironment("Development");
            var host          = hostBuilder.Build();
            var loggerFactory = host.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;

            var result = Bootloader.Configure(_ =>
            {
                _.UseLoggerFactory(loggerFactory);
                _.Development();
            }).Start();
            var consumerClient              = result.Container.Get <IConsumerClient>();
            var microservices               = result.Container.Get <IMicroservices>();
            var executionContextManager     = result.Container.Get <IExecutionContextManager>();
            var boundedContextConfiguration = result.Container.Get <BoundedContextConfiguration>();

            executionContextManager.CurrentFor(boundedContextConfiguration.Application, boundedContextConfiguration.BoundedContext, TenantId.Development);
            var eventHorizon = new EventHorizon.EventHorizon(
                executionContextManager.Current.Microservice,
                executionContextManager.Current.Tenant,
                Guid.Parse("4e146c23-3b32-4eae-90bd-068f37844dc0"),
                TenantId.Development);
            var microserviceAddress = microservices.GetAddressFor(eventHorizon.ProducerMicroservice);

            _ = consumerClient.SubscribeTo(eventHorizon, Guid.Parse("8a37fe70-654e-4e47-91e6-0c9103bd0519"), Guid.Parse("db7acf1e-a640-41f3-934f-f2f188e1b1e9"), Guid.Empty, microserviceAddress);
            await host.RunAsync().ConfigureAwait(false);
        }
        public Events(Bootloader loader, IInspector inspector = null)
        {
            Loader         = loader;
            this.inspector = inspector;
            Env            = loader.Env;

            backupUpdate();
        }
Exemple #14
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var boot = new Bootloader();

            boot.Container.ExportAssembly(Assembly.GetAssembly(typeof(EventHandlerServiceWpf)));

            boot.Boot();
        }
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var boot = new Bootloader();

            boot.Container.ExportInitialize <OptionsServicesWpf>((c, a, o) => o.SetRegistryPath("CHMP"));
            NotifyHelper.EventHandlerService = new EventHandlerServiceWpf(); // boot.Container.Locate<IEventHandlerService>();
            //boot.Container.ExportInitialize<BootLoaderErpWpf>((c, a, o) => o.SetMainViewMode(typeof(ViewModeKiosk)));

            boot.Boot();
        }
Exemple #16
0
        static void SetupHost()
        {
            var loggerFactory = new LoggerFactory(new ILoggerProvider[]
            {
                new NullLoggerProvider()
            });

            _bootLoaderResult = Bootloader.Configure(_ => _
                                                     .UseLoggerFactory(loggerFactory)
                                                     .UseLogAppender(new NullLogAppender())
                                                     .SkipBootprocedures()
                                                     ).Start();
        }
Exemple #17
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="Initializer" /> class.
        /// </summary>
        public Initializer()
        {
            StaticObjects.ProjectLogger.WriteLog("Loading...");
            if (!Bootloader.ChampionBundled.ContainsKey(StaticObjects.Player.ChampionName))
            {
                return;
            }
            if (!Bootloader.ChampionBundled[StaticObjects.Player.ChampionName])
            {
                return;
            }

            StaticObjects.ProjectLogger.WriteLog("Load Delays...");
            Handler.Load(true);
            // ReSharper disable once UnusedVariable
            var initializerMenu = new SettingsMenuGenerater();

            StaticObjects.SettingsMenu.AddToMainMenu();

            var championSettings = new Settings();

            if (!StaticObjects.SettingsMenu.Item($"{Names.Menu.BaseItem}{StaticObjects.Player.ChampionName}.Enable").GetValue <bool>())
            {
                return;
            }

            var coreMenu = new Menu("Core Modules", "CoreModulesMenu");

            var drawingEnabled   = StaticObjects.SettingsMenu.Item($"{Names.Menu.BaseItem}{StaticObjects.Player.ChampionName}.DrawingMenu").GetValue <bool>();
            var manaEnabled      = StaticObjects.SettingsMenu.Item($"{Names.Menu.BaseItem}{StaticObjects.Player.ChampionName}.ManaMenu").GetValue <bool>();
            var itemEnabled      = StaticObjects.SettingsMenu.Item($"{Names.Menu.BaseItem}{StaticObjects.Player.ChampionName}.ItemMenu").GetValue <bool>();
            var autoLevelEnabled = StaticObjects.SettingsMenu.Item($"{Names.Menu.BaseItem}{StaticObjects.Player.ChampionName}.OnLevelMenu").GetValue <bool>();
            var trinketEnabled   = StaticObjects.SettingsMenu.Item($"{Names.Menu.BaseItem}{StaticObjects.Player.ChampionName}.TrinketMenu").GetValue <bool>();

            StaticObjects.ProjectLogger.WriteLog("Load Base Menu's...");
            var orbWalker = new Orbwalking.Orbwalker(StaticObjects.ProjectMenu.SubMenu(nameof(Orbwalking.Orbwalker)));
            // ReSharper disable once UnusedVariable
            var manaMenu = new ManaMenu(coreMenu, championSettings.ManaSettings, manaEnabled);
            // ReSharper disable once UnusedVariable
            var drawingMeun = new Module.Core.Drawing.Menus.Drawing(coreMenu, championSettings.DrawingSettings, drawingEnabled);
            // ReSharper disable once UnusedVariable
            var itemMenu = new Item(coreMenu, itemEnabled, orbWalker);
            // ReSharper disable once UnusedVariable
            var autoLevelMenu = new Abilities(coreMenu, championSettings.AbilitieSettings, autoLevelEnabled);
            // ReSharper disable once UnusedVariable
            var trinketMenu = new Trinket(coreMenu, trinketEnabled);

            StaticObjects.ProjectMenu.AddSubMenu(coreMenu);
            StaticObjects.ProjectMenu.AddToMainMenu();
            Bootloader.Load(manaEnabled, orbWalker);
        }
 public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
 {
     try
     {
         var uint32      = (int)BitConverter.ToUInt32(eeprom, printerProfile.EEPROMConstants.GetEepromInfo("FirmwareVersion").EepromAddr);
         var eepromAddr1 = (int)printerProfile.EEPROMConstants.GetEepromInfo("ZCalibrationBLO").EepromAddr;
         var eepromAddr2 = (int)printerProfile.EEPROMConstants.GetEepromInfo("ZCalibrationBRO").EepromAddr;
         var eepromAddr3 = (int)printerProfile.EEPROMConstants.GetEepromInfo("ZCalibrationFLO").EepromAddr;
         var eepromAddr4 = (int)printerProfile.EEPROMConstants.GetEepromInfo("ZCalibrationFRO").EepromAddr;
         var eepromAddr5 = (int)printerProfile.EEPROMConstants.GetEepromInfo("ZCalibrationZO").EepromAddr;
         var single1     = BitConverter.ToSingle(eeprom, eepromAddr1);
         var single2     = BitConverter.ToSingle(eeprom, eepromAddr2);
         var single3     = BitConverter.ToSingle(eeprom, eepromAddr3);
         var single4     = BitConverter.ToSingle(eeprom, eepromAddr4);
         var single5     = BitConverter.ToSingle(eeprom, eepromAddr5);
         var num1        = 0.0f;
         var num2        = 2015080402;
         if ((uint)uint32 < (uint)num2)
         {
             if (Math.Abs(single1) > 1.40129846432482E-45 || Math.Abs(single2) > 1.40129846432482E-45 || (Math.Abs(single3) > 1.40129846432482E-45 || Math.Abs(single4) > 1.40129846432482E-45) || Math.Abs(single5) > 1.40129846432482E-45)
             {
                 try
                 {
                     StreamWriter text = File.CreateText(Path.Combine(Paths.SpoolerFolder, "user_offsets-" + serial_number + ".txt"));
                     text.WriteLine("Old Bed level offsets");
                     text.WriteLine("  Back Left: " + single1.ToString("0.###"));
                     text.WriteLine("  Back Right: " + single2.ToString("0.###"));
                     text.WriteLine("  Front Left: " + single3.ToString("0.###"));
                     text.WriteLine("  Front Right: " + single4.ToString("0.###"));
                     text.WriteLine("  Z: " + single5.ToString("0.###"));
                     text.Close();
                 }
                 catch (Exception ex)
                 {
                     ErrorLogger.LogErrorMsg("Exception in FirstRunUpdateResetOffsets.CheckForUpdate " + ex.Message, "Exception");
                 }
             }
             bootloader_conn.WriteToEEPROM((ushort)eepromAddr1, BitConverter.GetBytes(num1));
             bootloader_conn.WriteToEEPROM((ushort)eepromAddr2, BitConverter.GetBytes(num1));
             bootloader_conn.WriteToEEPROM((ushort)eepromAddr3, BitConverter.GetBytes(num1));
             bootloader_conn.WriteToEEPROM((ushort)eepromAddr4, BitConverter.GetBytes(num1));
             bootloader_conn.WriteToEEPROM((ushort)eepromAddr5, BitConverter.GetBytes(num1));
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogErrorMsg("Exception in FirstRunUpdateResetOffsets.CheckForUpdate " + ex.Message, "Exception");
         return(false);
     }
     return(true);
 }
Exemple #19
0
        public static void Main(string[] args)
        {
            Interpreter.Init(registers: 32);

            var mini = Interpreter.Instance;

            Bootloader.CreateReference();
            StandardAPI.Load(mini);

            while (mini.Ready)
            {
                Console.Write("> ")
                gelii.Run(Console.ReadLine());
            }
        }
Exemple #20
0
        public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
        {
            try
            {
                var num  = eeprom[printerProfile.EEPROMConstants.GetEepromInfo("FANTYPE").EepromAddr];
                var flag = false;
                FanConstValues.FanType   index;
                FanConstValues.FanValues fanConstant;
                if (Enum.IsDefined(typeof(FanConstValues.FanType), (int)num))
                {
                    index       = (FanConstValues.FanType)num;
                    fanConstant = FanConstValues.FanConstants[index];
                }
                else
                {
                    index       = FanConstValues.FanType.None;
                    fanConstant = FanConstValues.FanConstants[FanConstValues.FanType.HengLiXin];
                }
                var fanValues = new FanConstValues.FanValues
                {
                    Scale  = BitConverter.ToSingle(eeprom, printerProfile.EEPROMConstants.GetEepromInfo("FANSCALE").EepromAddr),
                    Offset = eeprom[(int)printerProfile.EEPROMConstants.GetEepromInfo("FANOFFSET").EepromAddr]
                };
                if (Math.Abs(fanValues.Offset - fanConstant.Offset) >= 1)
                {
                    flag = true;
                }

                if (Math.Abs(fanValues.Scale - fanConstant.Scale) >= 1.40129846432482E-45)
                {
                    flag = true;
                }

                if (flag)
                {
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANTYPE").EepromAddr, BitConverter.GetBytes((byte)index));
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANOFFSET").EepromAddr, BitConverter.GetBytes((byte)fanConstant.Offset));
                    bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("FANSCALE").EepromAddr, BitConverter.GetBytes(fanConstant.Scale));
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.LogErrorMsg("Exception in FirstRunUpdateFanValues.CheckForUpdate " + ex.Message, "Exception");
                return(false);
            }
            return(true);
        }
Exemple #21
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (Bootloader.Length != 0)
            {
                hash ^= Bootloader.GetHashCode();
            }
            if (ProcVersion.Length != 0)
            {
                hash ^= ProcVersion.GetHashCode();
            }
            if (CodeName.Length != 0)
            {
                hash ^= CodeName.GetHashCode();
            }
            if (Incremental.Length != 0)
            {
                hash ^= Incremental.GetHashCode();
            }
            if (Fingerprint.Length != 0)
            {
                hash ^= Fingerprint.GetHashCode();
            }
            if (BootID.Length != 0)
            {
                hash ^= BootID.GetHashCode();
            }
            if (AndroidID.Length != 0)
            {
                hash ^= AndroidID.GetHashCode();
            }
            if (BaseBand.Length != 0)
            {
                hash ^= BaseBand.GetHashCode();
            }
            if (InnerVersion.Length != 0)
            {
                hash ^= InnerVersion.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemple #22
0
        private void FlashBootloader(Bootloader bootloader, string port)
        {
            var flasher = new ImageFlasher();

            Log.Info("Verifying images...");

            int asize = 0, dsize = 0;

            foreach (var image in bootloader.Images)
            {
                Log.Debug($"VrStat of {image.Role}: {image.IsValid}");

                if (!image.IsValid)
                {
                    throw new Exception($"Image `{image.Role}` is invalid!");
                }

                asize += image.Size;
            }

            Log.Success("Verification passed!");
            Log.Debug($"Opening {port}...");

            flasher.Open(port);

            Log.Info($"Uploading {bootloader.Name} bootloader");

            foreach (var image in bootloader.Images)
            {
                var size = image.Size;

                Log.Info($"- {image.Role}");

                flasher.Write(image.Path, (int)image.Address, x => {
                    Log.SetProgressBar(dsize + (int)(size / 100f * x), asize);
                });

                dsize += size;
            }

            flasher.Close();

            Log.Success("Bootloader uploaded");
            Log.SetProgressBar(false);
        }
Exemple #23
0
        static async Task Main()
        {
            var hostBuilder = new HostBuilder();

            hostBuilder.ConfigureLogging(_ => _.AddConsole());
            hostBuilder.UseEnvironment("Development");

            var host          = hostBuilder.Build();
            var loggerFactory = host.Services.GetService(typeof(ILoggerFactory)) as ILoggerFactory;

            var result = Bootloader.Configure(_ =>
            {
                _.UseLoggerFactory(loggerFactory);
                _.Development();
            }).Start();
            var logger = result.Container.Get <Dolittle.Logging.ILogger>();

            var client   = result.Container.Get <TestServiceClient>();
            var response = await client.SayHelloToAsync(new Request { Name = "Yoda" });

            logger.Information($"Response was : {response.Message}");

            var counter = 0;
            var stream  = client.SayHelloToStream()
                          var timer = new System.Timers.Timer(1000);

            timer.Elapsed += (s, e) => stream.RequestStream.WriteAsync(new Request {
                Name = $"R2-D{counter++}"
            });
            timer.Start();

            var task = Task.Run(async() =>
            {
                while (await stream.ResponseStream.MoveNext(CancellationToken.None).ConfigureAwait(false))
                {
                    logger.Information($"Response : {stream.ResponseStream.Current.Message}");
                }
            });

            await host.RunAsync().ConfigureAwait(false);

            timer.Dispose();

            loggerFactory.Dispose();
        }
        public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
        {
            try
            {
                var eepromAddr1 = (int)printerProfile.EEPROMConstants.GetEepromInfo("SpeedLimitX").EepromAddr;
                var eepromAddr2 = (int)printerProfile.EEPROMConstants.GetEepromInfo("SpeedLimitY").EepromAddr;
                var eepromAddr3 = (int)printerProfile.EEPROMConstants.GetEepromInfo("SpeedLimitZ").EepromAddr;
                var eepromAddr4 = (int)printerProfile.EEPROMConstants.GetEepromInfo("SpeedLimitEp").EepromAddr;
                var eepromAddr5 = (int)printerProfile.EEPROMConstants.GetEepromInfo("SpeedLimitEn").EepromAddr;
                var single1     = BitConverter.ToSingle(eeprom, eepromAddr1);
                var single2     = BitConverter.ToSingle(eeprom, eepromAddr2);
                var single3     = BitConverter.ToSingle(eeprom, eepromAddr3);
                var single4     = BitConverter.ToSingle(eeprom, eepromAddr4);
                var single5     = BitConverter.ToSingle(eeprom, eepromAddr5);
                if (IsNotValid(single1, printerProfile.SpeedLimitConstants.MIN_FEEDRATE_X, printerProfile.SpeedLimitConstants.MAX_FEEDRATE_X))
                {
                    bootloader_conn.WriteToEEPROM((ushort)eepromAddr1, BitConverter.GetBytes(printerProfile.SpeedLimitConstants.DEFAULT_FEEDRATE_X));
                }

                if (IsNotValid(single2, printerProfile.SpeedLimitConstants.MIN_FEEDRATE_Y, printerProfile.SpeedLimitConstants.MAX_FEEDRATE_Y))
                {
                    bootloader_conn.WriteToEEPROM((ushort)eepromAddr2, BitConverter.GetBytes(printerProfile.SpeedLimitConstants.DEFAULT_FEEDRATE_Y));
                }

                if (IsNotValid(single3, printerProfile.SpeedLimitConstants.MIN_FEEDRATE_Z, printerProfile.SpeedLimitConstants.MAX_FEEDRATE_Z))
                {
                    bootloader_conn.WriteToEEPROM((ushort)eepromAddr3, BitConverter.GetBytes(printerProfile.SpeedLimitConstants.DEFAULT_FEEDRATE_Z));
                }

                if (IsNotValid(single4, printerProfile.SpeedLimitConstants.MIN_FEEDRATE_E_Positive, printerProfile.SpeedLimitConstants.MAX_FEEDRATE_E_Positive))
                {
                    bootloader_conn.WriteToEEPROM((ushort)eepromAddr4, BitConverter.GetBytes(printerProfile.SpeedLimitConstants.DEFAULT_FEEDRATE_E_Positive));
                }

                if (IsNotValid(single5, printerProfile.SpeedLimitConstants.MIN_FEEDRATE_E_Negative, printerProfile.SpeedLimitConstants.MAX_FEEDRATE_E_Negative))
                {
                    bootloader_conn.WriteToEEPROM((ushort)eepromAddr5, BitConverter.GetBytes(printerProfile.SpeedLimitConstants.DEFAULT_FEEDRATE_E_Negative));
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Exemple #25
0
        static void Main()
        {
            var loggerFactory = new LoggerFactory();

            loggerFactory.AddConsole();

            var bootloader = Bootloader.Configure(_ => _
                                                  .UseLoggerFactory(loggerFactory)
                                                  .Development()
                                                  .IncludeAssembliesStartingWith("Microsoft"));

            var result = bootloader.Start();
            var logger = result.Container.Get <ILogger>();

            result.Assemblies.GetAll().ForEach(_ => logger.Information($"Assembly '{_}' loaded and part of discovery"));

            loggerFactory.Dispose();
        }
Exemple #26
0
        /// <summary>
        /// Adds Dolittle services
        /// </summary>
        /// <returns></returns>
        public static BootloaderResult AddDolittle(this IServiceCollection services, Action <IBootBuilder> builderDelegate)
        {
            var bootloader = Bootloader.Configure(_ => {
                if (EnvironmentUtilities.GetExecutionEnvironment() == Dolittle.Execution.Environment.Development)
                {
                    _ = _.Development();
                }
                _.SkipBootprocedures()
                .UseContainer <Container>();
                builderDelegate(_);
            });

            var bootloaderResult = bootloader.Start();

            AddMvcOptions(services, bootloaderResult.TypeFinder);

            return(bootloaderResult);
        }
 public override bool CheckForUpdate(string serial_number, byte[] eeprom, Bootloader bootloader_conn, InternalPrinterProfile printerProfile)
 {
     try
     {
         var uint32 = (int)BitConverter.ToUInt32(eeprom, printerProfile.EEPROMConstants.GetEepromInfo("FirmwareVersion").EepromAddr);
         var num1   = 1500f;
         var num2   = 2015080402;
         if ((uint)uint32 < (uint)num2)
         {
             bootloader_conn.WriteToEEPROM(printerProfile.EEPROMConstants.GetEepromInfo("BacklashSpeed").EepromAddr, BitConverter.GetBytes(num1));
         }
     }
     catch (Exception ex)
     {
         ErrorLogger.LogErrorMsg("Exception in FirstRunUpdateSetBacklash1500.CheckForUpdate " + ex.Message, "Exception");
         return(false);
     }
     return(true);
 }
Exemple #28
0
        static void Main(string[] args)
        {
            var before = DateTime.Now;

            var bootResult = Bootloader.Configure(_ => _
                                                  .WithEntryAssembly(typeof(Program).Assembly)
                                                  .WithAssembliesSpecifiedIn(typeof(Program).Assembly)
                                                  .SynchronousScheduling()
                                                  .UseLogAppender(new CustomLogAppender())
                                                  ).Start();

            var container = bootResult.Container;
            var logger    = container.Get <ILogger>();

            logger.Information("We're running");

            //SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_WebAssembly());

            //SampleClass.Run().Wait();
        }
Exemple #29
0
        public NVForm()
        {
            InitializeComponent();

            usbController         = new UsbController();
            usbController.Notify += HandleDevices;
            usbController.StartWorker();

            bootloaders = Bootloader.GetBootloaders();

            foreach (var bl in bootloaders)
            {
                deviceBootloader.Items.Add(bl.Title);
            }

            if (bootloaders.Length > 0)
            {
                deviceBootloader.SelectedIndex = 0;
            }
        }
        /// <inheritdoc/>
        public ContainerBuilder CreateBuilder(IServiceCollection services)
        {
            ApplyLoggerFactoryWorkarounds(services);

            var builder = _autofacFactory.CreateBuilder(services);

            var bootResult = Bootloader.Configure(_ =>
            {
                if (_context.HostingEnvironment.IsDevelopment())
                {
                    _.Development();
                }
                _.SkipBootprocedures();
                _.UseContainer <ServiceProviderContainer>();
            }).Start();

            builder.AddDolittle(bootResult.Assemblies, bootResult.Bindings);

            return(builder);
        }