Basic Image AlgorithmS Library 2.8.0

wxTauControlFrame.cpp

00001 #include "wxTauControlFrame.h"
00002 #ifdef WIN32
00003 #include <windows.h>
00004 #endif
00005 #include <Base/Common/W32Compat.hh>
00006 #include <Gui/StringConv.hh>
00007 #include <wx/msgdlg.h>
00008 #include <iostream>
00009 #include <sstream>
00010 
00011 using namespace BIAS;
00012 using namespace std;
00013 
00014 wxTauControlFrame::wxTauControlFrame( wxWindow* parent )
00015 :
00016 wxTauControlFrameInterface( parent )
00017 {
00018   m_notebook1->Enable(false);
00019   wxString text= wxT("Not Connected!");
00020   SetStatusText(text, 0);
00021 #ifdef WIN32
00022   m_textCtrlDevice->SetValue(AsciiToWx("COM0"));
00023 #endif
00024 }
00025 
00026 void wxTauControlFrame::OnSetFFC( wxCommandEvent& event )
00027 {
00028     if(!serialFlirControl_.IsConnected()) return;
00029   //0 = manual, 1= auto, 2= external
00030     int sel = m_radioBoxFFC->GetSelection();
00031   int ffcInterval = atoi(m_textFFCInterval->GetValue().ToAscii());
00032   int ffcTmpChange = atoi(m_textCtrlTempChange->GetValue().ToAscii());
00033   int ffcLGInterval = atoi(m_textCtrlLGFFCInt->GetValue().ToAscii());
00034   int ffcLGTmpChange = atoi(m_textCtrlLGTC->GetValue().ToAscii());
00035   //mode
00036     FLIR_STATUS_MESSAGE ret = serialFlirControl_.SetFFCMode(sel);
00037     if(ret != CAM_OK){
00038         biasusleep(500);
00039         ret = serialFlirControl_.SetFFCMode(sel);
00040         if(ret != CAM_OK){
00041             wxString text= wxT("Failed, try again!");
00042             SetStatusText(text, 0);
00043         }
00044     }
00045   //interval
00046   ret = serialFlirControl_.SetFFCInterval(ffcInterval,ffcLGInterval);
00047     if(ret != CAM_OK){
00048         biasusleep(500);
00049         ret = serialFlirControl_.SetFFCInterval(ffcInterval,ffcLGInterval);
00050         if(ret != CAM_OK){
00051             wxString text= wxT("Failed, try again!");
00052             SetStatusText(text, 0);
00053         }
00054     }
00055   //temp change
00056   ret = serialFlirControl_.SetFFCTempChange(ffcTmpChange,ffcLGTmpChange);
00057     if(ret != CAM_OK){
00058         biasusleep(500);
00059         ret = serialFlirControl_.SetFFCTempChange(ffcTmpChange,ffcLGTmpChange);
00060         if(ret != CAM_OK){
00061             wxString text= wxT("Failed, try again!");
00062             SetStatusText(text, 0);
00063         }
00064     }
00065 }
00066 
00067 void wxTauControlFrame::OnOperationMode( wxCommandEvent& event )
00068 {
00069     if(!serialFlirControl_.IsConnected()) return;
00070     int sel = event.GetInt();
00071     if(sel == 0) sel = 0; //real time
00072     if(sel == 1) sel = 1; //frozen
00073     else sel = 0; //real time
00074     FLIR_STATUS_MESSAGE ret = serialFlirControl_.SetVideoMode(sel);
00075     if(ret != CAM_OK){
00076         biasusleep(500);
00077         ret = serialFlirControl_.SetVideoMode(sel);
00078         if(ret != CAM_OK){
00079             wxString text= wxT("Failed, try again!");
00080             SetStatusText(text, 0);
00081         }
00082     }
00083 }
00084 
00085 void wxTauControlFrame::OnTestPattern( wxCommandEvent& event )
00086 {
00087     // TODO: Implement OnTestPattern
00088 }
00089 
00090 void wxTauControlFrame::OnExternalSync( wxCommandEvent& event )
00091 {
00092     if(!serialFlirControl_.IsConnected()) return;
00093     int sel = event.GetInt();
00094   //Disable=0, slave=1, master=2
00095     FLIR_STATUS_MESSAGE ret = serialFlirControl_.SetExternalSync(sel);
00096     if(ret != CAM_OK){
00097         biasusleep(500);
00098         ret = serialFlirControl_.SetExternalSync(sel);
00099     }
00100    if(ret == CAM_OK){
00101         wxString text= wxT("Set external sync mode.");
00102         SetStatusText(text, 0);
00103     }
00104     else{
00105         stringstream txt; txt<<"Could not set external sync:";
00106         txt<<serialFlirControl_.StatusCodeToString(ret);
00107         wxString text= AsciiToWx(txt.str());
00108         SetStatusText(text, 0);
00109     }
00110 }
00111 
00112 void wxTauControlFrame::OnGainMode( wxCommandEvent& event )
00113 {
00114     if(!serialFlirControl_.IsConnected()) return;
00115     int sel = event.GetInt();
00116   //Auto=0, Low=1, High=2, Manual=3
00117     FLIR_STATUS_MESSAGE ret = serialFlirControl_.SetGainMode(sel);
00118     if(ret != CAM_OK){
00119         biasusleep(500);
00120         ret = serialFlirControl_.SetGainMode(sel);
00121     }
00122   if(ret == CAM_OK){
00123         wxString text= wxT("Set gain mode.");
00124         SetStatusText(text, 0);
00125     }
00126     else{
00127         stringstream txt; txt<<"Could not set gain mode:";
00128         txt<<serialFlirControl_.StatusCodeToString(ret);
00129         wxString text= AsciiToWx(txt.str());
00130         SetStatusText(text, 0);
00131     }
00132 }
00133 
00134 void wxTauControlFrame::OnReset( wxCommandEvent& event )
00135 {
00136     if(!serialFlirControl_.IsConnected()) return;
00137     FLIR_STATUS_MESSAGE ret = serialFlirControl_.SetDefaults();
00138     if(ret != CAM_OK){
00139         biasusleep(500);
00140         ret = serialFlirControl_.SetDefaults();
00141     }
00142     if(ret == CAM_OK){
00143         wxString text= wxT("Reset Camera.");
00144         SetStatusText(text, 0);
00145     }
00146     else{
00147         stringstream txt; txt<<"Could not reset camera:";
00148         txt<<serialFlirControl_.StatusCodeToString(ret);
00149         wxString text= AsciiToWx(txt.str());
00150         SetStatusText(text, 0);
00151     }
00152 }
00153 
00154 void wxTauControlFrame::OnOrientation( wxCommandEvent& event )
00155 {
00156     if(!serialFlirControl_.IsConnected()) return;
00157     int sel = event.GetInt();
00158     cout<<"Orientation selection:"<<sel<<endl;
00159     FLIR_STATUS_MESSAGE ret = serialFlirControl_.SetVideoOrientation(sel);
00160     if(ret != CAM_OK){
00161         biasusleep(500);
00162         ret = serialFlirControl_.SetVideoOrientation(sel);
00163     }
00164     if(ret == CAM_OK){
00165         wxString text= wxT("Set Orientation.");
00166         SetStatusText(text, 0);
00167     }
00168     else{
00169         stringstream txt; txt<<"Could not set orientation:";
00170         txt<<serialFlirControl_.StatusCodeToString(ret);
00171         wxString text= AsciiToWx(txt.str());
00172         SetStatusText(text, 0);
00173     }
00174 }
00175 
00176 void wxTauControlFrame::OnPolarity( wxCommandEvent& event )
00177 {
00178     if(!serialFlirControl_.IsConnected()) return;
00179     FLIR_STATUS_MESSAGE ret = serialFlirControl_.SetColoring(m_choicePolarity->GetSelection());
00180     if(ret != CAM_OK){
00181         biasusleep(500);
00182         ret = serialFlirControl_.SetColoring(m_choicePolarity->GetSelection());
00183     }
00184     if(ret == CAM_OK){
00185         wxString text= wxT("Set Polarity.");
00186         SetStatusText(text, 0);
00187     }
00188     else{
00189         stringstream txt; txt<<"Could not set polarity:";
00190         txt<<serialFlirControl_.StatusCodeToString(ret);
00191         wxString text= AsciiToWx(txt.str());
00192         SetStatusText(text, 0);
00193     }
00194 }
00195 
00196 void wxTauControlFrame::OnZoom( wxCommandEvent& event )
00197 {
00198     if(!serialFlirControl_.IsConnected()) return;
00199     int sel = event.GetInt();
00200     if(sel == 0) sel = 0; //no zoom
00201     if(sel == 1) sel = 4; //2x zoom
00202     if(sel == 2) sel = 8; //4x zoom
00203     FLIR_STATUS_MESSAGE ret = serialFlirControl_.SetVideoMode(sel);
00204     if(ret != CAM_OK){
00205         biasusleep(500);
00206         ret = serialFlirControl_.SetVideoMode(sel);
00207     }
00208     if(ret == CAM_OK){
00209         wxString text= wxT("Set Zoom.");
00210         SetStatusText(text, 0);
00211     }
00212     else{
00213         stringstream txt; txt<<"Could not set zoom:";
00214         txt<<serialFlirControl_.StatusCodeToString(ret);
00215         wxString text= AsciiToWx(txt.str());
00216         SetStatusText(text, 0);
00217 
00218     }
00219 }
00220 
00221 void wxTauControlFrame::OnFFCWarning( wxCommandEvent& event )
00222 {
00223     // TODO: Implement OnFFCWarning
00224 }
00225 
00226 void wxTauControlFrame::OnScrollDDE( wxScrollEvent& event )
00227 {
00228     // TODO: Implement OnScrollDDE
00229 }
00230 
00231 void wxTauControlFrame::OnVideoStandard( wxCommandEvent& event )
00232 {
00233     if(!serialFlirControl_.IsConnected()) return;
00234     int sel = event.GetInt();
00235 
00236     FLIR_STATUS_MESSAGE ret = serialFlirControl_.SetVideoStandard(sel);
00237     if(ret != CAM_OK){
00238         biasusleep(500);
00239         ret = serialFlirControl_.SetVideoStandard(sel);
00240     }
00241     if(ret == CAM_OK){
00242         wxString text= wxT("Set Video Standard.");
00243         SetStatusText(text, 0);
00244     }
00245     else{
00246         stringstream txt; txt<<"Could not set video standard:";
00247         txt<<serialFlirControl_.StatusCodeToString(ret);
00248         wxString text= AsciiToWx(txt.str());
00249         SetStatusText(text, 0);
00250     }
00251 }
00252 
00253 void wxTauControlFrame::OnAlgorithm( wxCommandEvent& event )
00254 {
00255 if(!serialFlirControl_.IsConnected()) return;
00256     int sel = event.GetInt();
00257 
00258     FLIR_STATUS_MESSAGE ret = serialFlirControl_.SetAGCAlgorithm(sel);
00259     if(ret != CAM_OK){
00260         biasusleep(500);
00261         ret = serialFlirControl_.SetAGCAlgorithm(sel);
00262     }
00263     if(ret == CAM_OK){
00264         wxString text= wxT("Set AGC Algorithm.");
00265         SetStatusText(text, 0);
00266     }
00267     else{
00268     stringstream txt; txt<<"Could not set AGC Algorithm :";
00269         txt<<serialFlirControl_.StatusCodeToString(ret);
00270         wxString text= AsciiToWx(txt.str());
00271         SetStatusText(text, 0);
00272     }
00273 }
00274 
00275 void wxTauControlFrame::OnPlateauValue( wxCommandEvent& event )
00276 {
00277     // TODO: Implement OnPlateauValue
00278 }
00279 
00280 void wxTauControlFrame::OnMaxGain( wxCommandEvent& event )
00281 {
00282     // TODO: Implement OnMaxGain
00283 }
00284 
00285 void wxTauControlFrame::OnContrast( wxScrollEvent& event )
00286 {
00287     // TODO: Implement OnContrast
00288 }
00289 
00290 void wxTauControlFrame::OnBrightness( wxScrollEvent& event )
00291 {
00292     // TODO: Implement OnBrightness
00293 }
00294 
00295 void wxTauControlFrame::OnBrightnessBias( wxScrollEvent& event )
00296 {
00297     // TODO: Implement OnBrightnessBias
00298 }
00299 
00300 void  wxTauControlFrame::
00301 OnSetSpotMeterMode( wxCommandEvent& event ){
00302     if(!serialFlirControl_.IsConnected()) return;
00303     int sel = event.GetInt();
00304     FLIR_STATUS_MESSAGE ret = serialFlirControl_.SetSpotMeterMode(sel);
00305     if(ret != CAM_OK){
00306         biasusleep(500);
00307         ret = serialFlirControl_.SetSpotMeterMode(sel);
00308     }
00309     if(ret == CAM_OK){
00310         wxString text= wxT("Set Spot Meter Mode.");
00311         SetStatusText(text, 0);
00312     }
00313     else{
00314         stringstream txt; txt<<"Could not set Spot Meter Mode:";
00315         txt<<serialFlirControl_.StatusCodeToString(ret);
00316         wxString text= AsciiToWx(txt.str());
00317         SetStatusText(text, 0);
00318     }
00319 }
00320 
00321 void  wxTauControlFrame::
00322 OnGetSpotMeterValue( wxCommandEvent& event ){
00323     if(!serialFlirControl_.IsConnected()) return;
00324     double deg=0;
00325     FLIR_STATUS_MESSAGE ret = serialFlirControl_.GetSpotMeterCelcius(deg);
00326     if(ret != CAM_OK){
00327         biasusleep(500);
00328         ret = serialFlirControl_.GetSpotMeterCelcius(deg);
00329     }
00330     if(ret == CAM_OK){
00331         stringstream d; d<< deg;
00332         m_textCtrSpotMeterValue->SetValue(AsciiToWx(d.str()));
00333         wxString text= wxT("Got Spot Meter Mode Value.");
00334         SetStatusText(text, 0);
00335     }
00336     else{
00337         stringstream txt; txt<<"Could not get Spot Meter Mode:";
00338         txt<<serialFlirControl_.StatusCodeToString(ret);
00339         wxString text= AsciiToWx(txt.str());
00340         SetStatusText(text, 0);
00341     }
00342 }
00343 
00344 void wxTauControlFrame::
00345 OnSpotMeterDisplay( wxCommandEvent& event ){
00346     if(!serialFlirControl_.IsConnected()) return;
00347     int sel = event.GetInt();
00348     FLIR_STATUS_MESSAGE ret = serialFlirControl_.SetSpotMeterDisplay(sel);
00349     if(ret != CAM_OK){
00350         biasusleep(500);
00351         ret = serialFlirControl_.SetSpotMeterDisplay(sel);
00352     }
00353     if(ret == CAM_OK){
00354         wxString text= wxT("Set Spot Meter Mode.");
00355         SetStatusText(text, 0);
00356     }
00357     else{
00358         stringstream txt; txt<<"Could not set display:";
00359         txt<<serialFlirControl_.StatusCodeToString(ret);
00360         wxString text= AsciiToWx(txt.str());
00361         SetStatusText(text, 0);
00362     }
00363 }
00364 
00365 void wxTauControlFrame::OnConnect( wxCommandEvent& event )
00366 {
00367     wxString dev = m_textCtrlDevice->GetValue();
00368 
00369     FLIR_STATUS_MESSAGE ret = CAM_OK;
00370         //bool tryToConnect=false;
00371     if(serialFlirControl_.IsConnected()){
00372                 //tryToConnect = false;
00373         ret = serialFlirControl_.DisconnectCamera();
00374     }
00375     else{
00376                 //tryToConnect = true;
00377         ret = serialFlirControl_.ConnectCamera(WxToAscii(dev));
00378     }
00379 
00380     if(ret!=CAM_OK){
00381         wxMessageDialog messageDialog(this,
00382                 wxT("Sorry, could not communicate with Flir thermal camera!"),
00383                 wxT("ShowCamWx - FLIR "), wxICON_ERROR | wxOK);
00384         messageDialog.ShowModal();
00385     }
00386 
00387     if(serialFlirControl_.IsConnected()){
00388         m_buttonConnect->SetLabel(AsciiToWx("Disconnect"));
00389     m_notebook1->Enable(true);
00390     string serial; serialFlirControl_.GetSerialNumber(serial);
00391     stringstream txt; txt<<"Connected! Camera Serial Number:Sensor Serial Number  ";
00392     txt<<serial;
00393     wxString text= AsciiToWx(txt.str());
00394     SetStatusText(text, 0);
00395     }
00396     else{
00397         m_buttonConnect->SetLabel(AsciiToWx("Connect"));
00398       m_notebook1->Enable(false);
00399     wxString text= wxT("Disconnected!");
00400     SetStatusText(text, 0);
00401   }
00402     
00403 }
00404 
00405 void wxTauControlFrame::OnClose( wxCommandEvent& event )
00406 {
00407     if(serialFlirControl_.IsConnected())
00408         serialFlirControl_.DisconnectCamera();
00409     Show(false);
00410 }
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends