--- trunk/FlisServer/FlisServerDlg.cpp 2007/11/27 15:26:42 70 +++ trunk/FlisServer/FlisServerDlg.cpp 2007/11/30 07:24:35 105 @@ -64,9 +64,9 @@ ON_WM_PAINT() ON_WM_QUERYDRAGICON() //}}AFX_MSG_MAP - ON_BN_CLICKED(IDOK, OnBnClickedOk) - ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel) ON_BN_CLICKED(IDC_test, OnBnClickedtest) + ON_BN_CLICKED(IDCLOSE, OnBnClickedClose) + ON_BN_CLICKED(IDC_GSMPIN, OnBnClickedGsmpin) END_MESSAGE_MAP() @@ -101,7 +101,7 @@ // TODO: Add extra initialization here StartSerial(); - SetPin(); + DBConnect(); return TRUE; // return TRUE unless you set the focus to a control } @@ -182,55 +182,75 @@ } return buf; } -void CFlisServerDlg::OnBnClickedOk() -{ - // TODO: Add your control notification handler code here - OnOK(); - if( Serial.isOpen() ){ - Serial.close(); - } -} - -void CFlisServerDlg::OnBnClickedCancel() -{ - // TODO: Add your control notification handler code here - OnCancel(); - if( Serial.isOpen() ){ - Serial.close(); - } -} - void CFlisServerDlg::OnBnClickedtest() { // TODO: Add your control notification handler code here - /* +/* +////////////////Read sms ting////////////////// + CString tekst; std::vector data; data.push_back('a'); data.push_back('t'); + data.push_back('+'); + data.push_back('c'); + data.push_back('m'); + data.push_back('g'); + data.push_back('r'); + data.push_back('='); + data.push_back('1'); writeFrame(data); - - if(Serial.getComstat().cbInQue > 0) + ReadSms(); +////////////////Read sms ting////////////////// +*/ +/* +////////////////DBRead stuff////////////////// + CString testdata; + std::vector data; + data = DBRead(); + for (int i=0; i answer = readFrame(); - Sleep(50); - if (answer.size() == 0){ - m_Textwindow.SetWindowText("ØV"); - } - else{ - CString ko; - char test[150]; - int i; - for (int i=0; i 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; + 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) { @@ -245,7 +265,7 @@ } int CFlisServerDlg::SetPin(void) { - CString tekst, oldtekst; + CString tekst; std::vector data; data.push_back('a'); data.push_back('t'); @@ -280,39 +300,217 @@ tekst.AppendChar(array1[i]); } } - - m_Textwindow.GetWindowText(oldtekst); - oldtekst.Append("\r\n"); - oldtekst.Append(tekst); - m_Textwindow.SetWindowText(oldtekst); + m_Textwindow.SetWindowText(tekst); } return 0; } void CFlisServerDlg::SendSmsData(std::vector data) -{ +{ + for (int i=0; i 0) + { + CString tekst; + std::vector answer = readFrame(); + Sleep(50); + char array1[25]; + int i; + for (int i=0; i data) { + vector atcommand; + atcommand.push_back('a'); + atcommand.push_back('t'); + atcommand.push_back('+'); + atcommand.push_back('c'); + atcommand.push_back('m'); + atcommand.push_back('g'); + atcommand.push_back('s'); + atcommand.push_back('='); + atcommand.push_back('"'); + int s = (atcommand.size() -1 ); + + for (int i=0; i<(atcommand.size()); i++) + { + Serial.writeByte( atcommand[i] ); + Sleep(5); + } + for (int i=0; i CFlisServerDlg::DBRead(void) +{ + vector buffer; + + CString SQL, IDnr, CommandID, InstallationsID; + SQL = "select id,date_trunc('second', created) as created,executed,commandid,installationid from command WHERE executed IS NULL;"; + CRecordset rs(&db); + rs.Open(AFX_DB_USE_DEFAULT_TYPE, SQL); + if (rs.GetRecordCount()>0) + { + 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; + + buffer.push_back(Mycom); + rs.MoveNext(); + } + } + rs.Close(); + return buffer; +} +void CFlisServerDlg::ReadSms() +{ + CString tekst, oldtekst; + Sleep(950); + if(Serial.getComstat().cbInQue > 0) + { + std::vector answer = readFrame(); + Sleep(50); + char array1[250]; + int i; + for (int i=0; i