--- trunk/FlisServer/FlisServerDlg.cpp 2007/12/01 14:18:33 113 +++ trunk/FlisServer/FlisServerDlg.cpp 2007/12/03 09:22:26 130 @@ -5,6 +5,7 @@ #include "FlisServer.h" #include "FlisServerDlg.h" #include +#include ".\flisserverdlg.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -64,9 +65,9 @@ ON_WM_QUERYDRAGICON() ON_MESSAGE(UWM_MYMESSAGE, OnShowString) //}}AFX_MSG_MAP - ON_BN_CLICKED(IDC_test, OnBnClickedtest) ON_BN_CLICKED(IDCLOSE, OnBnClickedClose) ON_BN_CLICKED(IDC_GSMPIN, OnBnClickedGsmpin) + ON_BN_CLICKED(IDC_Start, OnBnClickedStart) END_MESSAGE_MAP() @@ -102,15 +103,7 @@ // TODO: Add extra initialization here StartSerial(); DBConnect(); - continueThread = 1; ResetSms = 0; - /* -////////////Start Tråd//////////////////////// - MyThread *t = new MyThread(AfxGetMainWnd()); - t->start(); -////////////Start Tråd//////////////////////// -*/ - AfxBeginThread(threadWrapper,AfxGetMainWnd()); return TRUE; // return TRUE unless you set the focus to a control } @@ -191,47 +184,7 @@ } return buf; } -void CFlisServerDlg::OnBnClickedtest() -{ - // TODO: Add your control notification handler code here - -/* -///////////////Send sms stuff///////////////// - vector tlfnr; - vector smsdata; - tlfnr.push_back('2'); - tlfnr.push_back('9'); - tlfnr.push_back('7'); - tlfnr.push_back('2'); - tlfnr.push_back('2'); - tlfnr.push_back('6'); - tlfnr.push_back('0'); - tlfnr.push_back('3'); - - SendSmsHead(tlfnr); - //35:29860132:75 <--- demo pakke; - vector smsdata; - smsdata.push_back('3'); - smsdata.push_back('5'); - smsdata.push_back(':'); - smsdata.push_back('2'); - smsdata.push_back('9'); - smsdata.push_back('8'); - smsdata.push_back('6'); - smsdata.push_back('0'); - smsdata.push_back('1'); - smsdata.push_back('3'); - smsdata.push_back('2'); - smsdata.push_back(':'); - smsdata.push_back('7'); - smsdata.push_back('5'); - - SendSmsData(smsdata); -///////////////Send sms stuff///////////////// -*/ - -} void CFlisServerDlg::writeFrame(std::vector data) { for (int i=0; i answer = readFrame(); Sleep(50); - char array1[25]; + char array1[150]; int i; for (int i=0; i CFlisServerDlg::DBRead(void) @@ -366,17 +319,17 @@ rs.MoveFirst(); while(!rs.IsEOF()) { - Commands Mycom; - rs.GetFieldValue((short)0, IDnr); - rs.GetFieldValue(3, CommandID); - rs.GetFieldValue(4, InstallationsID); - - Mycom.IDnr = IDnr; - Mycom.CommandID = CommandID; - Mycom.InstallationsID = InstallationsID; + Commands Mycom; + rs.GetFieldValue((short)0, IDnr); + rs.GetFieldValue(3, CommandID); + rs.GetFieldValue(4, InstallationsID); + + Mycom.IDnr = IDnr; + Mycom.CommandID = CommandID; + Mycom.InstallationsID = InstallationsID; - buffer.push_back(Mycom); - rs.MoveNext(); + buffer.push_back(Mycom); + rs.MoveNext(); } } rs.Close(); @@ -438,7 +391,7 @@ FremFejl = Splitter(FyrData); PowerFail = Splitter(FyrData); /////////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////// Her skal sendes data til databasen ////////////////////////////////////////////// +///////////////////// Her skal sendes data til databasen ////NÅR HEDIN KAN SENDE SMS/////////////////// m_Textwindow.GetWindowText(oldtekst); oldtekst.Append("\r\n"); oldtekst.Append("På næste linie kommer SmsCount. \r\n"); @@ -502,7 +455,8 @@ { // TODO: Add your control notification handler code here SetPin(); - //Sleep(5000); + Sleep(35000); + OnBnClickedStart(); } void CFlisServerDlg::DeleteSms() { @@ -637,6 +591,7 @@ writeFrame(data); Sleep(200); ReadSms(); + ResetSms++; } else if(command = "wind") @@ -657,8 +612,9 @@ if (continueThread = 1) { - ////////////////DBRead stuff////////////////// - CString testdata, dataframe,testprint, sIDnr, sCommandID, sInstallationsID; + CString testdata, dataframe,testprint, sIDnr, sCommandID, sInstallationsID, sImei; + int commandtest = 0; + int iAll = 1; std::vector data; data = DBRead(); for (int i=0; i 1) + { testdata.Append(data[i].InstallationsID); testdata.Append(":"); + } } sIDnr = Splitter(testdata); sCommandID = Splitter(testdata); + sInstallationsID = "0"; + if (commandtest > 1) + { sInstallationsID = Splitter(testdata); + iAll = 0; + } - testprint.Append("sIDnr på næste linie\r\n"); - testprint.Append(sIDnr); - testprint.Append("\r\n"); - testprint.Append("sCommandID på næste linie\r\n"); - testprint.Append(sCommandID); - testprint.Append("\r\n"); - testprint.Append("sInstallationsID på næste linie\r\n"); - testprint.Append(sInstallationsID); - m_Textwindow.SetWindowText(testprint); - - if (sIDnr.GetLength() > 0) { DBReadData(sIDnr,sCommandID,sInstallationsID); } Sleep(500); - ////////////////DBRead stuff////////////////// } } void CFlisServerDlg::DBReadData(CString IDnr,CString CommandID,CString InstallationsID) { - CString TlfNr; + CString ServerTlfNr; + int i = 0; + ServerTlfNr = "29860132"; - //kald dbreadphone som du kalder dbread + std::vector inst; inst = DBReadPhone(InstallationsID); - for (int i=0; i tlfnr; for (int i=0; i smsdata; - smsdata.push_back('3'); - smsdata.push_back('5'); + + for (int i=0; i CFlisServerDlg::DBReadPhone(CString sInstallationsID) { vector buffer; - CString SQL, phonenr; - SQL.Format("select installationphonenr from installation WHERE id = %s",sInstallationsID); + CString SQL, phonenr, imei, updaterate; + int installernull; + Installation Myinst; + installernull = atoi(sInstallationsID); + if (installernull > 1) + { + SQL.Format("select installationphonenr, imei, updaterate from installation WHERE id = %s", sInstallationsID); + } + else if(installernull < 2) + { + SQL.Format("select installationphonenr, imei, updaterate from installation"); + } CRecordset rs(&db); rs.Open(AFX_DB_USE_DEFAULT_TYPE, SQL); if (rs.GetRecordCount()>0) @@ -752,15 +743,37 @@ rs.MoveFirst(); while(!rs.IsEOF()) { - Installation Myinst; - rs.GetFieldValue((short)0,phonenr); - - Myinst.InstPhoneNr.Append(phonenr); + + rs.GetFieldValue((short)0,phonenr); + rs.GetFieldValue(1,imei); + rs.GetFieldValue(2,updaterate); + + Myinst.InstPhoneNr = phonenr; + Myinst.Imei = imei; + Myinst.Updaterate = updaterate; - buffer.push_back(Myinst); - rs.MoveNext(); + buffer.push_back(Myinst); + rs.MoveNext(); } } rs.Close(); return buffer; -} \ No newline at end of file +} +int CFlisServerDlg::tversum(__int64 input) +{ + int sum = 0; + while (input > 0) + { + sum += (input %10); + input /= 10; + } + return sum; +} +void CFlisServerDlg::OnBnClickedStart() +{ +// TODO: Add your control notification handler code here + + continueThread = 1; + + AfxBeginThread(threadWrapper,AfxGetMainWnd()); +}