private void sendvolumedata() { while (sendvolumeflag) { string strData = "0"; try { string line; // 创建一个 StreamReader 的实例来读取文件 ,using 语句也能关闭 StreamReader using (System.IO.StreamReader sr = new System.IO.StreamReader("data.txt")) { // 从文件读取并显示行,直到文件的末尾 while ((line = sr.ReadLine()) != null) { //Console.WriteLine(line); strData = line; Data.volume.volume = Convert.ToDecimal(strData); } } } catch (Exception e) { // 向用户显示出错消息 Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } Console.WriteLine(strData); try { cloud.cloudnet.Send(DeviceNet.DeviceDataToPackage(Data.GetData(), Messagetype.volumepackage)); Thread.Sleep(500); } catch (Exception ex) { ErrorMessage.GetError(ex); return; } } sendvolumeflag = true; }
/// <summary> /// 更新服务端上的设备核心数据 /// </summary> private void updateTODO() { cloud.cloudnet.Send(DeviceNet.DeviceDataToPackage(cloud.Data.GetData(), Messagetype.package)); Console.WriteLine("succeed"); }
/// <summary> /// 服务端传达监控指令 /// </summary> private void monitor() { cloud.cloudnet.Send(DeviceNet.DeviceDataToPackage(Data.GetData(), Messagetype.carinfomessage)); }