/[H9]/trunk/FlisServer/FlisServerDlg.cpp
ViewVC logotype

Diff of /trunk/FlisServer/FlisServerDlg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 144 by kevin, Tue Dec 4 13:26:00 2007 UTC revision 168 by kevin, Thu Dec 6 07:14:17 2007 UTC
# Line 6  Line 6 
6  #include "FlisServerDlg.h"  #include "FlisServerDlg.h"
7  #include <vector>  #include <vector>
8  #include ".\flisserverdlg.h"  #include ".\flisserverdlg.h"
9    #include <atlrx.h>
10    
11  #ifdef _DEBUG  #ifdef _DEBUG
12  #define new DEBUG_NEW  #define new DEBUG_NEW
# Line 373  void CFlisServerDlg::SmsSplit(CString da Line 374  void CFlisServerDlg::SmsSplit(CString da
374                  HandleAcknowledge(TlfNr);                  HandleAcknowledge(TlfNr);
375                  return;                  return;
376          }          }
377                    CAtlRegExp<> regex;
378            if (regex.Parse("^{[0-9]+}:{[0-9]+}:[0-1]:[0-1]:[0-1]:[0-1]:$") == REPARSE_ERROR_OK)
379            {
380    
381                    CAtlREMatchContext<> pContext;
382    
383                    if (!regex.Match(FyrData, &pContext))
384                    {
385                            AppendText("Invalid SMS recieved");
386                            return;
387                    }
388            }
389            else
390            {
391                    AppendText("Regex PARSE error!!!"); //Burde aldrig kunne ske !
392            }
393    
394          SmsCount = Splitter(FyrData);          SmsCount = Splitter(FyrData);
395          Temper = Splitter(FyrData);          Temper = Splitter(FyrData);
396          Flamme = Splitter(FyrData);          Flamme = Splitter(FyrData);
# Line 421  void CFlisServerDlg::OnBnClickedClose() Line 438  void CFlisServerDlg::OnBnClickedClose()
438  {  {
439          // TODO: Add your control notification handler code here          // TODO: Add your control notification handler code here
440          continueThread = 0;          continueThread = 0;
441            Sleep(250);
442          DeleteSms();          DeleteSms();
443    
444          Sleep(500);          Sleep(500);
# Line 471  void CFlisServerDlg::OnBnClickedGsmpin() Line 489  void CFlisServerDlg::OnBnClickedGsmpin()
489                                  AppendText(tekst);                                  AppendText(tekst);
490                          }                          }
491                  }                  }
492                    Sleep(10); //Small delay to avoid busy wait
493          }          }
494          Sleep(100); //Give the modem a chance to send the last data          Sleep(100); //Give the modem a chance to send the last data
495          while(Serial.getComstat().cbInQue > 0)          while(Serial.getComstat().cbInQue > 0)
# Line 514  void CFlisServerDlg::runthread() Line 533  void CFlisServerDlg::runthread()
533  {  {
534          while (continueThread != 0)          while (continueThread != 0)
535          {          {
536                  Reader();                  MyMainThread();
537          }          }
538  }  }
539  void CFlisServerDlg::Reader()  void CFlisServerDlg::MyMainThread()
540  {  {
541          if(Serial.getComstat().cbInQue > 0)          if(Serial.getComstat().cbInQue > 0)
542                  {                  {
# Line 525  void CFlisServerDlg::Reader() Line 544  void CFlisServerDlg::Reader()
544                          std::vector<unsigned char> answer = readFrame();                          std::vector<unsigned char> answer = readFrame();
545                          Sleep(500);                          Sleep(500);
546                          CString tekst, oldtekst;                          CString tekst, oldtekst;
                         int lol;  
547                                    
548                          for (int i=0; i<answer.size(); i++)                          for (int i=0; i<answer.size(); i++)
549                          {                          {
# Line 740  void CFlisServerDlg::SendConfig(CString Line 758  void CFlisServerDlg::SendConfig(CString
758                  CString SQL, Textwindow;                  CString SQL, Textwindow;
759                  SQL.Format("update command set executed=now() where id=%s",IDnr);                  SQL.Format("update command set executed=now() where id=%s",IDnr);
760                  db.ExecuteSQL(SQL);                  db.ExecuteSQL(SQL);
761                    Sleep(100);
762                  AppendText("Command executed");                  AppendText("Command executed");
763          }          }
764          Sleep(150);          Sleep(150);
# Line 817  void CFlisServerDlg::AppendText(CString Line 836  void CFlisServerDlg::AppendText(CString
836          Tekst.Append("\r\n");          Tekst.Append("\r\n");
837          Tekst.Append(s);          Tekst.Append(s);
838          m_Textwindow.SetWindowText(Tekst);          m_Textwindow.SetWindowText(Tekst);
839            int g = m_Textwindow.GetScrollLimit(SB_VERT);
840            if (g > 0)
841            {
842            m_Textwindow.SetScrollPos(g,1,false);
843            }
844    
845  }  }
846  void ConfigFile::ReadSettings()  void ConfigFile::ReadSettings()
# Line 923  vector<keepalive> CFlisServerDlg::keepal Line 947  vector<keepalive> CFlisServerDlg::keepal
947          CString SQL, name, value;          CString SQL, name, value;
948          SQL = "select name, value from config;";          SQL = "select name, value from config;";
949          CRecordset rs(&db);          CRecordset rs(&db);
950          rs.Open(AFX_DB_USE_DEFAULT_TYPE, SQL);          try
         if (rs.GetRecordCount()>0)  
951          {          {
952                  rs.MoveFirst();                  rs.Open(AFX_DB_USE_DEFAULT_TYPE, SQL);
953                    if (rs.GetRecordCount()>0)
954                    {
955                            rs.MoveFirst();
956                                                    
957                  rs.GetFieldValue((short)0, name);                          rs.GetFieldValue((short)0, name);
958                  rs.GetFieldValue(1,value);                          rs.GetFieldValue(1,value);
959                                    
960                  Alive.name = name;                          Alive.name = name;
961                  Alive.value = value;                          Alive.value = value;
962                  Alive.tid = CTime::GetCurrentTime();                          Alive.tid = CTime::GetCurrentTime();
963                  if(Alive.name == "phonenr")                          if(Alive.name == "phonenr")
964                  {                          {
965                          Alive.Phonenr = value;                                  Alive.Phonenr = value;
966                  }                          }
967    
968                  buffer.push_back(Alive);                          buffer.push_back(Alive);
969                  rs.MoveNext();                          rs.MoveNext();
970    
971                    }
972                    rs.Close();
973                    return buffer;
974          }          }
975          rs.Close();          catch (char * str)
976          return buffer;          {
977                    AppendText("Keepalive failed, closing and opening the db connection again");
978                    if(db.IsOpen())
979                    {
980                            db.Close();
981                            AppendText("DB connection closed");
982                    }
983                    if(!db.IsOpen())
984                    {
985                            DBConnect();
986                            AppendText("DB connection started again");
987                    }
988                    return buffer;
989            }
990    
991                    
992  }  }

Legend:
Removed from v.144  
changed lines
  Added in v.168

  ViewVC Help
Powered by ViewVC 1.1.20