Exemplo n.º 1
0
        // User callback function (C# thread)
        private void CallbackThread(object tParam)
        {
            try
            {
                // Get Mutex lock for Marshal.Copy()
                this.MarshalCopyMutex.WaitOne();

                // Parameter for delegate
                ThreadParam Param = new ThreadParam();

                Param.eventID = ((ThreadParam)tParam).eventID;
                Param.eventData = ((ThreadParam)tParam).eventData;
                Param.userData = ((ThreadParam)tParam).userData;

                EVENTDATA ev = new EVENTDATA();
                FPD_ALARM fa = new FPD_ALARM();
                Byte[] imagePtr = null;

                // Thumbnail image collected
                // Full image collected
                if ((TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_EXP_IMG_THUMB == (TETD_EVENT_CALLBACK_ENUM)Param.eventID) ||
                    (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_EXP_IMG_FULL == (TETD_EVENT_CALLBACK_ENUM)Param.eventID))
                {
                    ev = (EVENTDATA)Marshal.PtrToStructure(Param.eventData, typeof(EVENTDATA));
                    imagePtr = new Byte[ev.myEventData[2]];

                    Marshal.Copy((IntPtr)ev.myEventData[1], imagePtr, 0, imagePtr.Length);
                }
                // Normal event
                if ((TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_FPD_ALARM != (TETD_EVENT_CALLBACK_ENUM)Param.eventID) &&
                    (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_FPD_REBOOT_ERROR != (TETD_EVENT_CALLBACK_ENUM)Param.eventID))
                {
                    ev = (EVENTDATA)Marshal.PtrToStructure(Param.eventData, typeof(EVENTDATA));
                }
                // Alarm from FPD
                else
                {
                    fa = (FPD_ALARM)Marshal.PtrToStructure(Param.eventData, typeof(FPD_ALARM));
                }

                // Delegate for other thread
                this.BeginInvoke(this.CallbackFromFPD_Delegate, Param.eventID, Param.eventData, Param.userData, ev, fa, imagePtr);

                // Release Mutex lock for Marshal.Copy()
                this.MarshalCopyMutex.ReleaseMutex();
            }
            catch
            {
            }
        }
