Ejemplo n.º 1
0
        protected override async Task Handle(MigoEndpoint endpoint)
        {
            var logger = Program.LoggerFactory.CreateLogger <SetTemperatureCommand>();

            var bedTemperature = CurrentParseResult.CommandResult
                                 .OptionResult(BedOption)?
                                 .GetValueOrDefault <double>();

            var nozzleTemperature = CurrentParseResult.CommandResult
                                    .OptionResult(NozzleOption)?
                                    .GetValueOrDefault <double>();

            var migo = MigoFactory.Create(endpoint);

            if (bedTemperature.HasValue)
            {
                logger.LogInformation($"Heating bed to {bedTemperature.Value}...");
                await SetBedTemperature(migo, bedTemperature.Value).ConfigureAwait(false);
            }

            if (nozzleTemperature.HasValue)
            {
                logger.LogInformation($"Heating nozzle to {nozzleTemperature.Value}...");
                await SetNozzleTemperature(migo, nozzleTemperature.Value).ConfigureAwait(false);
            }

            logger.LogInformation("OK.");
        }
Ejemplo n.º 2
0
        protected override async Task Handle(MigoEndpoint endpoint, double zoffset)
        {
            Log.Information($"Setting ZOffset to {zoffset.ToString()}...");
            var migo   = MigoFactory.Create(endpoint);
            var result = await migo.SetZOffset(zoffset)
                         .ConfigureAwait(false);

            Log.Information($"ZOffset = {result.ZOffset.ToString()}");
        }
Ejemplo n.º 3
0
        protected override async Task Handle(MigoEndpoint endpoint)
        {
            var migo   = MigoFactory.Create(endpoint);
            var result = await migo.GetZOffset()
                         .ConfigureAwait(false);

            var json = JsonSerializer.Serialize(result);

            Log.Information(json);
        }
Ejemplo n.º 4
0
        protected override async Task Handle(MigoEndpoint endpoint)
        {
            Log.Information($"Stopping print job...");
            var migo   = MigoFactory.Create(endpoint);
            var result = await migo.StopPrint()
                         .ConfigureAwait(false);

            var json = JsonSerializer.Serialize(result);

            Log.Information(json);
        }
Ejemplo n.º 5
0
        protected override async Task Handle(MigoEndpoint endpoint, string fileName)
        {
            Log.Information($"Uploading file from path {fileName}...");
            var migo = MigoFactory.Create(endpoint);

            _cts = new CancellationTokenSource();

            await Task.WhenAll(
                UploadFile(migo, fileName, _cts),
                OnProgressUpdate(migo, _cts.Token))
            .ConfigureAwait(false);
        }
Ejemplo n.º 6
0
        protected override async Task Handle(MigoEndpoint endpoint, string command)
        {
            var lines = command.Split(';');

            var migo   = MigoFactory.Create(endpoint);
            var result = await migo.ExecuteGCode(lines)
                         .ConfigureAwait(false);

            var json = JsonSerializer.Serialize(result);

            Log.Information(json);
        }
Ejemplo n.º 7
0
        protected override async Task Handle(MigoEndpoint endpoint, string fileName)
        {
            var logger = Program.LoggerFactory.CreateLogger <PreheatAndPrint>();
            var migo   = MigoFactory.Create(endpoint);

            var preheatTemperature = CurrentParseResult.CommandResult
                                     .OptionResult(PreheatOption)?
                                     .GetValueOrDefault <double>();

            var scenario = new PreheatAndPrint(logger, migo, fileName, preheatTemperature);

            var result = await scenario.Execute(CancellationToken.None)
                         .ConfigureAwait(false);

            var json = JsonSerializer.Serialize(result);

            Log.Information(json);
        }
Ejemplo n.º 8
0
        protected override async Task Handle(MigoEndpoint endpoint, BedLevelingCalibrationMode mode)
        {
            Console.WriteLine($"Starting manual bed calibration with mode = {mode}");

            var logger = Program.LoggerFactory.CreateLogger <BedLevelingCalibration>();
            var migo   = MigoFactory.Create(endpoint);

            var scenario = new BedLevelingCalibration(logger, migo, mode);

            await foreach (var calibrationResult in scenario.Execute(CancellationToken.None))
            {
                Console.WriteLine($"Current point is ({calibrationResult.Current.X},{calibrationResult.Current.Y})");
                Console.WriteLine("Press any key to continue...");
                await Console.In.ReadLineAsync().ConfigureAwait(false);

                Console.WriteLine($"Next point is ({calibrationResult.Next.X},{calibrationResult.Next.Y})");
            }
        }