Ejemplo n.º 1
0
        public bool Initialize(double kFactor, LaserMode laserMode, string ctbFileName)
        {
            Debug.Assert(kFactor > 0);
            RTC5Wrap.n_stop_execution(this.Index + 1);
            uint error      = RTC5Wrap.n_load_program_file(this.Index + 1, string.Empty);
            uint cardCnt    = RTC5Wrap.rtc5_count_cards();
            uint dllVersion = RTC5Wrap.get_dll_version();
            uint hexVersion = RTC5Wrap.get_hex_version();
            uint rtcVersion = RTC5Wrap.get_rtc_version();
            uint lastError  = RTC5Wrap.n_get_last_error(this.Index + 1);
            uint serialNo   = RTC5Wrap.n_get_serial_number(this.Index + 1);

            this.kFactor = kFactor;
            ///active high
            RTC5Wrap.n_set_laser_control(this.Index + 1, 0);

            if (!this.CtlLoadCorrectionFile(CorrectionTableIndex.Table1, ctbFileName))
            {
                return(false);
            }
            if (!this.CtlSelectCorrection(CorrectionTableIndex.Table1))
            {
                return(false);
            }
            RTC5Wrap.n_config_list(this.Index + 1, 4_000 * 2, 4_000 * 2);
            RTC5Wrap.n_set_laser_mode(this.Index + 1, (uint)laserMode);
            RTC5Wrap.n_set_firstpulse_killer(this.Index + 1, 0);
            RTC5Wrap.n_set_standby(this.Index + 1, 0, 0);
            return(true);
        }
Ejemplo n.º 2
0
 // reset to the presumed Peripheral defaults
 void reset()
 {
     type         = LaserType.NORMAL;
     mode         = LaserMode.MANUAL;
     enabled      = false;
     watchdogSec  = 10;
     laserDelayMS = 500;
     dump();
 }
Ejemplo n.º 3
0
        public override bool Initialize(double kFactor, LaserMode laserMode, string ctbFileName)
        {
            Debug.Assert(base.kFactor > 0);
            uint result = RTC6Wrap.init_rtc6_dll();

            RTC6Wrap.eth_set_search_cards_timeout(200 * 1000);
            result = RTC6Wrap.eth_search_cards(
                RTC6Wrap.eth_convert_string_to_ip(this.ipAddress.ToString()),
                RTC6Wrap.eth_convert_string_to_ip(this.subNetMask.ToString()));
            int assign_result = RTC6Wrap.eth_assign_card_ip(
                RTC6Wrap.eth_convert_string_to_ip(this.ipAddress.ToString()),
                base.Index + 1);

            if (base.Index + 1 != assign_result)
            {
                return(false);
            }

            RTC6Wrap.n_stop_execution(base.Index + 1);
            uint error      = RTC6Wrap.n_load_program_file(base.Index + 1, string.Empty);
            uint cardCnt    = RTC6Wrap.rtc6_count_cards();
            uint dllVersion = RTC6Wrap.get_dll_version();
            uint hexVersion = RTC6Wrap.get_hex_version();
            uint rtcVersion = RTC6Wrap.get_rtc_version();

            uint lastError = RTC6Wrap.n_get_last_error(base.Index + 1);

            base.kFactor = kFactor;
            ///active high
            RTC6Wrap.n_set_laser_control(this.Index + 1, 0);

            if (!this.CtlLoadCorrectionFile(CorrectionTableIndex.Table1, ctbFileName))
            {
                return(false);
            }
            if (!this.CtlSelectCorrection(CorrectionTableIndex.Table1))
            {
                return(false);
            }
            RTC6Wrap.n_config_list(this.Index + 1, 4000 * 2, 4000 * 2);
            RTC6Wrap.n_set_laser_mode(this.Index + 1, (uint)laserMode);
            RTC6Wrap.n_set_firstpulse_killer(this.Index + 1, 0);
            RTC6Wrap.n_set_standby(this.Index + 1, 0, 0);
            return(true);
        }
