public Line(LineCmd lineCmd, CoordinateCorrector coordinateCorrector) { //this.Valve = lineCmd.Valve; this.RunnableModule = lineCmd.RunnableModule; if (this.RunnableModule.Mode == ModuleMode.AssignMode1 || this.RunnableModule.Mode == ModuleMode.MainMode) { this.Valve = ValveType.Valve1; } else if (this.RunnableModule.Mode == ModuleMode.DualFallow) { this.Valve = ValveType.Both; } else { this.Valve = ValveType.Valve2; } PointD start, end; foreach (LineCoordinate line in lineCmd.LineCoordinateList) { start = coordinateCorrector.Correct(lineCmd.RunnableModule, line.Start, Executor.Instance.Program.ExecutantOriginOffset); end = coordinateCorrector.Correct(lineCmd.RunnableModule, line.End, Executor.Instance.Program.ExecutantOriginOffset); LineCoordinate newLine = new LineCoordinate(start, end); newLine.Weight = line.Weight; newLine.LineStyle = line.LineStyle; newLine.Param = lineCmd.RunnableModule.CommandsModule.Program.ProgramSettings.GetLineParam(newLine.LineStyle); newLine.LookOffsetRevs = line.LookOffsetRevs; newLine.LookOffset = line.LookOffset; newLine.Repetition = line.Repetition; lineCoordinateList.Add(newLine); lineCoordinateDic.Add(newLine, this); Log.Dprint("Line start : " + line.Start + ", real : " + start); Log.Dprint("Line end : " + line.End + ", real : " + end); } param = lineCmd.RunnableModule.CommandsModule.Program.ProgramSettings.GetLineParam(lineCmd.LineStyle); isWeightControl = lineCmd.IsWeightControl; wholeWeight = lineCmd.WholeWeight; Program = lineCmd.RunnableModule.CommandsModule.Program; this.lineCmd = lineCmd; if (lineCmd.AssociatedMeasureHeightCmd != null) { curMeasureHeightValue = lineCmd.AssociatedMeasureHeightCmd.RealHtValue; } else { curMeasureHeightValue = this.RunnableModule.MeasuredHt; } this.Tilt = this.lineCmd.Tilt; }
private void ProcessCmdLine(WorkProcessor processor, LineCmd cmdline) { string cmd = cmdline.CmdLine; Dictionary <string, string> args = null; int pos = cmdline.CmdLine.IndexOf(' '); if (pos != -1) { cmd = cmdline.CmdLine.Substring(0, pos); args = cmdline.CmdLine.Substring(pos + 1).Split(' ').ToList() .ConvertAll(s => { var p = s.IndexOf('='); return(p == -1 ? new { Name = s, Value = "" } : new { Name = s.Substring(0, p), Value = s.Substring(p + 1) }); }) .ToDictionary(s => s.Name, s => s.Value); } switch (cmd) { case "list": { var list = this.pluginManager.GetPlugins(); cmdline.Resp = string.Join("|", list.ToList().ConvertAll(d => d.PluginAssemblyPath).ToArray()); } break; case "add": { this.pluginManager.AddPlugin(cmdline.Bytes, args["file"]); } break; case "remove": { this.pluginManager.RemovePlugin(args["file"]); } break; case "q": { cmdline.DisconnectSocket = true; } break; default: { } break; } }
private void ProcessCmdline(string line, byte[] bytes) { Debug.Assert(cmdlineProcessor != null, "必须有处理器"); var cmdLine = new LineCmd() { CmdLine = line, Bytes = bytes }; try { cmdlineProcessor(this, cmdLine); if (cmdLine.DisconnectSocket) { this.client.Close(); return; } } catch (Exception ex) { log.ErrorFormat("cmdlineProcessor", ex.Message); CloseSocket(client); return; } if (string.IsNullOrEmpty(cmdLine.Resp)) { receivedBytesCount = 0; BeginReceive(client); } else { try { var bytesSend = Encoding.UTF8.GetBytes(cmdLine.Resp); client.BeginSend(bytesSend, 0, bytesSend.Length, SocketFlags.None, new AsyncCallback(OnSent), client); } catch (SocketException ex) { log.ErrorFormat("BeginReceive", ex); CloseSocket(client); } catch (ObjectDisposedException ex) { log.ErrorFormat("BeginReceive", ex.Message); CloseSocket(client); } } }