/// <summary> /// 安装应用 /// </summary> /// <param name="apkFileInfo"></param> /// <param name="device"></param> /// <param name="cmdStation"></param> public static void InstallTo(this FileInfo apkFileInfo, IDevice device, CommandStation cmdStation = null) { if (apkFileInfo == null) { throw new ArgumentNullException(nameof(apkFileInfo)); } if (device == null) { throw new ArgumentNullException(nameof(device)); } if (apkFileInfo.Extension != ".apk") { throw new ArgumentException("Is not apk file!", nameof(apkFileInfo)); } using (var command = cmdStation.NullCheckAndGet() .GetAdbCommand(device, $"install \"{apkFileInfo.FullName}\"")) { var result = command.Execute(); if (result.ExitCode != 0) { throw new AdbCommandFailedException(result.Output, result.ExitCode); } } }
/// <summary> /// Prepare this state for use in a live railway. /// Make sure all relevant connections to other state objects are resolved. /// </summary> /// <returns>True if the entity is now ready for use in a live railway, false otherwise.</returns> protected override bool TryPrepareForUse(IStateUserInterface ui, IStatePersistence statePersistence) { if (!base.TryPrepareForUse(ui, statePersistence)) { return(false); } CommandStation.AddInput(busyInput); return(true); }
public void TransmitCommandSequenceTest() { //arrange var mocks = new Mocks(); var robots = new List <Robot> { mocks.GetRobot() }; var commandStation = new CommandStation(robots); //act commandStation.TransmitCommandSequence(0, mocks.GetCommandSequence()); //assert var robot = commandStation.Robots[0]; Assert.AreEqual(3, robot.X); Assert.AreEqual(3, robot.Y); Assert.AreEqual(Orientation.north, robot.Orientation); Assert.AreEqual(true, robot.IsLost); }
protected void Button1_Click(object sender, EventArgs e) { try { var input = txtInput.Text; List <Robot> robots; List <List <Command> > commandSequences; Input.GetRobotsAndCommandSequences(input, out robots, out commandSequences); var commandStation = new CommandStation(robots); for (int i = 0; i < commandStation.Robots.Count(); i++) { commandStation.TransmitCommandSequence(i, commandSequences[i]); } var robotReport = Output.GetRobotReport(robots); txtOutput.Text = robotReport; } catch (Exception ex) { txtOutput.Text = ex.Message; } }
/// <summary> /// 推送文件到设备 /// </summary> /// <param name="fileInfo"></param> /// <param name="device"></param> /// <param name="path"></param> /// <param name="cmdStation"></param> public static void PushTo(this FileInfo fileInfo, IDevice device, string path, CommandStation cmdStation = null) { if (fileInfo == null) { throw new ArgumentNullException(nameof(fileInfo)); } if (device == null) { throw new ArgumentNullException(nameof(device)); } if (path == null) { throw new ArgumentNullException(nameof(path)); } using (var command = cmdStation.NullCheckAndGet() .GetAdbCommand(device, $"push \"{fileInfo.FullName}\" \"{path}\"")) { var result = command.Execute(); if (result.ExitCode != 0) { throw new AdbCommandFailedException(result.Output, result.ExitCode); } } }
/// <summary> /// 构建 /// </summary> /// <param name="device"></param> /// <param name="commandStation"></param> public DeviceCommanderFactory(IDevice device, CommandStation commandStation) { this.device = device ?? throw new ArgumentNullException(nameof(device)); this.commandStation = commandStation ?? throw new ArgumentNullException(nameof(commandStation)); }
static ExtensionShared() { CommandStation = new CommandStation(); }
public static CommandStation NullCheckAndGet(this CommandStation cmdStation) { return(cmdStation ?? CommandStation); }
/// <summary> /// Requested state of active property has changed. /// </summary> private void OnActiveRequestedChanged(bool value) { CommandStation.SendBinaryOutput(this); }
/// <summary> /// 当创建时,严格化拓展在此处初始化了一些工厂类 /// </summary> /// <param name="args"></param> protected override void OnCreate(ExtensionArgs args) { base.OnCreate(args); InitLazyFactory(); CmdStation = new CommandStation(); }
/// <summary> /// Requested pattern state has changed. /// </summary> private void OnPatternRequestedChanged(int value) { CommandStation.SendClock4StageOutput(this); }