<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 電源與新能源 > 設計應用 > 基于電力線(xiàn)傳輸媒介的通信終端設計

基于電力線(xiàn)傳輸媒介的通信終端設計

作者: 時(shí)間:2010-11-05 來(lái)源:網(wǎng)絡(luò ) 收藏

  首先使用Qt 的工具Qt Designer 設計界面。然后進(jìn)入具體的客戶(hù)端編程階段,構造一個(gè)窗體類(lèi)為T(mén)cpClient 類(lèi),具體的軟件編寫(xiě)如下:

  TcpClient::TcpClient(QWidget *parent)

 ?。?QWidget(parent)

  {

  ui.setupUi(this);

  adsocket= new QTcpSocket(this); //用以傳輸A/D數據的TCP通道

  tempsocket= new QTcpSocket(this); //用以傳輸溫度數據的TCP通道

  applincesocket= new QTcpSocket(this); //用以控制家用電器的TCP通道

  securitysocket = new QTcpSocket(this); //用以安防系統報警的TCP通道

  QTimer *temptimer = new QTimer(this); //2S的定時(shí)器

  connect(temptimer,SIGNAL(timeout()),this,SLOT(temp_update()));

  temptimer->start(2000);

  connect( adsocket,SIGNAL( connected() ),this, SLOT( ad_request() ) );

  connect( adsocket,SIGNAL( readyRead() ), this, SLOT( ad_readresult() ) );

  connect( tempsocket,SIGNAL( connected() ),this,SLOT( lm_request() ) );

  connect( tempsocket,SIGNAL( readyRead() ),this,SLOT( lm_readresult() ) );

  connect(appliancesocket,SIGNAL( connected() ), this,SLOT( appliance_request() ) );

  connect(securitysocket,SIGNAL( readyRead() ),this,SLOT( security_readresult() ) );

  }

  動(dòng)態(tài)分配四個(gè)QTcpSocket(Qt 內部對于TCP 協(xié)議的封裝類(lèi))對象,分別用該類(lèi)的對象指針adsocket、tempsocket、appliancesocket、securitysocket 來(lái)指向這四個(gè)對象。然后定義一個(gè)QTimer對象,用來(lái)實(shí)現2 秒的定時(shí)。接著(zhù)對一些信號和槽進(jìn)行連接,從而完成各個(gè)組件之間的通訊,其中: QTimer 對象的timeout 信號和temp_update()槽連接、adsocket 對象的connected 信號和ad_request()連接,adsocket 對象的readyRead 信號和ad_readresult()槽。同理連接其他的幾個(gè)QTckSocket 對象的信號和槽。

  以下,具體描述如何實(shí)現溫度檢測和空調自動(dòng)控制的功能(其他功能的實(shí)現類(lèi)似,就不贅述):(1)定時(shí)器每隔2S 觸發(fā)一次,客戶(hù)端使用tempsocket 連接服務(wù)器端后發(fā)送測溫請求。(2)接收到服務(wù)器的溫度數據后在界面上顯示,并且根據要求決定是否需要啟動(dòng)空調。(3)利用appliancesocket 發(fā)送開(kāi)啟或者關(guān)閉空調的命令。并根據服務(wù)器端的執行結果修改空調開(kāi)關(guān)狀態(tài)欄顯示。

  五、結論

  在實(shí)際的測試中,服務(wù)器端運行在實(shí)驗室,連接有日光燈、電飯煲和空調??蛻?hù)端運行在寢室中。本應用在實(shí)現所有功能的基礎上,線(xiàn)終端作為服務(wù)器連續開(kāi)機一周,并進(jìn)行高流量的負荷測試,能夠穩定運行,所有功能均表現正常,沒(méi)有發(fā)生故障。從而驗證了本終端的穩定性和該智能家居應用的可行性。



上一頁(yè) 1 2 3 下一頁(yè)

關(guān)鍵詞: 電力 通信

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>