Esempio n. 1
0
void WBSDOutletWindow::on_normalOpenValve_released()
{
    ParameterMsg message1(Message::MCB,Message::DV,2,Message::SET_PARAMETER);
    ParameterMsg message2(Message::MCB,Message::DV,15,Message::SET_PARAMETER);
    message1.setBit(10,0);
    message2.setBit(4,0);
	qDebug() << "No 2 r";
    itsBaseWindow->addMessageToQue(message2);
	qDebug() << "No 1 r";
    itsBaseWindow->addMessageToQue(message1);
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
        QApplication app(argc, argv);
        Swift::UIEventStream eventStream;
        Swift::QtEventWindow* viewer = new Swift::QtEventWindow(&eventStream);
        viewer->show();
        std::shared_ptr<Swift::Message> message1(new Swift::Message());
        message1->setBody("Oooh, shiny");
        std::shared_ptr<Swift::MessageEvent> event1(new Swift::MessageEvent(message1));
        viewer->addEvent(std::dynamic_pointer_cast<Swift::StanzaEvent>(event1), true);
        for (int i = 0; i < 100; i++) {
            viewer->addEvent(std::dynamic_pointer_cast<Swift::StanzaEvent>(event1), false);
        }
        viewer->addEvent(std::dynamic_pointer_cast<Swift::StanzaEvent>(std::make_shared<Swift::ErrorEvent>(Swift::JID("*****@*****.**"), "Something bad did happen to you.")), true);
        return app.exec();
}
Esempio n. 3
0
static bool
init_zlib_functions (void)
{
  HMODULE library = w32_delayed_load (Qzlib_dll);

  if (!library)
    {
      message1 ("zlib library not found");
      return false;
    }

  LOAD_ZLIB_FN (library, inflateInit2_);
  LOAD_ZLIB_FN (library, inflate);
  LOAD_ZLIB_FN (library, inflateEnd);
  return true;
}
Esempio n. 4
0
static int
init_libxml2_functions (void)
{
#ifdef WINDOWSNT
  if (libxml2_loaded_p ())
    return 1;
  else
    {
      HMODULE library;

      if (!(library = w32_delayed_load (Qlibxml2_dll)))
	{
	  message1 ("libxml2 library not found");
	  return 0;
	}

      /* LOAD_XML2_FN jumps to bad_library if it fails to find the
	 named function.  */
      LOAD_XML2_FN (library, htmlReadMemory);
      LOAD_XML2_FN (library, xmlReadMemory);
      LOAD_XML2_FN (library, xmlDocGetRootElement);
      LOAD_XML2_FN (library, xmlFreeDoc);
      LOAD_XML2_FN (library, xmlCleanupParser);
      LOAD_XML2_FN (library, xmlCheckVersion);

      Vlibrary_cache = Fcons (Fcons (Qlibxml2_dll, Qt), Vlibrary_cache);
      return 1;
    }

 bad_library:
  Vlibrary_cache = Fcons (Fcons (Qlibxml2_dll, Qnil), Vlibrary_cache);

  return 0;
#else  /* !WINDOWSNT */
  return 1;
#endif	/* !WINDOWSNT */
}
Esempio n. 5
0
TEST(UnitTestTeeStreambuf, UnitTest)
{
  stk::tee_streambuf    out_tee_streambuf;

  std::ostream          my_out(&out_tee_streambuf);
  
  std::ostringstream    dest1;
  std::ostringstream    dest2;

  out_tee_streambuf.add(&dest1);
  out_tee_streambuf.add(&dest2);

  std::string message1("This is a test");
  std::string message2("This is a test");

  std::string message3 = message1 + message2;
  
  my_out << message1;

  ASSERT_EQ((dest1.str() == message1), true);
  ASSERT_EQ((dest2.str() == message1), true);

  out_tee_streambuf.remove(&dest2);

  my_out << message2;
  
  ASSERT_EQ((dest1.str() == message3), true);
  ASSERT_EQ((dest2.str() == message1), true);

  out_tee_streambuf.remove(&dest1);

  my_out << message2;

  ASSERT_EQ((dest1.str() == message3), true);
  ASSERT_EQ((dest2.str() == message1), true);
}
Esempio n. 6
0
    void queues_getting_started_sample()
    {
        try
        {
            // Initialize storage account
            azure::storage::cloud_storage_account storage_account = azure::storage::cloud_storage_account::parse(storage_connection_string);

            // Create a queue
            azure::storage::cloud_queue_client queue_client = storage_account.create_cloud_queue_client();
            azure::storage::cloud_queue queue = queue_client.get_queue_reference(U("my-sample-queue"));
            
            // Return value is true if the queue did not exist and was successfully created.
            queue.create_if_not_exists();

            // Insert some queue messages
            azure::storage::cloud_queue_message message1(U("some message"));
            queue.add_message(message1);
            azure::storage::cloud_queue_message message2(U("different message"));
            queue.add_message(message2);
            azure::storage::cloud_queue_message message3(U("another message"));
            queue.add_message(message3);

            // Peek the next queue message
            azure::storage::cloud_queue_message peeked_message = queue.peek_message();
            ucout << U("Peek: ") << peeked_message.content_as_string() << std::endl;

            // Dequeue the next queue message
            azure::storage::cloud_queue_message dequeued_message = queue.get_message();
            ucout << U("Get: ") << dequeued_message.content_as_string() << std::endl;

            // Update a queue message (content and visibility timeout)
            dequeued_message.set_content(U("changed message"));
            queue.update_message(dequeued_message, std::chrono::seconds(30), true);
            ucout << U("Update: ") << dequeued_message.content_as_string() << std::endl;

            // Delete the queue message
            queue.delete_message(dequeued_message);

            // Dequeue some queue messages (maximum 32 at a time) and set their visibility timeout to 5 minutes
            azure::storage::queue_request_options options;
            azure::storage::operation_context context;
            std::vector<azure::storage::cloud_queue_message> messages = queue.get_messages(32, std::chrono::seconds(300), options, context);
            for (std::vector<azure::storage::cloud_queue_message>::const_iterator it = messages.cbegin(); it != messages.cend(); ++it)
            {
                ucout << U("Get: ") << it->content_as_string() << std::endl;
            }

            // Delete the queue messages
            for (std::vector<azure::storage::cloud_queue_message>::iterator it = messages.begin(); it != messages.end(); ++it)
            {
                queue.delete_message(*it);
            }

            // Get the approximate queue size
            queue.download_attributes();
            ucout << U("Approximate message count: ") << queue.approximate_message_count() << std::endl;

            // Delete the queue
            // Return value is true if the queue did exist and was succesfully deleted.
            queue.delete_queue_if_exists();
        }
        catch (const azure::storage::storage_exception& e)
        {
            ucout << U("Error: ") << e.what() << std::endl;

            azure::storage::request_result result = e.result();
            azure::storage::storage_extended_error extended_error = result.extended_error();
            if (!extended_error.message().empty())
            {
                ucout << extended_error.message() << std::endl;
            }
        }
        catch (const std::exception& e)
        {
            ucout << U("Error: ") << e.what() << std::endl;
        }
    }
