public void Setup() { var endpoint = new MigoEndpoint(Ip, Port); _migo = new Migo(Init.LoggerFactory, endpoint); _tokenSource = new CancellationTokenSource(); }
private async Task <Process> ExecuteCommand(MigoEndpoint endpoint, string command) { var process = new Process { StartInfo = new ProcessStartInfo( "dotnet", $"run -p ../../../../src/MigoToolCli/MigoToolCli.csproj -- --endpoint={endpoint} {command}") { RedirectStandardOutput = true, RedirectStandardError = true } }; process.Start(); await process.WaitForExitAsync(); var output = await process.StandardOutput.ReadToEndAsync(); var err = await process.StandardError.ReadToEndAsync(); Log.Information(output); Log.Information(err); return(process); }
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."); }
public void Init() { _endpoint = new MigoEndpoint(IPAddress.Parse("127.0.0.1"), 5100); var logger = Tests.Init.LoggerFactory.CreateLogger <FakeMigo>(); _fakeMigo = new FakeMigo(_endpoint, logger); _fakeMigo.Start(); }
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()}"); }
public async Task Should_get_migo_state() { var endpoint = new MigoEndpoint(MigoIp, MigoPort); var migo = new Migo(Init.LoggerFactory, endpoint); var state = await migo.GetState().ConfigureAwait(false); Log.Information(JsonConvert.SerializeObject(state)); state.NozzleTemp.Should().BePositive(); }
public async Task Should_set_zoffset_and_receive_correct_response() { var endpoint = new MigoEndpoint(MigoIp, MigoPort); var migo = new Migo(Init.LoggerFactory, endpoint); var expectedOffset = -0.8; var actualOffset = await migo.SetZOffset(expectedOffset).ConfigureAwait(false); actualOffset.Should().Be(expectedOffset); }
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); }
private void OnSelectedEndpointChanged(MigoEndpoint endpoint) { if (!endpoint.IsValid()) { return; } _migoProxyService.SwitchTo(endpoint); StartupObservables(); }
public async Task Should_exec_gcode() { var endpoint = new MigoEndpoint(MigoIp, MigoPort); var migo = new Migo(Init.LoggerFactory, endpoint); var gcode = "G28 X0 Y0"; var result = await migo.ExecuteGCode(new[] { gcode }) .ConfigureAwait(false); result.Success.Should().BeTrue(); }
public async Task Should_get_migo_printerinfo() { var endpoint = new MigoEndpoint(MigoIp, MigoPort); var migo = new Migo(Init.LoggerFactory, endpoint); var state = await migo.GetPrinterInfo().ConfigureAwait(false); Log.Information(JsonConvert.SerializeObject(state)); state.Success.Should().BeTrue(); }
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); }
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); }
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); }
public void OneTimeSetup() { var logger = Init.LoggerFactory.CreateLogger <FakeMigo>(); var fileInfo = new FileInfo(GCodeFile); _gCodeSize = fileInfo.Length + 33; _fakeMigo = new FakeMigo(Ip, Port, logger); _fakeMigo.Start(); var endpoint = new MigoEndpoint(Ip, Port); _migo = new Migo(Init.LoggerFactory, endpoint); }
public FakeMigo(MigoEndpoint endpoint, ILogger <FakeMigo> logger) { var bytesBuff = new byte[MaxBuffer]; _buffer = new Memory <byte>(bytesBuff); _receiveStream = new MemoryStream(MaxBuffer); _tokenSource = new CancellationTokenSource(); _tcpListener = new TcpListener(endpoint.Ip, endpoint.Port); _log = logger; _streamReplies = PopulateStreamReplies() .ToList(); }
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); }
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})"); } }
protected abstract Task Handle(MigoEndpoint endpoint);
public Config(MigoEndpoint selectedEndpoint, IReadOnlyCollection <MigoEndpoint> endpoints) { SelectedEndpoint = selectedEndpoint; Endpoints = endpoints; }
public static Migo Create(MigoEndpoint endpoint) => new(Program.LoggerFactory, endpoint);