Example #1
0
        public MultiTracesCmd(RunnableModule runnableModule, MultiTracesCmdLine multiTracesCmdLine, MeasureHeightCmd mhCmd)
            : base(runnableModule, multiTracesCmdLine)
        {
            this.Valve = multiTracesCmdLine.Valve;
            var structure = runnableModule.CommandsModule.program.ModuleStructure;

            this.multiTracesCmdLine = multiTracesCmdLine;

            foreach (var trace in this.multiTracesCmdLine.Traces)
            {
                TraceBase newTrace = trace.Clone() as TraceBase;
                if (newTrace is TraceLine)
                {
                    TraceLine traceLine = newTrace as TraceLine;
                    traceLine.Start = structure.ToMachine(runnableModule, traceLine.Start);
                    traceLine.End   = structure.ToMachine(runnableModule, traceLine.End);
                }
                else
                {
                    TraceArc traceArc = newTrace as TraceArc;
                    traceArc.Start = structure.ToMachine(runnableModule, traceArc.Start);
                    traceArc.Mid   = structure.ToMachine(runnableModule, traceArc.Mid);
                    traceArc.End   = structure.ToMachine(runnableModule, traceArc.End);
                }
                this.traces.Add(newTrace);
            }

            LineStyle       = multiTracesCmdLine.LineStyle;
            IsWeightControl = multiTracesCmdLine.IsWeightControl;
            wholeWeight     = multiTracesCmdLine.WholeWeight;
            this.OffsetX    = multiTracesCmdLine.OffsetX;
            this.OffsetY    = multiTracesCmdLine.OffsetY;
            this.associatedMeasureHeightCmd = mhCmd;
            //this.CheckRepeat();
        }
Example #2
0
 public PointTrace(PointD point, TraceBase trace, int traceIndex, TracePointType pointType)
 {
     this.Point      = point;
     this.Trace      = trace;
     this.TraceIndex = traceIndex;
     this.PointType  = pointType;
 }
Example #3
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (this.listBoxPoints.SelectedIndex < 0)
            {
                return;
            }
            PointTrace pointTrace = pointsCache[this.listBoxPoints.SelectedIndex];

            if (pointTrace.PointType != TracePointType.End)
            {
                return;
            }

            int index = this.listBoxPoints.SelectedIndex;

            PointTrace pointPrev = pointsCache[this.listBoxPoints.SelectedIndex - 1];
            PointD     newPoint  = (Machine.Instance.Robot.PosXY - origin).ToPoint();
            TraceBase  trace     = this.tracesCache[pointTrace.TraceIndex];

            TraceBase tracePrev;

            if (pointTrace.TraceIndex == 0)
            {
                tracePrev = null;
            }
            else
            {
                tracePrev = this.tracesCache[pointTrace.TraceIndex - 1];
            }

            if (this.rbLine.Checked)
            {
                trace.Start = newPoint.Clone() as PointD;
                TraceLine line;
                if (tracePrev == null)
                {
                    line           = new TraceLine(pointPrev.Point.Clone() as PointD, newPoint.Clone() as PointD);
                    line.LineStyle = trace.LineStyle;
                }
                else
                {
                    line           = new TraceLine(tracePrev.End.Clone() as PointD, newPoint.Clone() as PointD);
                    line.LineStyle = trace.LineStyle;
                }
                this.tracesCache.Insert(pointTrace.TraceIndex, line);
            }
            else
            {
                TraceArc arc = new TraceArc(trace.Start, newPoint, trace.End);
                arc.LineStyle = trace.LineStyle;
                this.tracesCache[pointTrace.TraceIndex] = arc;
            }
            this.updatePointsCache();
            this.LoadLines2ListBox();
            this.LoadPoints2ListBox();

            this.listBoxPoints.SelectedIndex = index + 1;
        }
