新聞中心

        EEPW首頁 > 模擬技術 > 設計應用 > 什么是上位機_上位機軟件介紹

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

        作者: 時間:2012-09-05 來源:網絡 收藏

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

        本文引用地址:http://www.104case.com/article/185790.htm

        上位機
        下面介紹一種軟件:物聯網應用中收集感知節點信息,進行顯示,控制的應用控制臺。此軟件主要有兩部分組成,數據收發部分和顯示部分
        1、上位機在系統中的位置:處于網絡層中,與嵌入式網關通過網線相連。實際應用時是放置在實驗室的老師工作臺上,供實驗室的老師使用。
        2、上位機的功能:此軟件實時監視實驗實中每個實驗臺的狀況,包括上電或斷電狀態,實驗臺是否發出了警告,是否發出了求助信號,并對這些信號做出應答,還控制LED屏的文字顯示。
        3、上位機的設計實現: 此軟件主要有兩部分組成,數據收發部分和顯示部分。數據收發指的是和嵌入式網關的數據收發。兩者是通過網線連接的,所以應用的是TCP/IP 的Socket 套接字編程,嵌入式網關的設計中已經提到過,它在和上位機通信中是作為服務器的,那么上位機就是作為連接發起方。為了能保證網絡連接的穩定性,我們把Socket讀寫的程序代碼放在了try{} catch(){} 塊中,一旦網絡連接不正常,就會捕獲到該異常,從而關閉程序。
        4、關鍵代碼如下:
        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(連接中斷,程序將退出。); 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來的上電狀態
        status = 上電;
        subindex = 1;
        break;
        case POWER_OFF://從ARM來的斷電狀態
        status = 斷電;
        subindex = 1;
        break;
        case ABNORMAL://從ARM來的異常狀態
        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發送
        /// /summary>
        /// param name=Zuohao>座號 2字節/param>
        /// param name=mingling>命令字 1字節/param>
        public void WriteToArm(byte[] Zuohao, byte mingling)
        {
        if (connection == Indicator.Connected)//在與ARM保持連接的情況下可寫


        上一頁 1 2 下一頁

        關鍵詞: 上位機 軟件介紹

        評論


        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 大庆市| 保康县| 韶关市| 沧源| 九龙县| 临泉县| 大港区| 团风县| 阿克苏市| 易门县| 梁河县| 涞水县| 侯马市| 建昌县| 绩溪县| 民权县| 栾川县| 赣州市| 常山县| 平湖市| 滦平县| 弥渡县| 盐亭县| 广昌县| 阜新市| 岳普湖县| 株洲县| 正定县| 防城港市| 新巴尔虎左旗| 六安市| 水富县| 长阳| 醴陵市| 东乌| 宁波市| 雷波县| 天峻县| 女性| 西乌珠穆沁旗| 枣阳市|