/// <summary> /// 根据路径获取脚本程序 /// </summary> /// <param name="fstream"></param> /// <param name="programPath"></param> /// <returns></returns> public static FluidProgram GetProgram(Stream fstream, string programPath) { fstream = new FileStream(programPath, FileMode.Open, FileAccess.Read); BinaryFormatter binFormat = new BinaryFormatter(); FluidProgram program = (FluidProgram)binFormat.Deserialize(fstream); // 新增用户位置定义,防止加载之前的程序用户位置为空 if (program.UserPositions == null) { program.UserPositions = new List <UserPosition>(); } if (program.Conveyor2OriginOffset == null) { program.Conveyor2OriginOffset = new PointD(); } if (program.runtimeSettings.FlyOffsetList == null) { program.runtimeSettings.FlyOffsetList = new List <VectorD>(); } // Load程序后,第一次打开Pattern需要拍摄Mark点进行编程模式下的坐标校正 program.NeedMarkCorrect(); // 初始化Mark点 program.initMarks(); return(program); }
/// <summary> /// 加载程序 /// </summary> /// <param name="programName">程序名称</param> /// <param name="onFinished"></param> /// <param name="onError"></param> public static void Load(string programPath, OnFinished <FluidProgram> onFinished, OnError onError) { Stream fstream = null; try { FluidProgram program = GetProgram(fstream, programPath); current = program; //传递程序中的速度重量键值对 SvOrGearValveSpeedWeightValve.VavelSpeedWeightDic = FluidProgram.CurrentOrDefault().runtimeSettings.VavelSpeedDic; onFinished?.Invoke(program); } catch (Exception e) { onError?.Invoke(-1, e.ToString()); } finally { if (fstream != null) { fstream.Close(); } } }
public void ChangeAirValue(ushort value) { FluidProgram.CurrentOrDefault().RuntimeSettings.AirPressure = value; if (Machine.Instance.Setting.ValveSelect == ValveSelection.双阀) { FluidProgram.CurrentOrDefault().RuntimeSettings.AirPressure2 = value; } }
/// <summary> /// 默认程序,初始化一次 /// </summary> /// <returns>默认空程序</returns> public static FluidProgram Default() { if (defaultProgram == null) { defaultProgram = new FluidProgram("default", 0, 0); } return(defaultProgram); }
public Pattern(FluidProgram program, string name, double originX, double originY) : base(program) { this.name = name; Origin.X = originX; Origin.Y = originY; //this.ParentPattern = program.Workpiece; //program.Workpiece.AddChild(this); AddCmdLine(new EndCmdLine()); }
/// <summary> /// 创建新程序 /// </summary> /// <param name="name">程序名称</param> /// <param name="originPosX">产品坐标原点</param> /// <param name="originPosY">产品坐标原点</param> /// <returns></returns> public static FluidProgram Create(string name, double originPosX, double originPosY) { current = new FluidProgram(name, originPosX, originPosY); current.runtimeSettings.SingleDropWeight = 0.1; return(current); }
public Workpiece(FluidProgram program, double originX, double originY) : base(program, WORKPIECE_NAME, originX, originY) { }