<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 模擬技術(shù) > 設(shè)計應(yīng)用 > 什么是上位機_上位機軟件介紹

          什么是上位機_上位機軟件介紹

          作者: 時間:2012-09-05 來源:網(wǎng)絡(luò) 收藏

          什么是
          是一臺可以發(fā)出特定操控命令的計算機,通過操作預先設(shè)定好的命令,將命令傳遞給下位機,通過下位機來控制設(shè)備完成各項操作(應(yīng)用最多的地方如:工業(yè)、水利、供電部門、交通等方面)。都有特定的編程,有專門的開發(fā)系統(tǒng),或以上是已經(jīng)規(guī)定好任務(wù),只能按特定的任務(wù)進行操作。簡單說上位機就是命令的下達者,而下位機則是命令的執(zhí)行者。

          本文引用地址:http://www.ex-cimer.com/article/185790.htm

          上位機
          下面介紹一種軟件:物聯(lián)網(wǎng)應(yīng)用中收集感知節(jié)點信息,進行顯示,控制的應(yīng)用控制臺。此軟件主要有兩部分組成,數(shù)據(jù)收發(fā)部分和顯示部分
          1、上位機在系統(tǒng)中的位置:處于網(wǎng)絡(luò)層中,與嵌入式網(wǎng)關(guān)通過網(wǎng)線相連。實際應(yīng)用時是放置在實驗室的老師工作臺上,供實驗室的老師使用。
          2、上位機的功能:此軟件實時監(jiān)視實驗實中每個實驗臺的狀況,包括上電或斷電狀態(tài),實驗臺是否發(fā)出了警告,是否發(fā)出了求助信號,并對這些信號做出應(yīng)答,還控制LED屏的文字顯示。
          3、上位機的設(shè)計實現(xiàn): 此軟件主要有兩部分組成,數(shù)據(jù)收發(fā)部分和顯示部分。數(shù)據(jù)收發(fā)指的是和嵌入式網(wǎng)關(guān)的數(shù)據(jù)收發(fā)。兩者是通過網(wǎng)線連接的,所以應(yīng)用的是TCP/IP 的Socket 套接字編程,嵌入式網(wǎng)關(guān)的設(shè)計中已經(jīng)提到過,它在和上位機通信中是作為服務(wù)器的,那么上位機就是作為連接發(fā)起方。為了能保證網(wǎng)絡(luò)連接的穩(wěn)定性,我們把Socket讀寫的程序代碼放在了try{} catch(){} 塊中,一旦網(wǎng)絡(luò)連接不正常,就會捕獲到該異常,從而關(guān)閉程序。
          4、關(guān)鍵代碼如下:
          private void ReadFromArm()
          {
          byte[] buffertocheck = new byte[1];
          int bytesize = 0;
          do
          {
          byte[] bufferofread = new byte[1024];
          try { bytesize = stream.Read(bufferofread, 0, bufferofread.Length); }
          catch (Exception ex) { connection = Indicator.Unconnected; MessageBox.Show(連接中斷,程序?qū)⑼顺觥?; Application.Exit(); read.Abort(); }
          //MessageBox.Show(BitConverter.ToString(bufferofread));
          byte[] buffertochecktemp = buffertocheck;
          buffertocheck = new byte[buffertochecktemp.Length + bytesize];
          Array.Copy(buffertochecktemp, 0, buffertocheck, 0, buffertochecktemp.Length);
          Array.Copy(bufferofread, 0, buffertocheck, buffertochecktemp.Length, bytesize);
          int index_1, index_2;
          while (Check7E(buffertocheck, out index_1, out index_2))
          {
          byte[] buffertodecode = new byte[index_2 + 1 - index_1];
          Array.Copy(buffertocheck, index_1, buffertodecode, 0, index_2 + 1 - index_1);
          byte[] bufferofdecode = PPP.Decode(buffertodecode);
          //MessageBox.Show(BitConverter.ToString(bufferofdecode));
          if (bufferofdecode[0] == bufferofdecode.Length CheckSum(bufferofdecode))//保證從ARM來的幀是正確的
          {
          byte[] Zuohao = new byte[2];
          int subindex = 1, index = bufferofdecode[1]*256+bufferofdecode[2]-1;
          string status=null;
          switch (bufferofdecode[3])//分別處理從ARM來的幀
          {

          case POWER_ON://從ARM來的上電狀態(tài)
          status = 上電;
          subindex = 1;
          break;
          case POWER_OFF://從ARM來的斷電狀態(tài)
          status = 斷電;
          subindex = 1;
          break;
          case ABNORMAL://從ARM來的異常狀態(tài)
          status = 異常;
          subindex = 1;
          break;
          case WARNING://從ARM來的警告信號
          status = 有;
          subindex = 2;
          break;
          case NEED_HELP://從ARM來的求救信號
          status = 有;
          subindex = 3;
          break;
          }
          if (0 = index index = 49)
          {
          listView1.Items[index].SubItems[subindex].Text = status;
          if (status == 異常 || status == 有)
          listView1.Items[index].SubItems[subindex].ForeColor = Color.Red;
          else
          listView1.Items[index].SubItems[subindex].ForeColor = Color.Black;
          }
          }
          int newlength = buffertocheck.Length - 1 - index_2;
          if (newlength == 0)
          {
          buffertocheck = new byte[1];
          }
          else
          {
          buffertochecktemp = buffertocheck;
          buffertocheck = new byte[newlength];
          Array.Copy(buffertochecktemp, index_2 + 1, buffertocheck, 0, newlength);
          }
          }
          } while (connection == Indicator.Connected);
          }
          /// summary>
          /// 向ARM發(fā)送
          /// /summary>
          /// param name=Zuohao>座號 2字節(jié)/param>
          /// param name=mingling>命令字 1字節(jié)/param>
          public void WriteToArm(byte[] Zuohao, byte mingling)
          {
          if (connection == Indicator.Connected)//在與ARM保持連接的情況下可寫


          上一頁 1 2 下一頁

          關(guān)鍵詞: 上位機 軟件介紹

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();