/// <summary> /// 지정된 반지름을 갖는 원 그리기 /// </summary> /// <param name="rtc"></param> /// <param name="radius"></param> private static void DrawCircle(ILaser laser, IRtc rtc, double radius) { rtc.ListBegin(laser); rtc.ListJump(new Vector2((float)radius, 0)); rtc.ListArc(new Vector2(0, 0), 360.0); rtc.ListEnd(); }
private static bool DrawCircle(ILaser laser, IRtc rtc) { bool success = true; var rtcDualHead = rtc as IRtcDualHead; //리스트 시작 success &= rtc.ListBegin(laser); //리스트 명령으로 오프셋 및 회전 처리 방법 //rtcDualHead.ListHeadOffset(ScannerHead.Primary, new Vector2(5, 0), 0); //rtcDualHead.ListHeadOffset(ScannerHead.Secondary, new Vector2(-5, 0), 0); for (int i = 0; i < 10; i++) { //직선을 그립니다. success &= rtc.ListJump(new Vector2(0, 0)); success &= rtc.ListMark(new Vector2(10, 0)); success &= rtc.ListJump(new Vector2((float)10, 0)); success &= rtc.ListArc(new Vector2(0, 0), 360.0f); if (!success) { break; } } //리스트 명령으로 오프셋 및 회전 처리 방법 //rtcDualHead.ListHeadOffset(ScannerHead.Primary, Vector2.Zero, 0); //rtcDualHead.ListHeadOffset(ScannerHead.Secondary, Vector2.Zero, 0); //리스트 종료 if (success) { success &= rtc.ListEnd(); //나머지 데이타 가공 완료 대기 success &= rtc.ListExecute(true); } return(success); }
private static void DrawCircle(IRtc rtc, double radius) { rtc.ListBegin(); rtc.ListJump(new System.Numerics.Vector2((float)radius, 0)); rtc.ListArc(new System.Numerics.Vector2(0, 0), 360.0); rtc.ListEnd(); }
private static void DrawCircleWithPosition(ILaser laser, IRtc rtc) { var motf = rtc as IRtcMOTF; /// RTC 15핀 커넥터에 있는 /START , /STOP 입력핀을 시작, 중지 트리거로 사용합니다. ///turn on external /start ///turn on reset encoder when external start var extCtrl = new RtcExternalControlMode(); extCtrl.Add(RtcExternalControlMode.Signal.EncoderReset); extCtrl.Add(RtcExternalControlMode.Signal.ExternalStart); extCtrl.Add(RtcExternalControlMode.Signal.ExternalStartAgain); motf.CtlExternalControl(extCtrl); rtc.ListBegin(laser); ///직선을 그립니다. (엔코더 입력과 무관합니다) rtc.ListJump(new Vector2(0, 0)); rtc.ListMark(new Vector2(10, 0)); /// ListMOTFBegin 부터 ListMOTFEnd 사이의 모든 list 명령어는 엔코더증감값이 적용됩니다 motf.ListMOTFBegin(); /// 엔코더 X 값이 10mm 가 넘을때(Over) 까지 리스트 명령을 대기 motf.ListMOTFWait(RtcEncoder.EncX, 10, EncoderWaitCondition.Over);//wait until encoder x position over 10.0mm ///엔코더 X 값이 위 조건을 만족한이후 원 을 그린다 rtc.ListJump(new Vector2((float)10, 0)); rtc.ListArc(new Vector2(0, 0), 360.0f); /// MOTF 중지및 0,0 위치(스캐너 중심 위치)로 jump 실시 motf.ListMOTFEnd(Vector2.Zero); rtc.ListEnd(); ///외부 트리거(/START)에 의해 시작되므로 execute 호출은 하지 않는다 ///rtc.ListExecute(); /// its not need to call because its started by external trigger }
/// <summary> /// 지정된 반지름을 갖는 원 그리기 /// </summary> /// <param name="rtc"></param> /// <param name="radius"></param> private static void DrawCircle(ILaser laser, IRtc rtc, double radius) { /// 스캐너만 구동하여 원 그리기 rtc.ListBegin(laser, MotionType.ScannerOnly); rtc.ListJump(new Vector2((float)radius, 0)); rtc.ListArc(new Vector2(0, 0), 360.0f); rtc.ListEnd(); rtc.ListExecute(true); }
private static void DrawCircle(ILaser laser, IRtc rtc) { float radius = 20.0f; rtc.ListBegin(laser); rtc.ListJump(new Vector2(radius, 0)); rtc.ListArc(new Vector2(0, 0), 360.0f); rtc.ListEnd(); }
/// <summary> /// laser processing /// </summary> /// <param name="rtc"></param> /// <returns></returns> public override bool Mark(IRtc rtc) { if (this.OutterDiameter <= 0) { return(false); } if (this.InnerDiameter > this.OutterDiameter) { return(false); } if (this.Revolutions <= 0) { return(false); } bool success = true; ///translate spiral's center rtc.Matrix.Push(this.X, this.Y); ///jump to start pos success &= rtc.ListJump(new Vector2((float)(this.InnerDiameter / 2.0), 0.0f)); ///calculate radial pitch double radialPitch = (this.OutterDiameter - this.InnerDiameter) / 2.0 / (double)this.Revolutions; for (int i = 0; i < this.Revolutions; i++) { for (double t = 0; t < 360; t += 30.0) ///360/30 = 12 steps { double angle = t + 360.0 * (double)i; double degInRad = angle * Math.PI / 180.0; double d = InnerDiameter / 2.0 + radialPitch * (double)i + radialPitch * t / 360.0; Vector2 v2; v2.X = (float)(d * Math.Cos(degInRad)); v2.Y = (float)(d * Math.Sin(degInRad)); success &= rtc.ListMark(v2); if (!success) { break; } } if (!success) { break; } } if (success && this.Closed) { success &= rtc.ListArc(new Vector2(0.0f, 0.0f), 360.0); } rtc.Matrix.Pop(); return(success); }
/// <summary> /// draw circle /// </summary> /// <param name="laser"></param> /// <param name="rtc"></param> /// <param name="radius"></param> private static bool DrawCircle(ILaser laser, IRtc rtc, float radius) { if (rtc.CtlGetStatus(RtcStatus.Busy)) { return(false); } var rtcMeasurement = rtc as IRtcMeasurement; Debug.Assert(rtcMeasurement != null); Console.WriteLine("WARNING !!! LASER IS BUSY ... Draw Circle"); timer = Stopwatch.StartNew(); var channels = new MeasurementChannel[4] { MeasurementChannel.SampleX, //X MeasurementChannel.SampleY, //Y MeasurementChannel.LaserOn, //Gate 0/1 MeasurementChannel.OutputPeriod, //KHz }; float hz = 10 * 1000; //10KHz (샘플링 주기 : 100usec) bool success = true; success &= rtc.ListBegin(laser); success &= rtcMeasurement.ListMeasurementBegin(hz, channels); //1Khz, 4개 채널 success &= rtc.ListFrequency(50 * 1000, 2); // 주파수 50KHz, 펄스폭 2usec success &= rtc.ListSpeed(500, 500); // 점프, 마크 속도 500mm/s success &= rtc.ListDelay(10, 100, 200, 200, 0); // 스캐너/레이저 지연값 success &= rtc.ListJump(new Vector2(radius, 0)); //원 시작 위치 success &= rtc.ListArc(new Vector2(0, 0), 360.0f); // 360도 원 그리기 success &= rtcMeasurement.ListMeasurementEnd(); success &= rtc.ListEnd(); if (success) { success &= rtc.ListExecute(true); } var measurementFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plot", "measurement_circle.txt"); success &= MeasurementHelper.Save(measurementFile, rtcMeasurement, hz, channels, false); if (success) { Console.WriteLine($"Processing time = {timer.ElapsedMilliseconds / 1000.0:F3}s. plot to file = {measurementFile}"); } return(success); }
/// <summary> /// laser processing /// </summary> /// <param name="rtc"></param> /// <returns></returns> public override bool Mark(IRtc rtc) { if (this.Radius <= 0) { return(false); } bool success = true; ///translate circle's center rtc.Matrix.Push(this.X, this.Y); ///jump to start pos success &= rtc.ListJump(new Vector2((float)(this.Radius), 0.0f)); ///rotate 360 degress with CCW success &= rtc.ListArc(new Vector2(0.0f, 0.0f), 360.0); rtc.Matrix.Pop(); return(success); }
/// <summary> /// laser processing /// </summary> /// <param name="rtc"></param> /// <returns></returns> public override bool Mark(IRtc rtc) { if (this.Radius <= 0) { return(false); } bool success = true; ///translate arc's center rtc.Matrix.Push(this.X, this.Y); ///jump to start pos double x = this.Radius * Math.Sin(this.StartAngle * Math.PI / 180.0); double y = this.Radius * Math.Cos(this.SweepAngle * Math.PI / 180.0); success &= rtc.ListJump(new Vector2((float)x, (float)y)); success &= rtc.ListArc(new Vector2(0.0f, 0.0f), this.SweepAngle); ///revert matrix rtc.Matrix.Pop(); return(success); }
/// <summary> /// draw circle /// </summary> /// <param name="laser"></param> /// <param name="rtc"></param> /// <param name="radius"></param> private static bool DrawCircle(ILaser laser, IRtc rtc, float radius) { if (rtc.CtlGetStatus(RtcStatus.Busy)) { return(false); } Console.WriteLine("WARNING !!! LASER IS BUSY ... Draw Circle"); timer = Stopwatch.StartNew(); bool success = true; success &= rtc.ListBegin(laser); success &= rtc.ListJump(new Vector2(radius, 0)); success &= rtc.ListArc(new Vector2(0, 0), 360.0f); success &= rtc.ListEnd(); if (success) { success &= rtc.ListExecute(true); } Console.WriteLine($"Processing time = {timer.ElapsedMilliseconds / 1000.0:F3}s"); return(success); }
private static bool MotfWithCircleAndWaitEncoder(ILaser laser, IRtc rtc, bool externalStart) { var rtcMotf = rtc as IRtcMOTF; var rtcExtension = rtc as IRtcExtension; bool success = true; // 리스트 시작 success &= rtc.ListBegin(laser, ListType.Single); // 직선을 그립니다. (엔코더 입력과 무관합니다) success &= rtc.ListJump(new Vector2(0, 0)); success &= rtc.ListMark(new Vector2(0, 10)); // ListMOTFBegin 부터 ListMOTFEnd 사이의 모든 list 명령어는 엔코더증감값이 적용됩니다 success &= rtcMotf.ListMOTFBegin(); // 엔코더 X 값이 10mm 가 넘을때(Over) 까지 리스트 명령들이 모두 대기됨 success &= rtcMotf.ListMOTFWait(RtcEncoder.EncX, 10, EncoderWaitCondition.Over); // 엔코더 X 값이 위 조건을 만족한 이후 원 을 그린다 success &= rtc.ListJump(new Vector2((float)10, 0)); success &= rtc.ListArc(new Vector2(0, 0), 360.0f); // MOTF 중지및 0,0 위치(스캐너 중심 위치)로 jump 실시 success &= rtcMotf.ListMOTFEnd(Vector2.Zero); success &= rtc.ListEnd(); if (externalStart) { // RTC 15핀 커넥터에 있는 /START 을 리스트 시작 트리거로 사용합니다. var extCtrl = new Rtc5ExternalControlMode(); extCtrl.Add(Rtc5ExternalControlMode.Bit.ExternalStart); extCtrl.Add(Rtc5ExternalControlMode.Bit.ExternalStartAgain); rtcExtension.CtlExternalControl(extCtrl); } else { // 외부 트리거(/START) 미사용 rtcExtension.CtlExternalControl(Rtc5ExternalControlMode.Empty); if (success) { success &= rtc.ListExecute(); } } return(success); }