Esempio n. 7
0
void CSetTimeDlg::OnButSend() 
{
//        swprintf(pTTTW->szText,L"%s",strB); 
 //      swprintf((wchar_t *)pTTTW->szText,L"%s",tooltip.AllocSysString()); 
//			 _stprintf((LPTSTR)word,_T("%s"),strB);  

//	m_ndkSend = new  unsigned char[200]; 
//		GetDlgItem(IDC_COMBO_VERIFYT)->GetWindowText(cccc);
	CString strPointNo,cccc,strim2;
	UpdateData(TRUE);
		GetDlgItem(IDC_COMBO_VERIFYT)->GetWindowText(cccc);
		unsigned char nfds3 = m_Str2Data.String2Int(cccc);
		GetDlgItem(IDC_COMBO_PORT)->GetWindowText(cccc);
		int nfdsP = m_Str2Data.String2Int(cccc);
	unsigned char nfds =nfds3;

	if(chcommand == 0x54)   //校时
	{
//	GetSystemMenu(FALSE)->EnableMenuItem(SC_CLOSE ,MF_DISABLED);
//	GetDlgItem(IDOK_SEND)-> EnableWindow(FALSE);
//	GetDlgItem(IDCANCEL)-> EnableWindow(FALSE);
        m_ndkSend = new  unsigned char[11];
    	CMainFrame* pFWnd=(CMainFrame*)AfxGetMainWnd();
		pFWnd->n_timer60 =1;
	}
	else if(chcommand == 0x4B)            //手动控制
	{
      	m_ndkSend = new  unsigned char[6];
		            m_ndkSend[0] = 0x7E;
		            m_ndkSend[1] = nfds3;
		            m_ndkSend[2] = chcommand;
		            m_ndkSend[3] = nfdsP;
					nfds = m_FUNCTION.GetCurSel();
					if(nfds >1)
					{
          	AfxMessageBox("请选择“吸合”或“断开”!", MB_OK);
			m_FUNCTION.SetCurSel(0);
         	delete m_ndkSend;
			return;
					}
		            m_ndkSend[4] = nfds;
		            m_ndkSend[5] = 0x21;
    	CNDKMessage message1(MANUALCONTROL);
					message1.Add(m_ndkSend , 200);
					theApp.Sync(message1,1);
					if(nfds ==0)
						cccc ="吸合";
					else if(nfds ==1)
						cccc ="断开";

					m_nchangev = chcommand;
        GetDlgItem(IDC_BUT_RES)->ShowWindow(SW_SHOW);
					strim2.Format("%d号分站手动控制:端口%d|%s",nfds3,nfdsP,cccc);
       g_Log.StatusOut(strim2);
	}
	else if(chcommand == 0x43)       //配置测点
	{
        	CString strSQL;
		if(m_SerialF[nfds].SFSd ==0)
		{
        	strSQL.Format("%d号分站没有巡检!",nfds3);
            AfxMessageBox(strSQL, MB_OK);
			return;
		}
      	m_ndkSend = new  unsigned char[166];
		theApp.m_RTDM.SendPP(nfds3);
	}
	else if(chcommand == 0x41)            //配置分站
	{
      	m_ndkSend = new  unsigned char[64];
		int n_fen;
		            m_ndkSend[0] = 0x7E;
		            m_ndkSend[1] = 0x01;
		            m_ndkSend[2] = chcommand;
        for(int nItem=0;nItem<60;nItem++)
		{
    		strPointNo=m_listC.GetItemText(nItem,2);
			n_fen = m_Str2Data.String2Int(strPointNo);
			if(n_fen >99 || n_fen <0)
				break;
			if(n_fen == 0)//输入其它数据时,也是0  重新设为0
	      		m_listC.SetItemText(nItem,2,"0");
              m_ndkSend[nItem+3] = n_fen;
		}
		if(n_fen >99 || n_fen <0)
		{
          	AfxMessageBox("串口号在0-99间选择!", MB_OK);
			m_listC.SetItemText(nItem,2,"0"); //重新设为0
         	delete m_ndkSend;
			return;
		}
		            m_ndkSend[63] = 0x21;
    	CNDKMessage message1(INFODEFINE);
					message1.Add(m_ndkSend , 64);
					theApp.Sync(message1,1);
        for( nItem=0;nItem<60;nItem++)
		{
            				try
							{
                             m_SControl.AbsolutePosition(nItem + 1);
         					 m_SControlNew->m_szSID = nItem+1;
	         				 m_SControlNew->m_szSerialnum = m_ndkSend[nItem+3];
					   	     m_SControlNew->Update();    //Update the recordset
							}
		     			    catch (CAxException *e)
							{
					        	AfxMessageBox(e->m_szErrorDesc, MB_OK);
				        		delete e;
							}
					strPointNo.Format("%d号分站,配串口%d  ",nItem+1,m_ndkSend[nItem+3]);
					strim2 +=strPointNo;
		}//for
		theApp.InitData();
       g_Log.StatusOut("配置分站:" +strim2);
          	AfxMessageBox("配置分站命令发送成功!", MB_OK);
	}
	else if(chcommand == 0x47)            //通讯测试
	{
      	m_ndkSend = new  unsigned char[4];
		            m_ndkSend[0] = 0x7E;
		            m_ndkSend[1] = nfds3;
		            m_ndkSend[2] = chcommand;
		            m_ndkSend[3] = 0x21;
    	CNDKMessage message1(TESTCOMMUNICATION);
					message1.Add(m_ndkSend , 200);
					theApp.Sync(message1,1);
 	  strim2.Format("通讯测试:%d号分站",nfds3);
      g_Log.StatusOut(strim2);
	}
	else if(chcommand == 0x5A)            //故障闭锁
	{
		if(m_SerialF[nfds3].SFSd ==0)
		{
        	strim2.Format("%d号分站没有巡检!",nfds3);
            AfxMessageBox(strim2, MB_OK);
			return;
		}
      	m_ndkSend = new  unsigned char[5];
				    m_ndkSend[0] = 0x7E;
		            m_ndkSend[1] = nfds3;
		            m_ndkSend[2] = chcommand;
					nfds = m_FUNCTION.GetCurSel();
					if(nfds >1)
					{
          	AfxMessageBox("请选择“使能”或“关闭”!", MB_OK);
			m_FUNCTION.SetCurSel(0);
         	delete m_ndkSend;
			return;
					}
		            m_ndkSend[3] = nfds;
		            m_ndkSend[4] = 0x21;
    	CNDKMessage message1(FAULTATRESIA);
					message1.Add(m_ndkSend , 200);
					theApp.Sync(message1,1);
					theApp.n_temp =nfds;

/*            				try
							{
                             m_SControl.AbsolutePosition(m_ndkSend[1]);
         					 m_SControlNew->m_szSID = m_ndkSend[1];
	         				 m_SControlNew->m_szSpeCtrol = (bool)m_ndkSend[3];
					   	     m_SControlNew->Update();    //Update the recordset
							}
		     			    catch (CAxException *e)
							{
					        	AfxMessageBox(e->m_szErrorDesc, MB_OK);
				        		delete e;
							}*/
 	  strim2.Format("%d分站,故障闭锁设为:",nfds3);
			if(nfds ==0)
				strim2 +="关闭";
			else if(nfds ==1)
				strim2 +="使能";
// 	  strim2.Format("%x||%x",nfds3,m_ndkSend[3]);
      g_Log.StatusOut(strim2);
	}
	else if(chcommand == 0x46)            //风电瓦斯闭锁
	{
		if(m_SerialF[nfds3].SFSd ==0)
		{
        	strim2.Format("%d号分站没有巡检!",nfds3);
            AfxMessageBox(strim2, MB_OK);
			return;
		}
		for(int i =0; i < 6 ;i++)//风电瓦斯闭锁关系定义的测点正常时可以初始化、修改
		{
			if(str_list[i].strl =="")
				break;
        	CString strf,strc,strSQL;
		    strf = str_list[i].strl.Mid(0,2);
    		strc = str_list[i].strl.Mid(3,2);
    		int nfds = m_Str2Data.String2Int(strf);
     		int nchan = m_Str2Data.String2Int(strc);
			unsigned char nstatus = m_SlaveStation[nfds][nchan].Channel_state;
			if(nstatus == 0x10 || nstatus == 0x20 || nstatus == 0xa0)
			{
            	strSQL.Format("%d号分站%s状态为%s,不能修改!",nfds,str_list[i].strl,theApp.m_RTDM.strstatus(nstatus));
                AfxMessageBox(strSQL, MB_OK);
	    		return;
			}
		}

      	m_ndkSend = new  unsigned char[10];
		bool b_gas =true;
		            m_ndkSend[0] = 0x7E;
		            m_ndkSend[1] = nfds3;
		            m_ndkSend[2] = chcommand;
        for(int nItem=0;nItem<6;nItem++)
		{
    		strPointNo=m_listC.GetItemText(nItem,2);
			if(strPointNo == "")
			{
				b_gas =false;
				break;
			}
			strPointNo = strPointNo.Mid(3,2);
			nfds = m_Str2Data.String2Int(strPointNo);
	        		m_ndkSend[nItem+3] = nfds;
		}
		if(b_gas)
		{
		            m_ndkSend[9] = 0x21;
                	CNDKMessage message1(WINDGASATRESIA);
					message1.Add(m_ndkSend , 200);
					theApp.Sync(message1,1);

        	for(int i =0;i<6;i++)
        		str_list[i].strl=m_listC.GetItemText(i,2);
        	strim2.Format("设置%d号分站风电瓦斯闭锁:",nfds3);
            AfxMessageBox(strim2);
            g_Log.StatusOut(strim2);
		}
		else
		{
        	delete m_ndkSend;
			strPointNo.Format("第%d项不能为空!",nItem+1);
            AfxMessageBox(strPointNo);
	    	return;
		}
	}
	else if(chcommand == 0xf0)            //双风门、主扇备扇报警
	{
      	m_ndkSend = new  unsigned char[11];
       	LPCTSTR str1 = "",str2 = "",str3 = "";
      	CString  m_strsel,m_strsel2 ,str11,str12;
		int kkk=0;
            				try
							{
         					 m_Fans.m_szFansID = m_nSecond;
							 m_PORT.GetWindowText(m_strsel);
           	m_Str2Data.SplittoCString(m_strsel,str1,str2,str3);
			str11 =str1;
			m_strsel =str2;
			m_strsel +="|";
			m_strsel +=str3;
	         				 m_Fans.m_szName1 = m_strsel;
	         				 m_Fans.m_szpointnum1 = str11 ;
							 m_FUNCTION.GetWindowText(m_strsel2);
           	m_Str2Data.SplittoCString(m_strsel2,str1,str2,str3);
			str12 =str1;
			m_strsel2 =str2;
			m_strsel2 +="|";
			m_strsel2 +=str3;
	         				 m_Fans.m_szName2 = m_strsel2;
	         				 m_Fans.m_szpointnum2 = str12;
				if(str11 == str12)
				{
                 	AfxMessageBox("点号不能相同,请重选!", MB_OK);
                   	delete m_ndkSend;
          			return;
				}
				for ( int i = 0 ; i < m_Records1.size() ; i++ )
				{
    				if((str11 == m_Records1[i])&&(str12 == m_Records2[i]))
					{
						kkk =100;
                    	AfxMessageBox("关联点号已定义,请重选!", MB_OK);
                     	delete m_ndkSend;
           	    		break;
					}
				}
				if(kkk == 100)
           	    		return;

				kkk = m_Records1.size();
				  m_listC.InsertItem(kkk, str11);
    			  m_listC.SetItemText(kkk, 1, m_strsel);
    			  m_listC.SetItemText(kkk, 2, str12);
    			  m_listC.SetItemText(kkk, 3, m_strsel2);
		strim2 = str11 +" "+m_strsel+"   "+str12 + " "+m_strsel2+ "   ";  
            m_strsel.Format(_T("%d态"), m_VERIFYT.GetCurSel());
			strim2 += m_strsel+"   "+theApp.curuser;
    			  m_listC.SetItemText(kkk, 4, m_strsel);
            m_strsel.Format(_T("%d"), m_nSecond);
    			  m_listC.SetItemText(kkk, 5, m_strsel);

				  m_Records1.push_back(str11);
				  m_Records2.push_back(str12);
	
				m_Fans.m_szAStatus = m_VERIFYT.GetCurSel();

      						m_Fans.AddNew();  //Add a new, blank record
					   	    m_Fans.Update();    //Update the recordset
						    m_Fans.Requery();
							m_nSecond++;
							}
		     			    catch (CAxException *e)
							{
					        	AfxMessageBox(e->m_szErrorDesc, MB_OK);
				        		delete e;
							}
		theApp.InitData();

      g_Log.StatusOut("双设备报警关系添加:" +strim2);
	}
	else if(chcommand == 0xf1)            //数据显示页属性
	{
      	m_ndkSend = new  unsigned char[11];
		if(m_nSecond <1)
		{
                 	AfxMessageBox("请选择文件名!", MB_OK);
          			return;
		}
    	CString strPointNo,strrsy,strrsy1,strSQL;
		int ishave=0;
		strrsy1 ="dispoint"+strMetrics;
		strrsy.Format("LP%d",m_nSecond);
		CppSQLite3Query q;
		GetDlgItem(IDC_COMBO_PORT)->GetWindowText(cccc);
//				strSQL.Format("UPDATE '%s' SET LP1='' WHERE DISID =0;",
//					strrsy1);
				strSQL.Format("UPDATE '%s' SET '%s'='%s' WHERE DISID =1;",
					strrsy1,strrsy,cccc);
             q = theApp.db3.execQuery(strSQL);
		GetDlgItem(IDC_COMBO_FUNCTION)->GetWindowText(cccc);

		 if(cccc =="1")
		 {
           for(int m =0; m < 25 ;m++)
		   {
			   if(m < 8)
				strSQL.Format("UPDATE '%s' SET '%s'='%s' WHERE DISID = %d;",
					strrsy1,strrsy,m_listC.GetItemText(m,2),m+11);
			   else
				strSQL.Format("UPDATE '%s' SET '%s'='%s' WHERE DISID = %d;",
					strrsy1,strrsy,m_listC.GetItemText(m,2),m+12);
                q = theApp.db3.execQuery(strSQL);
		   }
		 }
		 else if(cccc =="2")
		 {
           for(int m =0; m < 25 ;m++)
		   {
			   if(m < 8)
				strSQL.Format("UPDATE '%s' SET '%s'='%s' WHERE DISID = %d;",
					strrsy1,strrsy,m_listC.GetItemText(m,2),m+111);
			   else
				strSQL.Format("UPDATE '%s' SET '%s'='%s' WHERE DISID = %d;",
					strrsy1,strrsy,m_listC.GetItemText(m,2),m+112);
             q = theApp.db3.execQuery(strSQL);
		   }
		 }
		 else if(cccc =="3")
		 {
           for(int m =0; m < 25 ;m++)
		   {
			   if(m < 8)
				strSQL.Format("UPDATE '%s' SET '%s'='%s' WHERE DISID = %d;",
					strrsy1,strrsy,m_listC.GetItemText(m,2),m+211);
			   else
				strSQL.Format("UPDATE '%s' SET '%s'='%s' WHERE DISID = %d;",
					strrsy1,strrsy,m_listC.GetItemText(m,2),m+212);
             q = theApp.db3.execQuery(strSQL);
		   }
		 }
    	q.finalize();
       AfxMessageBox("保存成功!", MB_OK);
		m_nchange =1000;
	}
	delete m_ndkSend;
}
Esempio n. 8
0
void CSetTimeDlg::OnButRES() 
{
	m_ndkSend = new  unsigned char[166];
    if(chcommand == 0x4B)   //手动控制
	{
		            m_ndkSend[0] = 0x7E;
		     unsigned char nfds = m_VERIFYT.GetCurSel()+1;
		            m_ndkSend[1] = nfds;
		            m_ndkSend[2] = chcommand;
		            m_ndkSend[3] = 0xff;
		            m_ndkSend[4] = 0x02;
		            m_ndkSend[5] = 0x21;
    	CNDKMessage message1(MANUALCONTROL);
					message1.Add(m_ndkSend , 100);
					theApp.Sync(message1,1);
//		m_nchangev = 0;
	}
    else if(chcommand == 0xf0)   //双风门、主扇备扇报警
	{
			CString  dddd ="";
    	int nItemCount=m_listC.GetItemCount();
        for(int nItem=0;nItem<nItemCount;nItem++)
		{
    		if(m_listC.GetItemState(nItem,LVIS_SELECTED) & LVIS_SELECTED)
			{
				dddd = m_listC.GetItemText(nItem,0) +" "+m_listC.GetItemText(nItem,1) +"   " +m_listC.GetItemText(nItem,2) 
					      +" "+m_listC.GetItemText(nItem,3) +"   "+m_listC.GetItemText(nItem,4)+"   "+theApp.curuser;
            	CString strf,strc;
     		    strf = dddd.Mid(0,2);
          		strc = dddd.Mid(3,2);
          		int nfds = m_Str2Data.String2Int(strf);
        		int nchan = m_Str2Data.String2Int(strc);
				int n_fans = m_AFans[nfds][nchan].fchan;
    			if(n_fans == 1)
				{
					nItemCount =666;
	        		break;
				}
	    	   	  m_listC.DeleteItem(nItem);
//       			nItem = m_Str2Data.String2Int(strPointNo);
                  g_Log.StatusOut("双设备报警关系删除:" + dddd);
    	     		break;
			}
		}
        CString strSQL;
		if(dddd =="")
		{
            AfxMessageBox("请选择要删除的设备!", MB_OK);
         	delete m_ndkSend;
			return;
		}
		if(nItemCount == 666)
		{
        	strSQL.Format("%s:设备报警,不能删除!",dddd);
            AfxMessageBox(strSQL, MB_OK);
         	delete m_ndkSend;
			return;
		}
		else
    		m_Fans.Delete();

        if ( m_Fans._IsOpen() )
             m_Fans.Close();
		m_Records1.clear();
		m_Records2.clear();
		m_listC.DeleteAllItems();

		m_Fans.Create();
		m_Fans.CursorType(adOpenDynamic);
		m_Fans.CacheSize(50);
		m_Fans._SetRecordsetEvents(new CAccountSetEvents);
		m_Fans.Open(_T("Select * From fanscon"), &theApp.m_Cn);
		m_Fans.MarshalOptions(adMarshalModifiedOnly);

		int iItem = 0;
		m_Fans.MoveFirst();
		while ( !m_Fans.IsEOF() )
		{
				  CString dddd = m_Fans.m_szpointnum1;
    		dddd.TrimRight();
				  m_listC.InsertItem(iItem, dddd);
				  m_Records1.push_back(dddd);
				  dddd = m_Fans.m_szName1;
    		dddd.TrimRight();
    			  m_listC.SetItemText(iItem, 1, dddd);
				  dddd = m_Fans.m_szpointnum2;
    		dddd.TrimRight();
    			  m_listC.SetItemText(iItem, 2, dddd);
				  m_Records2.push_back(dddd);
				  dddd = m_Fans.m_szName2;
    		dddd.TrimRight();
    			  m_listC.SetItemText(iItem, 3, dddd);
            dddd.Format(_T("%d态"), m_Fans.m_szAStatus);
    			  m_listC.SetItemText(iItem, 4, dddd);
 			m_nSecond = m_Fans.m_szFansID+1;
//            dddd.Format(_T("%d"), m_nSecond-1);
//    			  m_listC.SetItemText(iItem, 5, dddd);
			iItem++;
			m_Fans.MoveNext();
		}
		theApp.InitData();
	}
    else if(chcommand == 0x46)   //风电瓦斯闭锁初始化
	{
		     unsigned char nfds = m_VERIFYT.GetCurSel()+1;
        	CString strSQL;
		if(m_SerialF[nfds].SFSd ==0)
		{
        	strSQL.Format("%d号分站没有巡检!",nfds);
            AfxMessageBox(strSQL, MB_OK);
         	delete m_ndkSend;
			return;
		}
		for(int i =0; i < 6 ;i++)//风电瓦斯闭锁关系定义的测点正常时可以初始化、修改
		{
        	CString strf,strc;
			if(str_list[i].strl =="")
				break;
		    strf = str_list[i].strl.Mid(0,2);
    		strc = str_list[i].strl.Mid(3,2);
    		int nfds = m_Str2Data.String2Int(strf);
     		int nchan = m_Str2Data.String2Int(strc);
			unsigned char nstatus = m_SlaveStation[nfds][nchan].Channel_state;
			if(nstatus == 0x10 || nstatus == 0x20 || nstatus == 0xa0)
			{
            	strSQL.Format("%d号分站%s状态为%s,不能初始化!",nfds,str_list[i].strl,theApp.m_RTDM.strstatus(nstatus));
                AfxMessageBox(strSQL, MB_OK);
            	delete m_ndkSend;
	    		return;
			}
		}
			strSQL.Format("%d号分站风电瓦斯闭锁初始化,此操作将删除%d号分站风电瓦斯闭锁配置,是否继续操作?",nfds,nfds);
           int Reply = AfxMessageBox(strSQL, MB_YESNO);
           if ( Reply != IDYES )
		   {
            	delete m_ndkSend;
        		return;
		   }
		            m_ndkSend[0] = 0x7E;
		            m_ndkSend[1] = nfds;
		            m_ndkSend[2] = chcommand;
		            m_ndkSend[3] = 0xff;     m_ndkSend[4] = 0xff;     m_ndkSend[5] = 0xff;
		            m_ndkSend[6] = 0xff;     m_ndkSend[7] = 0xff;     m_ndkSend[8] = 0xff;
		            m_ndkSend[9] = 0x21;
                	CNDKMessage message1(WINDGASATRESIA);
					message1.Add(m_ndkSend , 100);
					theApp.Sync(message1,1);

            	for( i =0;i<6;i++)
             		str_list[i].strl="";
            	strSQL.Format("设置%d号分站风电瓦斯闭锁初始化!",nfds);
                AfxMessageBox(strSQL, MB_OK);
                g_Log.StatusOut(strSQL);
	}
    else if(chcommand == 0x5A)   //故障闭锁初始化
	{
        	CString strSQL;
			strSQL.Format("故障闭锁初始化,此操作将删除60个分站故障闭锁配置,是否继续操作。");
           int Reply = AfxMessageBox(strSQL, MB_YESNO);
           if ( Reply != IDYES )
		   {
            	delete m_ndkSend;
        		return;
		   }
    	CMainFrame* pFWnd=(CMainFrame*)AfxGetMainWnd();
		pFWnd->n_derr60 =1;
	}
	else if(chcommand == 0x43)       //配置测点初始化
	{
		     unsigned char nfds = m_VERIFYT.GetCurSel()+1;
     	CString strim2;
		if(m_SerialF[nfds].SFSd ==0)
		{
        	strim2.Format("%d号分站没有巡检!",nfds);
            AfxMessageBox(strim2, MB_OK);
         	delete m_ndkSend;
			return;
		}
			strim2.Format("%d号分站测点配置初始化,此操作将删除%d号分站测点配置,是否继续操作?",nfds,nfds);
           int Reply = AfxMessageBox(strim2, MB_YESNO);
           if ( Reply != IDYES )
		   {
            	delete m_ndkSend;
        		return;
		   }
		            m_ndkSend[0] = 0x7E;
		            m_ndkSend[1] = nfds;
		            m_ndkSend[2] = 0x43;
					strim2.Format("%x|%x|%x",m_ndkSend[0],m_ndkSend[1],m_ndkSend[2]);
				ComDisMes(strim2);

        for(int i=1;i<17 ;i++)
		{
		            m_ndkSend[i*10-7] = 0xff;
		            m_ndkSend[i*10-6] = 0xff;      //
		            m_ndkSend[i*10-5] = 0xff;
		            m_ndkSend[i*10-4] = 0xff;      //
		            m_ndkSend[i*10-3] = 0xff;
		            m_ndkSend[i*10-2] = 0xff;      //
		            m_ndkSend[i*10-1] = 0xff;
		            m_ndkSend[i*10] = 0xff;     //
		            m_ndkSend[i*10+1] = 0xff;
		            m_ndkSend[i*10+2] = 0xff;      //

			strim2.Format("%x|%x|%x|%x|%x|%x|%x|%x|%x|%x    %d|%d|%d|%d|%d|%d|%d|%d|%d|%d",m_ndkSend[i*10-7],m_ndkSend[i*10-6],m_ndkSend[i*10-5],m_ndkSend[i*10-4],m_ndkSend[i*10-3],m_ndkSend[i*10-2],m_ndkSend[i*10-1],
				m_ndkSend[i*10],m_ndkSend[i*10+1],m_ndkSend[i*10+2],
				m_ndkSend[i*10-7],m_ndkSend[i*10-6],m_ndkSend[i*10-5],m_ndkSend[i*10-4],m_ndkSend[i*10-3],m_ndkSend[i*10-2],m_ndkSend[i*10-1],
				m_ndkSend[i*10],m_ndkSend[i*10+1],m_ndkSend[i*10+2]);
			ComDisMes(strim2);
		}
		            m_ndkSend[163] = 0xff;      //控制量类型
		            m_ndkSend[164] = 0xff;      //
		            m_ndkSend[165] = 0x21;      //
					strim2.Format("%x|%x|%x",m_ndkSend[163],m_ndkSend[164],m_ndkSend[165]);
    	CNDKMessage message1(SENDCONFIG);
					message1.Add(m_ndkSend , 200);
					theApp.Sync(message1,1);
				ComDisMes(strim2);
		strim2.Format("%d号分站测点初始化。",nfds);
        AfxMessageBox(strim2, MB_OK);
       g_Log.StatusOut( strim2 );
	}
	delete m_ndkSend;
}
Esempio n. 9
0
static void
sound_warning (const char *msg)
{
  message1 (msg);
}
Esempio n. 10
0
int RPC::dispatch(Disk& disk)
{
  char buf[NDISK_BLOCK_SIZE];
  char packet[NDISK_BLOCK_SIZE + 8];

  size_t len = NDISK_BLOCK_SIZE + 8;
  char *msg = packet;

  if (disk.block_size() != NDISK_BLOCK_SIZE)
    return DISK_ERROR;

  // Read the packet (with 8-byte header)
  do
  {
    ssize_t nread = recv(sock, msg, len, 0);

    if (nread <= 0)
      return DISK_ERROR;

    len -= nread;
    msg += nread;
  }
  while (len > 0);

  // Get the command from the packet's first four bytes
  char command[5];
  memcpy(command, packet, 4);
  command[4] = '\0';

  // Get the block number parameter from the packet
  int block_num = ston(packet + 4);

  if (!strcmp(command, "NUMB"))
  {
    // Write num blocks into packet data
    ntos(packet + 8, disk.num_blocks());
  }
  else if (!strcmp(command, "FRMT"))
  {
    disk.format(block_num);
  }
  else if (!strcmp(command, "READ"))
  {
    disk.read(block_num, buf);
    memcpy(packet + 8, buf, NDISK_BLOCK_SIZE);
  }
  else if (!strcmp(command, "WRTE"))
  {
    memcpy(buf, packet + 8, NDISK_BLOCK_SIZE);
    disk.write(block_num, buf);
  }
  else
  {
    message1("Unknown RPC command %s\n", command);
  }

  message2("RPC command %s(%d)\n", command, block_num);

  len = NDISK_BLOCK_SIZE + 8;
  msg = packet;

  // Write the packet (with 8-byte header)
  do
  {
    ssize_t nwritten = send(sock, msg, len, 0);

    if (nwritten < 0)
      return DISK_ERROR;

    len -= nwritten;
    msg += nwritten;
  }
  while (len > 0);

  return DISK_OK;
}
  void testCycleWithGzipChain ()
  {
    u_long cycleLog = 40;
    list<string> filters;
    string message ("The quick brown fox jumped over the lazy dog.");
    string message1 ("Yet another short log message.");
    string gotMessage;
    string gotMessage1;
    File f;
    char gzipComp[128];
    char gzipDecomp[128];
    GzipDecompress gzdc;
    size_t nbr = 0;
    list<string> cs;
    list<string>::iterator it;
    LogStream* ls = NULL;

    try
      {
        FilesUtility::deleteFile ("fooc");
      }
    catch (...)
      {
      }

    filters.push_back ("gzip");
    lm->add (this, "test", "file://fooc", filters, cycleLog);
    lm->log (this, "test", "file://fooc", message);
    lm->log (this, "test", "file://fooc", message1);
    f.openFile ("fooc", File::READ | File::OPEN_IF_EXISTS);
    f.read (gzipComp, 128, &nbr);
    f.close ();
    gzdc.decompress (&gzipComp[gzdc.headerSize ()],
                     nbr - gzdc.headerSize (),
                     gzipDecomp, 128);
    gzipDecomp[message1.size ()] = '\0';
    gotMessage1.assign (gzipDecomp);
    lm->get (this, "test", "file://fooc", &ls);
    CPPUNIT_ASSERT (ls);
    cs = ls->getCycledStreams ();
    for (it = cs.begin (); it != cs.end (); it++)
      {
        f.openFile (*it, File::READ | File::OPEN_IF_EXISTS);
        f.read (gzipComp, 128, &nbr);
        f.close ();
        gzdc.decompress (&gzipComp[gzdc.headerSize ()],
                         nbr - gzdc.headerSize (),
                         gzipDecomp, 128);
        gzipDecomp[message.size ()] = '\0';
        gotMessage.assign (gzipDecomp);

        try
          {
            FilesUtility::deleteFile (*it);
          }
        catch (...)
          {
          }
      }
    lm->close (this);

    try
      {
        FilesUtility::deleteFile ("fooc");
      }
    catch (...)
      {
      }

    CPPUNIT_ASSERT (!message1.compare (gotMessage1));
    CPPUNIT_ASSERT (!message.compare (gotMessage));
  }
  void testFileStreamCycle ()
  {
    string message ("A message\n");
    string message1 ("Another message\n");
    string gotMessage;
    string gotMessage1;
    list<string> filters;
    File f;
    char buf[64];
    size_t nbr;
    LogStream* ls = NULL;
    list<string> cs;
    list<string>::iterator it;
    try
      {
        FilesUtility::deleteFile ("foobar");
      }
    catch (...)
      {
      }

    lm->add (this, "test", "file://foobar", filters, 10);
    lm->log (this, "test", "file://foobar", message);
    lm->log (this, "test", "file://foobar", message1);
    lm->close (this, "test", "file://foobar");

    f.openFile ("foobar", File::READ | File::OPEN_IF_EXISTS);
    f.read (buf, 64, &nbr);
    buf[nbr] = '\0';
    f.close ();
    gotMessage1.assign (buf);

    lm->get (this, "test", "file://foobar", &ls);
    CPPUNIT_ASSERT (ls);
    cs = ls->getCycledStreams ();
    for (it = cs.begin (); it != cs.end (); it++)
      {
        f.openFile (*it, File::READ | File::OPEN_IF_EXISTS);
        f.read (buf, 64, &nbr);
        buf[nbr] = '\0';
        f.close ();
        gotMessage.assign (buf);
        try
          {
            FilesUtility::deleteFile (*it);
          }
        catch (...)
          {
          }
      }

    lm->close (this);

    try
      {
        FilesUtility::deleteFile ("foobar");
      }
    catch (...)
      {
      }

    CPPUNIT_ASSERT (!message1.compare (gotMessage1));
    CPPUNIT_ASSERT (!message.compare (gotMessage));
  }
Esempio n. 13
0
void pf_mult_shot_deff (void)
{
	message1 (&font_fixed10, "ADVANCE SHOT");
}
Esempio n. 14
0
void pf_mult_advance_deff (void)
{
	message1 (&font_fixed6, "ADV. MULTIPLIER");
}