public TelosbSensor(UInt16 Id, TelosbConfig newconfig) { id = Id; type = (int)SensorType.TELOSB; online = true; online_t = false; port = -1; for (int i = 0; i < 2; i++) { telosbdata[i] = 0; } if (Id == newconfig.id) { config = newconfig.config; } temperature = 0.0; humidity = 0.0; newindata = false; uploadcreatenewfile = true; }
private void ReadConfig(string dir, ref ArrayList array,int mode) { FileStream fs; StreamReader sr; var fileMode = FileMode.Open; fs = new FileStream(dir, fileMode, FileAccess.Read); sr = new StreamReader(fs, Encoding.Default); if (mode == 1) { try { while (true) { string line = sr.ReadLine(); if(line.StartsWith("#")) continue; if(line.Length<3) continue; string[] split1 = line.Split(':'); string[] split2 = split1[1].Split(','); TemperatureConfig newconfig = new TemperatureConfig(); try { newconfig.id = UInt16.Parse(split1[0]); for (int i = 0; i < 16; i++) { newconfig.config[i] = int.Parse(split2[i]); } } catch { } Temperatureconfig.Add(newconfig); } } catch { } } else if (mode == 2) { try { while (true) { string line = sr.ReadLine(); if (line.StartsWith("#")) continue; if (line.Length < 3) continue; string[] split1 = line.Split(':'); string[] split2 = split1[1].Split(','); FlowrateConfig newconfig = new FlowrateConfig(); try { newconfig.id = UInt16.Parse(split1[0]); for (int i = 0; i < 8; i++) { newconfig.config[i] = int.Parse(split2[i]); } } catch { } Flowrateconfig.Add(newconfig); } } catch { } } else if(mode ==3) { try { while (true) { string line = sr.ReadLine(); if (line.StartsWith("#")) continue; if (line.Length < 3) continue; string[] split1 = line.Split(':'); TelosbConfig newconfig = new TelosbConfig(); try { newconfig.id = UInt16.Parse(split1[0]); newconfig.config = int.Parse(split1[1]); } catch { } Telosbconfig.Add(newconfig); } } catch { } } else if (mode == 4) { try { while (true) { string line = sr.ReadLine(); if (line.StartsWith("#")) continue; if (line.Length < 3) continue; string[] split1 = line.Split(':'); if (split1.Length == 4) { UInt16 id; try { id = UInt16.Parse(split1[0]); } catch { continue; } int type = -1; if (split1[1] == "TEMPERATURE") type = (int)SensorType.TEMPBOARD; else if (split1[1] == "FLOWRATE" || split1[1] == "PUMP") type = (int)SensorType.PUMPBOARD; else continue; if (Boardconfig.Contains(id) == false) { BoardConfig newconfig = new BoardConfig(id, type); Boardconfig.Add(newconfig); } int i = Boardconfig.IndexOf(id); if(i>=0) ((BoardConfig)Boardconfig[i]).SetConfig(split1); } } } catch { } } else { } }
public TelosbSensor(UInt16 Id,TelosbConfig newconfig) { id = Id; type = (int)SensorType.TELOSB; online = true; online_t = false; port = -1; for (int i = 0; i < 2; i++) telosbdata[i] = 0; if (Id == newconfig.id) config = newconfig.config; temperature = 0.0; humidity = 0.0; newindata = false; uploadcreatenewfile = true; }