Exemplo n.º 2
0
        private void CallbackFromFPD_Exec(Int32 eventID, IntPtr eventData, IntPtr userData, EVENTDATA ev, FPD_ALARM fa, Byte[] imagePtr)
        {
            try
            {
                // Thumbnail image collected
                // Full image collected
                if ((TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_EXP_IMG_THUMB == (TETD_EVENT_CALLBACK_ENUM)eventID) ||
                    (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_EXP_IMG_FULL == (TETD_EVENT_CALLBACK_ENUM)eventID))
                {
                    SaveImgFromFDX4343R_New(imagePtr);

                }
                // Image process completed
                else if (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_EXP_COMPLETE == (TETD_EVENT_CALLBACK_ENUM)eventID)
                {
                    this.ExposureMode = SINGLE_EXPOSURE;
                    //this.btn_ToDouble.Text = "To Double";

                    // Set Exposure mode
                    //              if (CInterfaceLower.E_ERR_TETD_CONTROLLER_ENUM.TETD_OK == this.cIfLower.TetdFpdExposureMode(this.ExposureMode))
                    //              {
                    if (SOFT_EXPOSURE == this.ExposureRequestSwitch)
                    {
                        // Enable Exposure button
                        //this.btn_Exposure.Enabled = true;
                    }
                    else
                    {
                        AppLogger.LogAction.ShowEventStatus(lblFPDStatus, "Sẵn sàng chụp");
                        // External trigger enabled
                        this.cLog.WriteLine("Ready to Exposure");
                    }
                    //              }
                }
                // External trigger received
                else if (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_EXP_REQ_EXTERNAL_NOTIFTY == (TETD_EVENT_CALLBACK_ENUM)eventID)
                {
                    // If calibration callback function is registered
                    if (null != this.calilbCallBack)
                    {
                        // Call calibration callback function
                        this.calilbCallBack(eventID, eventData, userData, ev);
                    }
                    else
                    {
                        // Exposure button clicked
                        if (HARD_EXPOSURE == this.ExposureRequestSwitch)
                        {
                            Exposure();
                        }
                    }
                }
                // Normal event
                if ((TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_FPD_ALARM != (TETD_EVENT_CALLBACK_ENUM)eventID) &&
                    (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_FPD_REBOOT_ERROR != (TETD_EVENT_CALLBACK_ENUM)eventID))
                {
                    // Update Callback Event text box
                    // Get Mutex lock for this.txt_CallbackEvent
                    this.txt_CallbackMutex.WaitOne();

                    // Begin with current time
                    if ((TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_OFFSET_PROGRESS == (TETD_EVENT_CALLBACK_ENUM)eventID) ||
                        (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_OFFSET_COMPLETE == (TETD_EVENT_CALLBACK_ENUM)eventID))
                    {
                         }
                    else
                    {
                        }

                   

                    // Release Mutex lock for this.txt_CallbackEvent
                    this.txt_CallbackMutex.ReleaseMutex();

                    // If calibration callback function is registered
                    if ((null != this.calilbCallBack) &&
                       ((TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_OFFSET_PROGRESS == (TETD_EVENT_CALLBACK_ENUM)eventID) ||
                        (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_OFFSET_COMPLETE == (TETD_EVENT_CALLBACK_ENUM)eventID) ||
                        (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_FLATNESS_CHECK == (TETD_EVENT_CALLBACK_ENUM)eventID)))
                    {
                        // Call calibration callback function
                        this.calilbCallBack(eventID, eventData, userData, ev);
                    }
                }
                // Alarm from FPD
                else
                {
                 
                    // Begin with current time
                    AppLogger.LogAction.AddLog2List(lstFPD560, DateTime.Now.ToString("HH:mm:ss.fff") + " " + ((TETD_EVENT_CALLBACK_ENUM)eventID).ToString() +
                         " " + ((CInterfaceLower.E_ERR_TETD_CONTROLLER_ENUM)fa.ev).ToString());

                  

                  
                    // Release Mutex lock for this.txt_CallbackEvent
                    this.txt_CallbackMutex.ReleaseMutex();
                    // Convert FPD status information to CCondition class
                    CCondition cCondition = new CCondition(fa.fc);

                    // Update Status
                   AppLogger.LogAction.ShowEventStatus(lblFPDStatus, cCondition.fpdStatus.ToString());
                  

                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 3
0
        private void CallbackFromFPD_Exec(Int32 eventID, IntPtr eventData, IntPtr userData, EVENTDATA ev, FPD_ALARM fa, Byte[] imagePtr)
        {
            try
            {
                // Thumbnail image collected
                // Full image collected
                if ((TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_EXP_IMG_THUMB == (TETD_EVENT_CALLBACK_ENUM)eventID) ||
                    (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_EXP_IMG_FULL == (TETD_EVENT_CALLBACK_ENUM)eventID))
                {
                    SaveImgFromFDX4343R_New(imagePtr);
                   
                }
                // Image process completed
                else if (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_EXP_COMPLETE == (TETD_EVENT_CALLBACK_ENUM)eventID)
                {
                    this.ExposureMode = SINGLE_EXPOSURE;
                    //this.btn_ToDouble.Text = "To Double";

                    // Set Exposure mode
                    //              if (CInterfaceLower.E_ERR_TETD_CONTROLLER_ENUM.TETD_OK == this.cIfLower.TetdFpdExposureMode(this.ExposureMode))
                    //              {
                    if (SOFT_EXPOSURE == this.ExposureRequestSwitch)
                    {
                        // Enable Exposure button
                        //this.btn_Exposure.Enabled = true;
                    }
                    else
                    {
                        // External trigger enabled
                        this.cLog.WriteLine("Ready to Exposure");
                    }
                    //              }
                }
                // External trigger received
                else if (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_EXP_REQ_EXTERNAL_NOTIFTY == (TETD_EVENT_CALLBACK_ENUM)eventID)
                {
                    // If calibration callback function is registered
                    if (null != this.calilbCallBack)
                    {
                        // Call calibration callback function
                        this.calilbCallBack(eventID, eventData, userData, ev);
                    }
                    else
                    {
                        // Exposure button clicked
                        if (HARD_EXPOSURE == this.ExposureRequestSwitch)
                        {
                            //this.btn_Exposure_Click(null, null);
                        }
                    }
                }
                // Normal event
                if ((TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_FPD_ALARM != (TETD_EVENT_CALLBACK_ENUM)eventID) &&
                    (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_FPD_REBOOT_ERROR != (TETD_EVENT_CALLBACK_ENUM)eventID))
                {
                    // Update Callback Event text box
                    // Get Mutex lock for this.txt_CallbackEvent
                    this.txt_CallbackMutex.WaitOne();

                    // Begin with current time
                    if ((TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_OFFSET_PROGRESS == (TETD_EVENT_CALLBACK_ENUM)eventID) ||
                        (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_OFFSET_COMPLETE == (TETD_EVENT_CALLBACK_ENUM)eventID))
                    {
                        AppLogger.LogAction.AddLog2List(lstFPD560, DateTime.Now.ToString("HH:mm:ss.fff") + " " + ((TETD_EVENT_CALLBACK_ENUM)eventID).ToString() +
                             " " + ((CInterfaceLower.E_ERR_TETD_CONTROLLER_ENUM)ev.myEventData[0]).ToString() + " " + ev.myEventData[1].ToString());
                    }
                    else
                    {
                        AppLogger.LogAction.AddLog2List(lstFPD560, DateTime.Now.ToString("HH:mm:ss.fff") + " " + ((TETD_EVENT_CALLBACK_ENUM)eventID).ToString() +
                             " " + ((CInterfaceLower.E_ERR_TETD_CONTROLLER_ENUM)ev.myEventData[0]).ToString());
                    }

                    // Move to end
                    //this.txt_CallbackEvent.SelectionStart = this.txt_CallbackEvent.Text.Length;
                    //this.txt_CallbackEvent.Focus();
                    //this.txt_CallbackEvent.ScrollToCaret();

                    // Release Mutex lock for this.txt_CallbackEvent
                    this.txt_CallbackMutex.ReleaseMutex();

                    // If calibration callback function is registered
                    if ((null != this.calilbCallBack) &&
                       ((TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_OFFSET_PROGRESS == (TETD_EVENT_CALLBACK_ENUM)eventID) ||
                        (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_OFFSET_COMPLETE == (TETD_EVENT_CALLBACK_ENUM)eventID) ||
                        (TETD_EVENT_CALLBACK_ENUM.TETD_EVENT_FLATNESS_CHECK == (TETD_EVENT_CALLBACK_ENUM)eventID)))
                    {
                        // Call calibration callback function
                        this.calilbCallBack(eventID, eventData, userData, ev);
                    }
                }
                // Alarm from FPD
                else
                {
                    // Update Callback Event text box
                    // Get Mutex lock for this.txt_CallbackEvent
                    this.txt_CallbackMutex.WaitOne();

                    // Begin with current time
                    AppLogger.LogAction.AddLog2List(lstFPD560, DateTime.Now.ToString("HH:mm:ss.fff") + " " + ((TETD_EVENT_CALLBACK_ENUM)eventID).ToString() +
                         " " + ((CInterfaceLower.E_ERR_TETD_CONTROLLER_ENUM)fa.ev).ToString());

                    // Move to end
                    //this.txt_CallbackEvent.SelectionStart = this.txt_CallbackEvent.Text.Length;
                    //this.txt_CallbackEvent.Focus();
                    //this.txt_CallbackEvent.ScrollToCaret();

                    // Release Mutex lock for this.txt_CallbackEvent
                    this.txt_CallbackMutex.ReleaseMutex();

                    // Convert FPD status information to CCondition class
                    CCondition cCondition = new CCondition(fa.fc);

                    // Update Status
                    AppLogger.LogAction.ShowEventStatus(lblFPDStatus, cCondition.fpdStatus.ToString());
                    //this.txt_ShotReq.Text = cCondition.shotReq.ToString();
                    //this.txt_MicroSD.Text = cCondition.microSD.ToString();
                    //this.txt_ShotMode.Text = cCondition.shotMode.ToString();
                    //this.txt_EEPROM.Text = cCondition.eeprom.ToString();
                    //this.txt_PSave.Text = cCondition.powerSave.ToString();
                    //this.txt_Port.Text = cCondition.port.ToString();
                    //this.txt_PictBufNo.Text = cCondition.pictBufNo.ToString();

                    //// Update Temp
                    //this.txt_PwrbdTmp1.Text = cCondition.pwrbdTmp1.ToString();
                    //this.txt_PwrbdTmp2.Text = cCondition.pwrbdTmp2.ToString();
                    //this.txt_DtbdTmp1.Text = cCondition.dtbdTmp1.ToString();
                    //this.txt_DtbdTmp2.Text = cCondition.dtbdTmp2.ToString();

                    //// Update Voltage
                    //this.txt_TftOn.Text = cCondition.tftOn.ToString();
                    //this.txt_TftOff.Text = cCondition.tftOff.ToString();
                    //this.txt_Pd.Text = cCondition.pd.ToString();

                    //// Paint in White
                    //this.txt_EEPROM.BackColor = Color.White;
                    //this.txt_PwrbdTmp1.BackColor = Color.White;
                    //this.txt_PwrbdTmp2.BackColor = Color.White;
                    //this.txt_DtbdTmp1.BackColor = Color.White;
                    //this.txt_DtbdTmp2.BackColor = Color.White;
                    //this.txt_TftOn.BackColor = Color.White;
                    //this.txt_TftOff.BackColor = Color.White;
                    //this.txt_Pd.BackColor = Color.White;

                    //// Paint Error in HotPink
                    //if (this.txt_EEPROM.Text == "Error")
                    //{
                    //    this.txt_EEPROM.BackColor = Color.HotPink;
                    //}
                    //if (this.txt_PwrbdTmp1.Text == "Error")
                    //{
                    //    this.txt_PwrbdTmp1.BackColor = Color.HotPink;
                    //}
                    //if (this.txt_PwrbdTmp2.Text == "Error")
                    //{
                    //    this.txt_PwrbdTmp2.BackColor = Color.HotPink;
                    //}
                    //if (this.txt_DtbdTmp1.Text == "Error")
                    //{
                    //    this.txt_DtbdTmp1.BackColor = Color.HotPink;
                    //}
                    //if (this.txt_DtbdTmp2.Text == "Error")
                    //{
                    //    this.txt_DtbdTmp2.BackColor = Color.HotPink;
                    //}
                    //if (this.txt_TftOn.Text == "Error")
                    //{
                    //    this.txt_TftOn.BackColor = Color.HotPink;
                    //}
                    //if (this.txt_TftOff.Text == "Error")
                    //{
                    //    this.txt_TftOff.BackColor = Color.HotPink;
                    //}
                    //if (this.txt_Pd.Text == "Error")
                    //{
                    //    this.txt_Pd.BackColor = Color.HotPink;
                    //}
                }
            }
            catch(Exception ex)
            {
            }
        }