Example #4
0
        public MultiTraces(MultiTracesCmd multiTracesCmd, CoordinateCorrector coordinateCorrector)
        {
            this.RunnableModule = multiTracesCmd.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;
            }

            foreach (var item in multiTracesCmd.Traces)
            {
                TraceBase newTrace = item.Clone() as TraceBase;
                if (newTrace is TraceLine)
                {
                    TraceLine traceLine = newTrace as TraceLine;
                    traceLine.Start = coordinateCorrector.Correct(multiTracesCmd.RunnableModule, traceLine.Start, Executor.Instance.Program.ExecutantOriginOffset);
                    traceLine.End   = coordinateCorrector.Correct(multiTracesCmd.RunnableModule, traceLine.End, Executor.Instance.Program.ExecutantOriginOffset);
                }
                else
                {
                    TraceArc traceArc = newTrace as TraceArc;
                    traceArc.Start = coordinateCorrector.Correct(multiTracesCmd.RunnableModule, traceArc.Start, Executor.Instance.Program.ExecutantOriginOffset);
                    traceArc.Mid   = coordinateCorrector.Correct(multiTracesCmd.RunnableModule, traceArc.Mid, Executor.Instance.Program.ExecutantOriginOffset);
                    traceArc.End   = coordinateCorrector.Correct(multiTracesCmd.RunnableModule, traceArc.End, Executor.Instance.Program.ExecutantOriginOffset);
                }

                //newTrace.Param = multiTracesCmd.RunnableModule.CommandsModule.Program.ProgramSettings.GetLineParam(newLine.LineStyle);
                this.traces.Add(newTrace);
                Log.Dprint(string.Format("{0}: {1}", item.GetType(), item));
            }
            //param = multiTracesCmd.RunnableModule.CommandsModule.Program.ProgramSettings.GetLineParam(multiTracesCmd.LineStyle);
            isWeightControl     = multiTracesCmd.IsWeightControl;
            wholeWeight         = multiTracesCmd.WholeWeight;
            this.OffsetX        = multiTracesCmd.OffsetX;
            this.OffsetY        = multiTracesCmd.OffsetY;
            Program             = multiTracesCmd.RunnableModule.CommandsModule.Program;
            this.multiTracesCmd = multiTracesCmd;
            if (multiTracesCmd.AssociatedMeasureHeightCmd != null)
            {
                curMeasureHeightValue = multiTracesCmd.AssociatedMeasureHeightCmd.RealHtValue;
            }
            else
            {
                curMeasureHeightValue = this.RunnableModule.MeasuredHt;
            }
        }
Example #5
0
        /// <summary>
        /// 获取副阀的AB轴的移动轨迹
        /// </summary>
        /// <param name="multiTraces"></param>
        /// <param name="trace"></param>
        /// <returns></returns>
        private TraceBase getSimulTraces(MultiTraces multiTraces, TraceBase trace)
        {
            TraceBase newTrace = trace.Clone() as TraceBase;

            newTrace.Start = this.getSimulPos(multiTraces, newTrace.Start);
            newTrace.End   = this.getSimulPos(multiTraces, newTrace.End);
            if (newTrace is TraceArc)
            {
                TraceArc traceArc = newTrace as TraceArc;
                traceArc.Mid = this.getSimulPos(multiTraces, traceArc.Mid);
            }
            return(newTrace);
        }
Example #6
0
        /// <summary>
        /// 螺杆阀Wet和Dry模式下的运行逻辑
        /// </summary>
        /// <param name="points"></param>
        /// <returns></returns>
        private Result SvValveWetAndDryLogic(MultiTraces multiTraces)
        {
            Result ret = Result.OK;
            //主阀轨迹
            List <TraceBase> primaryTraces = new List <TraceBase>();
            //副阀轨迹
            List <TraceBase> simulTraces = new List <TraceBase>();

            //将相机坐标位置转换为阀的位置
            foreach (var trace in multiTraces.Traces)
            {
                TraceBase newTrace = trace.Clone() as TraceBase;
                newTrace.Start = newTrace.Start.ToNeedle(multiTraces.Valve);
                newTrace.End   = newTrace.End.ToNeedle(multiTraces.Valve);
                if (newTrace is TraceArc)
                {
                    TraceArc traceArc = newTrace as TraceArc;
                    traceArc.Mid = traceArc.Mid.ToNeedle(multiTraces.Valve);
                }
                primaryTraces.Add(newTrace);
            }

            //为主阀的坐标点进行偏移调整
            foreach (var trace in primaryTraces)
            {
                trace.TranslateBy(multiTraces.OffsetX, multiTraces.OffsetY);
            }

            //生成副阀的坐标点
            for (int i = 0; i < primaryTraces.Count; i++)
            {
                simulTraces.Add(this.getSimulTraces(multiTraces, primaryTraces[i]));
            }

            ret = this.SvValveTracesLogic(multiTraces, primaryTraces, simulTraces);
            if (!ret.IsOk)
            {
                return(ret);
            }

            return(ret);
        }
Example #7
0
        private void btnTeachEnd_Click(object sender, EventArgs e)
        {
            tbEndX.Text = (Machine.Instance.Robot.PosX - origin.X).ToString("0.000");
            tbEndY.Text = (Machine.Instance.Robot.PosY - origin.Y).ToString("0.000");
            if (!tbEndX.IsValid || !tbEndY.IsValid)
            {
                //MessageBox.Show("Please input valid values.");
                MessageBox.Show("请输入正确的值.");
                return;
            }
            //机械坐标->系统坐标
            this.tempEndPoint = pattern.SystemRel(tbEndX.Value, tbEndY.Value);
            if (hasSamePoints())
            {
                MessageBox.Show("存在相同点,请检查.");
                return;
            }
            TraceBase newTrace = null;

            if (this.rbLine.Checked)
            {
                newTrace = new TraceLine(this.tempStartPoint.Clone() as PointD, this.tempEndPoint.Clone() as PointD);
            }
            else
            {
                newTrace = new TraceArc(this.tempStartPoint.Clone() as PointD, this.tempMidPoint.Clone() as PointD, this.tempEndPoint.Clone() as PointD);
            }
            newTrace.LineStyle = this.comboBoxLineType.SelectedIndex;
            this.tracesCache.Add(newTrace);
            this.updatePointsCache();
            this.LoadLines2ListBox();
            this.LoadPoints2ListBox();
            listBoxLines.SelectedIndex  = listBoxLines.Items.Count - 1;
            listBoxPoints.SelectedIndex = listBoxPoints.Items.Count - 1;
            // 本段终点为下一段轨迹的起点
            this.tempStartPoint.X = this.tempEndPoint.X;
            this.tempStartPoint.Y = this.tempEndPoint.Y;
            this.tbStartX.Text    = this.tempStartPoint.X.ToString("0.000");
            this.tbStartY.Text    = this.tempStartPoint.Y.ToString("0.000");
            this.tbMidX.Text      = this.tempMidPoint.X.ToString("0.000");
            this.tbMidY.Text      = this.tempMidPoint.Y.ToString("0.000");
        }
