예제 #1
0
        static void Main(string[] args)
        {
            SpiralLab.Core.Initialize();

            #region initialize RTC
            var rtc = new RtcVirtual(0); ///create Rtc for dummy
            //var rtc = new Rtc5(0); ///create Rtc5 controller
            //var rtc = new Rtc6(0); ///create Rtc6 controller
            //var rtc = new Rtc6Ethernet(0, "192.168.0.200"); ///create Rtc6 ethernet controller
            //var rtc = new Rtc53D(0); ///create Rtc5 + 3D option controller
            //var rtc = new Rtc63D(0); ///create Rtc5 + 3D option controller
            //var rtc = new Rtc5DualHead(0); ///create Rtc5 + Dual head option controller
            //var rtc = new Rtc5MOTF(0); ///create Rtc5 + MOTF option controller
            //var rtc = new Rtc6MOTF(0); ///create Rtc6 + MOTF option controller
            //var rtc = new Rtc6SyncAxis(0, "syncAXISConfig.xml"); ///create Rtc6 + XL-SCAN (ACS+SYNCAXIS) option controller


            float fov            = 60.0f;                            /// scanner field of view : 60mm
            float kfactor        = (float)Math.Pow(2, 20) / fov;     /// k factor (bits/mm) = 2^20 / fov
            var   correctionFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "correction", "cor_1to1.ct5");
            rtc.Initialize(kfactor, LaserMode.Yag1, correctionFile); /// 스캐너 보정 파일 지정 : correction file
            rtc.CtlFrequency(50 * 1000, 2);                          /// laser frequency : 50KHz, pulse width : 2usec
            rtc.CtlSpeed(100, 100);                                  /// default jump and mark speed : 100mm/s
            rtc.CtlDelay(10, 100, 200, 200, 0);                      /// scanner and laser delays
            #endregion

            #region initialize Laser (virtial)
            ILaser laser = new LaserVirtual(0, "virtual", 20);  /// 최대 출력 20W 의 가상 레이저 소스 생성
            #endregion

            ConsoleKeyInfo key;
            do
            {
                Console.WriteLine("Testcase for spirallab.sirius. powered by [email protected] (https://sepwind.blogspot.com)");
                Console.WriteLine("");
                Console.WriteLine("'S' : get status");
                Console.WriteLine("'C' : draw circle");
                Console.WriteLine("'R' : draw rectangle");
                Console.WriteLine("'D' : draw circle with dots");
                Console.WriteLine("'Q' : quit");
                Console.WriteLine("");
                Console.Write("select your target : ");
                key = Console.ReadKey(false);
                if (key.Key == ConsoleKey.Q)
                {
                    break;
                }
                var timer = Stopwatch.StartNew();
                switch (key.Key)
                {
                case ConsoleKey.S:      ///RTC의 상태 확인
                    if (rtc.CtlGetStatus(RtcStatus.Busy))
                    {
                        Console.WriteLine($"\r\nRtc is busy!");
                    }
                    else if (!rtc.CtlGetStatus(RtcStatus.PowerOK))
                    {
                        Console.WriteLine($"\r\nScanner power is not ok");
                    }
                    else if (!rtc.CtlGetStatus(RtcStatus.PositionAckOK))
                    {
                        Console.WriteLine($"\r\nScanner position is not acked");
                    }
                    else if (!rtc.CtlGetStatus(RtcStatus.NoError))
                    {
                        Console.WriteLine($"\r\nRtc status has an error");
                    }
                    else
                    {
                        Console.WriteLine($"\r\nIt's okay");
                    }
                    break;

                case ConsoleKey.C:      /// 원 모양 가공
                    Console.WriteLine("\r\nWARNING !!! LASER IS BUSY ...");
                    DrawCircle(laser, rtc, 10);
                    break;

                case ConsoleKey.R:      /// 사각형 모양 가공
                    Console.WriteLine("\r\nWARNING !!! LASER IS BUSY ...");
                    DrawRectangle(laser, rtc, 10, 10);
                    break;

                case ConsoleKey.D:      ///점으로 이루어진 원 모양 가공
                    Console.WriteLine("\r\nWARNING !!! LASER IS BUSY ...");
                    DrawCircleWithDots(laser, rtc, 10, 1.0f);
                    break;
                }
                Console.WriteLine($"Processing time = {timer.ElapsedMilliseconds/1000.0:F3}s");
            } while (true);

            rtc.Dispose();
        }