Ejemplo n.º 4
0
        private bool SiriusLibInit()
        {
            // 기본 문서 생성
            var doc = new Sirius.DocumentDefault();

            this.FormAuto.SiriusViewer.Document   = doc;
            this.FormEditor.SiriusEditor.Document = doc;
            // 소스 문서(IDocument) 가 변경될경우 다른 멀티 뷰에 이를 통지하는 이벤트 핸들러 등록
            this.FormEditor.SiriusEditor.OnDocumentSourceChanged += SiriusEditorForm_OnDocumentSourceChanged;

            bool success = true;

            #region RTC 초기화
            uint i = 0;
            //var rtcCounts = NativeMethods.ReadIni<int>(Program.ConfigFileName, "RTC", "COUNTS");
            //for (uint i = 0; i < rtcCounts; i++)
            //{
            var  rtcTypeName = NativeMethods.ReadIni <string>(ConfigFileName, $"RTC{i}", "TYPE");
            Type rtcType     = Type.GetType(rtcTypeName.Trim());
            if (null == rtcType)
            {
                var mb = new Default.MessageBoxOk();
                mb.ShowDialog("Critical", $"Can't create rtc instance : {rtcType.ToString()} at {ConfigFileName}");
                success &= false;
            }
            var rtc     = Activator.CreateInstance(rtcType) as IRtc;
            var rtcName = NativeMethods.ReadIni <string>(ConfigFileName, $"RTC{i}", "NAME");
            rtc.Name  = rtcName;
            rtc.Index = i;
            var       kFactor           = NativeMethods.ReadIni <float>(ConfigFileName, $"RTC{i}", "KFACTOR");
            var       ct5FileName       = NativeMethods.ReadIni <string>(ConfigFileName, $"RTC{i}", "CORRECTION");
            var       laserModeTypeName = NativeMethods.ReadIni <string>(ConfigFileName, $"RTC{i}", "LASERMODE");
            LaserMode laserMode         = (LaserMode)Enum.Parse(typeof(LaserMode), laserModeTypeName.Trim());
            success &= rtc.Initialize(kFactor, laserMode, ct5FileName);
            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

            this.FormEditor.SiriusEditor.Rtc = rtc;
            //}
            #endregion

            #region 레이저 소스 초기화
            //var laserCounts = NativeMethods.ReadIni<int>(Program.ConfigFileName, "LASER", "COUNTS");
            //for (uint i = 0; i < laserCounts; i++)
            //{
            var  laserTypeName = NativeMethods.ReadIni <string>(ConfigFileName, $"LASER{i}", "TYPE");
            Type laserType     = Type.GetType(laserTypeName.Trim());
            if (null == laserType)
            {
                var mb = new Default.MessageBoxOk();
                mb.ShowDialog("Critical", $"Can't create laser instance : {laserType.ToString()} at {ConfigFileName}");
                success &= false;
            }
            var laser = Activator.CreateInstance(laserType) as ILaser;
            //ILaser laser = new Sirius.LaserVirtual(0, "virtual", 20.0f);
            var laserName = NativeMethods.ReadIni <string>(ConfigFileName, $"LASER{i}", "NAME");
            laser.Rtc   = rtc;
            laser.Index = i;
            laser.Name  = laserName;
            var maxPower = NativeMethods.ReadIni <float>(ConfigFileName, $"LASER{i}", "MAXPOWER");
            laser.MaxPowerWatt = maxPower;
            success           &= laser.Initialize();
            var powerControl = laser as IPowerControl;
            if (null != powerControl)
            {
                success &= powerControl.CtlPower(10);
            }

            this.FormEditor.SiriusEditor.Laser = laser;
            //}
            this.FormEditor.SiriusEditor.Laser = laser;
            #endregion

            #region 마커 지정
            var marker = new MarkerDefault(0);
            this.FormEditor.SiriusEditor.Marker = marker;
            #endregion
            return(success);
        }
Ejemplo n.º 5
0
 public bool Initialize(float kFactor, LaserMode laserMode, string ctbFileName)
 {
     Debug.Assert(kFactor > 0);
     return(true);
 }
Ejemplo n.º 6
0
        // Parse and validate a 6-byte payload received from Peripheral by Central.
        //
        // If any part of the payload does not pass validation, the entire payload
        // is rejected and application state is unchanged.
        public bool parse(byte[] data)
        {
            if (data.Length != 6)
            {
                logger.error($"rejecting LaserState with invalid payload length {data.Length}");
                return(false);
            }

            ////////////////////////////////////////////////////////////////////
            // Laser Type
            ////////////////////////////////////////////////////////////////////

            LaserType newType = LaserType.NORMAL;
            byte      value   = data[0];

            if (value < (byte)LaserType.MAX_LASER_TYPES)
            {
                newType = (LaserType)value;
            }
            else
            {
                logger.error($"rejecting LaserState with invalid LaserType {value}");
                return(false);
            }

            ////////////////////////////////////////////////////////////////////
            // Laser Mode
            ////////////////////////////////////////////////////////////////////

            LaserMode newMode = LaserMode.MANUAL;

            value = data[1];
            if (value < (byte)LaserMode.MAX_LASER_MODES)
            {
                newMode = (LaserMode)value;
            }
            else
            {
                logger.error($"rejecting LaserState with invalid LaserMode 0x{value:x2}");
                return(false);
            }

            ////////////////////////////////////////////////////////////////////
            // Laser Enabled
            ////////////////////////////////////////////////////////////////////

            bool newEnabled = false;

            value = data[2];
            if (value < 0x02)
            {
                newEnabled = value == 0x01;
            }
            else
            {
                logger.error($"rejecting LaserState with invalid LaserEnabled 0x{value:x2}");
                return(false);
            }

            ////////////////////////////////////////////////////////////////////
            // Laser Watchdog
            ////////////////////////////////////////////////////////////////////

            byte newWatchdog = 0;

            value = data[3];
            if (value < 0xff)
            {
                newWatchdog = value;
            }
            else
            {
                logger.error($"rejecting LaserState with invalid LaserWatchdog 0x{value:x2}");
                return(false);
            }

            ////////////////////////////////////////////////////////////////////
            // Laser Delay
            ////////////////////////////////////////////////////////////////////


            ushort newLaserDelayMS = (ushort)((data[4] << 8) | data[5]);

            ////////////////////////////////////////////////////////////////////
            // all fields validated, accept new values
            ////////////////////////////////////////////////////////////////////

            type         = newType;
            enabled      = newEnabled;
            watchdogSec  = newWatchdog;
            laserDelayMS = newLaserDelayMS;

            if (!SW_RAMAN_MODE)
            {
                mode = newMode;
            }

            dump();

            return(true);
        }