--- trunk/FlisServer/FlisServerDlg.cpp 2007/11/28 14:27:51 80 +++ trunk/FlisServer/FlisServerDlg.cpp 2007/11/28 16:24:04 81 @@ -51,6 +51,7 @@ : CDialog(CFlisServerDlg::IDD, pParent) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); + db = 0; } void CFlisServerDlg::DoDataExchange(CDataExchange* pDX) @@ -101,7 +102,8 @@ // TODO: Add extra initialization here StartSerial(); - SetPin(); + //SetPin(); + DBConnect(); return TRUE; // return TRUE unless you set the focus to a control } @@ -189,6 +191,13 @@ if( Serial.isOpen() ){ Serial.close(); } + + if (db != 0) + { + //db->Close(); + delete db; + db=0; + } } void CFlisServerDlg::OnBnClickedCancel() @@ -198,39 +207,32 @@ if( Serial.isOpen() ){ Serial.close(); } + + if (db != 0) + { + db->Close(); + delete db; + db = 0; + } } void CFlisServerDlg::OnBnClickedtest() { // TODO: Add your control notification handler code here - /* + 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) - { - std::vector 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 data) { @@ -245,7 +247,7 @@ } int CFlisServerDlg::SetPin(void) { - CString tekst, oldtekst; + CString tekst; std::vector data; data.push_back('a'); data.push_back('t'); @@ -280,11 +282,7 @@ 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; } @@ -310,9 +308,108 @@ Sleep(100); } -void CFlisServerDlg::DBconnect() +void CFlisServerDlg::DBConnect() { + db = new CDatabase(); + CString dsn; - dsn.Format("ODBC;Description=asd;DRIVER=PostgreSQL ANSI;SERVER=%s; uid=%s;password=%s;database=%s",config.host, config.username, config.password, config.database); - db.OpenEx(dsn, CDatabase::noOdbcDialog); + dsn.Format("ODBC;Description=asd;DRIVER=PostgreSQL ANSI;SERVER=192.168.134.132; uid=serrenab;password=furnacemonitor;database=flisfyr"); + //db->OpenEx(dsn, CDatabase::noOdbcDialog); + +} +void CFlisServerDlg::DBRead() +{ + +} +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