什么是上位機(jī)_上位機(jī)軟件介紹
{
byte[] frame = new byte[5];
frame[0] = 0x05;
Array.Copy(Zuohao, 0, frame, 1, 2);
frame[3] = mingling;
byte temp = 0;
foreach (byte item in frame)
temp += item;
frame[4] = (byte)(0 - temp);
byte[] frametosend = PPP.Encode(frame);
Console.WriteLine(BitConverter.ToString(frametosend));
try { stream.Write(frametosend, 0, frametosend.Length); }
catch (Exception ex) { }
}
}
/// summary>
/// 向ARM發(fā)送
/// /summary>
/// param name=Zuohao>座號(hào) 2字節(jié)/param>
/// param name=mingling>命令字加ASC碼 n字節(jié)/param>
public void WriteToArm(byte[] Zuohao, byte[] minglingandASC)
{
if (connection == Indicator.Connected)//在與ARM保持連接的情況下可寫
{
byte[] frame = new byte[4+minglingandASC.Length];
frame[0] = (byte)frame.Length;
Array.Copy(Zuohao, 0, frame, 1, 2);
Array.Copy(minglingandASC,0,frame,3,minglingandASC.Length);
byte temp = 0;
foreach (byte item in frame)
temp += item;
frame[frame.Length-1] = (byte)(0 - temp);
byte[] frametosend = PPP.Encode(frame);
Console.WriteLine(BitConverter.ToString(frametosend));
try { stream.Write(frametosend, 0, frametosend.Length); }
catch (Exception ex) { }
}
}本文引用地址:http://www.ex-cimer.com/article/185790.htm
另外數(shù)據(jù)收發(fā)還需要協(xié)議,和嵌入式網(wǎng)關(guān)通信的指令和協(xié)議定制如下:
因此數(shù)據(jù)量較少,協(xié)議也就比較簡(jiǎn)單,此協(xié)議在發(fā)送接收時(shí)用PPP封裝。顯示部分使用C#編寫的運(yùn)行于Windows .Net Framework 上的窗體應(yīng)用程序,根據(jù)實(shí)際需求,對(duì)每個(gè)實(shí)驗(yàn)臺(tái)狀態(tài)的顯示使用ListView控件實(shí)現(xiàn),當(dāng)出現(xiàn)異常情況,或?qū)嶒?yàn)臺(tái)出現(xiàn)警告、求助信號(hào)時(shí),ListView的相應(yīng)字段文字會(huì)通過改變顏色來提醒監(jiān)視人員,監(jiān)視人員還可以通過一個(gè)文字發(fā)送窗體來向LED屏發(fā)送要顯示的文字。總之界面清晰直觀,簡(jiǎn)便易用。
評(píng)論