本文介绍了如果未连接到网络,如何在设备上存储信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 您好,我正在使用raspberry pi创建一个数据采集系统,将测量的传感器值添加到缓冲区(类型列表)并将信息写入每隔x秒清除缓冲区之前的SQL Server数据库(使用WPF服务)。我目前正在努力保持连接,而在某些时候运行这个应用程序。我想用某种方法来检查我是否已连接到网络。如果我是,我想在清除之前将缓冲区写入数据库。如果我没有连接,我想继续将添加到缓冲区再次进行x秒的迭代。I'm working with the raspberry pi to create a Data Acquisition system that Adds measured sensor values to a buffer (type List) and writes the information to a SQL Server database (using a WPF service) before clearing the buffer every x seconds. I'm currently struggling to stay connected while running this App some of the time. I want some way to check if I'm connected to the network. If I am, I want to be write the buffer to the database before clearing it. If I'm not connected, I would like to continue to add to the buffer for another iteration of x seconds before checking again. public override void ProcessData(float value) { //将传感器测量值添加到缓冲区 dataBuffer.Add(new SensorService.RawDataValue(){TimeStamp = DateTime 。现在,值=值}); //Add sensors measured value to buffer dataBuffer.Add(new SensorService.RawDataValue() { TimeStamp = DateTime.Now, Value = value }); //如果是时候写缓冲区 if((LastWriteTime.AddSeconds(DataOutputSeconds)< DateTime.Now))//如果数据缓冲区足够大,发送到服务 { //If it is time to write the buffer if ((LastWriteTime.AddSeconds(DataOutputSeconds) < DateTime.Now))//If data buffer is big enough, send to service { SensorService.DataServiceClient client = new SensorService.DataServiceClient(); //启动新客户端 SensorService.RawData rawData =新的SensorService.RawData(); rawData.SensorID = this.ParentSensor.SensorID; rawData.ProgramID = this.ProgramID; rawData.SensorName = this.ParentSensor.SensorName; rawData.deviceID = this.ParentSensor.DeviceID; rawData.ProgramName = this.ProgramName; rawData.RawDataValues = new ObservableCollection< SensorService.RawDataValue>(dataBuffer as List< SensorService.RawDataValue>); //将整个缓冲区发送到客户端 client.SendRawDataAsync(rawData); SensorService.DataServiceClient client = new SensorService.DataServiceClient();//start new client SensorService.RawData rawData = new SensorService.RawData(); rawData.SensorID = this.ParentSensor.SensorID; rawData.ProgramID = this.ProgramID; rawData.SensorName = this.ParentSensor.SensorName; rawData.deviceID = this.ParentSensor.DeviceID; rawData.ProgramName = this.ProgramName; rawData.RawDataValues = new ObservableCollection<SensorService.RawDataValue>(dataBuffer as List<SensorService.RawDataValue>);//send entire buffer to client client.SendRawDataAsync(rawData); //设置上次写入到现在 LastWriteTime = DateTime.Now; //set last write to to now LastWriteTime = DateTime.Now; //清除数据缓冲区 dataBuffer.Clear(); //client.CloseAsync(); } //clear data buffer dataBuffer.Clear(); //client.CloseAsync(); }推荐答案似乎标题没有反映内容基于标题你似乎想知道如何在Windows 10 IoT核心设备上存储数据,答案可能是SQLite,但基于您搜索网络可用性检查的内容based on the title it seems you want to know how to store data on a Windows 10 IoT Core device, the answer could be SQLite but based on the content you search for a network availability check NetworkInformation 提供对网络连接信息的访问 https://docs.microsoft.com/en-us/uwp/api/windows。 networking.connectivity.networkinformationNetworkInformation provides access to network connection informationhttps://docs.microsoft.com/en-us/uwp/api/windows.networking.connectivity.networkinformation IoT核心默认应用( https://github.com/Microsoft/Windows-iotcore-samples/tree/develop/Samples/IoTCoreDefaultApp )以及本教程 http://windowsapptutorials.com/windows-10/how-to-check-for-network-availability-in-universal -windows-apps / 显示其工作原理the IoT Core Default App (https://github.com/Microsoft/Windows-iotcore-samples/tree/develop/Samples/IoTCoreDefaultApp) and also this tutorialhttp://windowsapptutorials.com/windows-10/how-to-check-for-network-availability-in-universal-windows-apps/ shows how it works br AndrebrAndre 这篇关于如果未连接到网络,如何在设备上存储信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的..
09-08 05:56