Example #8
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.listBoxPoints.SelectedIndex < 0)
            {
                return;
            }
            PointTrace pointTrace = pointsCache[this.listBoxPoints.SelectedIndex];
            TraceBase  trace      = this.tracesCache[pointTrace.TraceIndex];
            TraceBase  traceNext  = null;
            TraceBase  traceNew   = null;

            if (pointTrace.PointType == TracePointType.End)
            {
                // 删除连接点,则同时删除2条相邻轨迹,用一条直线轨迹替代
                if (this.tracesCache.Count - 1 >= pointTrace.TraceIndex + 1)
                {
                    traceNext          = this.tracesCache[pointTrace.TraceIndex + 1];
                    traceNew           = new TraceLine(trace.Start, traceNext.End);
                    traceNew.LineStyle = trace.LineStyle;
                }
                this.tracesCache.Remove(trace);
                if (traceNext != null)
                {
                    this.tracesCache.Remove(traceNext);
                    this.tracesCache.Insert(pointTrace.TraceIndex, traceNew);
                }
            }
            else if (pointTrace.PointType == TracePointType.Mid)
            {
                traceNew           = new TraceLine(trace.Start, trace.End);
                traceNew.LineStyle = trace.LineStyle;
                this.tracesCache.Remove(trace);
                this.tracesCache.Insert(pointTrace.TraceIndex, traceNew);
            }
            this.updatePointsCache();
            this.LoadLines2ListBox();
            this.LoadPoints2ListBox();
        }
Example #9
0
        /// <summary>
        /// 根据轨迹集合生成插补列表
        /// </summary>
        /// <param name="traces"></param>
        /// <param name="vels"></param>
        /// <param name="acc"></param>
        /// <returns></returns>
        public static List <ICrdable> GetCrdsBy(List <TraceBase> traces, double[] vels, double acc)
        {
            List <ICrdable> crdList = new List <ICrdable>();

            for (int i = 0; i < traces.Count; i++)
            {
                TraceBase trace = traces[i];
                if (trace is TraceLine)
                {
                    CrdLnXY crd = new CrdLnXY()
                    {
                        EndPosX = trace.End.X,
                        EndPosY = trace.End.Y,
                        Vel     = vels[i],
                        Acc     = acc,
                        VelEnd  = i == (traces.Count - 1) ? 0 : vels[i + 1]
                    };
                    crdList.Add(crd);
                }
                else if (trace is TraceArc)
                {
                    CrdArcXYC crd = new CrdArcXYC()
                    {
                        EndPosX   = trace.End.X,
                        EndPosY   = trace.End.Y,
                        CenterX   = (trace as TraceArc).Center.X - trace.Start.X,
                        CenterY   = (trace as TraceArc).Center.Y - trace.Start.Y,
                        Clockwise = (short)((trace as TraceArc).Degree > 0 ? 1 : 0),
                        Vel       = vels[i],
                        Acc       = acc,
                        VelEnd    = i == (traces.Count - 1) ? 0 : vels[i + 1]
                    };
                    crdList.Add(crd);
                }
            }
            return(crdList);
        }
Example #10
0
 /// <summary>
 /// 获取线参数
 /// </summary>
 /// <param name="multiTraces"></param>
 /// <param name="lineStyle"></param>
 /// <returns></returns>
 private LineParam getLineParam(MultiTraces multiTraces, TraceBase trace)
 {
     return(multiTraces.RunnableModule.CommandsModule.Program.ProgramSettings.GetLineParam((LineStyle)trace.LineStyle));
 }
Example #11
0
 public static void ClassCleanup()
 {
     TraceBase.InitClass("DebugTrace");
 }
Example #12
0
 public static void ClassInit(TestContext context)
 {
     TraceBase.InitClass("DebugTrace_PropertyV1Test");
 }
Example #13
0
 public LineParam GetLineStyle(TraceBase trace)
 {
     return(this.RunnableModule.CommandsModule.Program.ProgramSettings.GetLineParam((LineStyle)trace.LineStyle));
 }