protected override AnalogicDataRegisterDE ReadValues(FileStream fstream, string Name, long HeaderLen, DateTime dateHourMinute) { AnalogicDataRegisterDE measurement; DateTime DataDosValores; char[] Dbuffer; BitArray myBA; fstream.Position = HeaderLen - DataDosValoresLen; Dbuffer = new char[DataDosValoresLen]; r.Read(Dbuffer,0,DataDosValoresLen); DataDosValores = ConvertDateTime.DateVmsToDateTime(Dbuffer,"pt-BR"); fstream.Position = HeaderLen + ((int) htHeader[Name] * NumBValGr); float measAux = r.ReadSingle(); float estimAux = r.ReadSingle(); byte[] BBuffer = new byte[NumBValGr - 8]; BBuffer = r.ReadBytes(NumBValGr - 8); if(BBuffer.Length > 1) { byte[] aux = new byte[1]; aux[0] = BBuffer[1]; myBA = new BitArray(aux); } else myBA = new BitArray(BBuffer); if(DataDosValores.Date == dateHourMinute.Date) measurement = new AnalogicDataRegisterDE(dateHourMinute,Name,measAux,estimAux,myBA); else measurement = new AnalogicDataRegisterDE(Name,dateHourMinute,true); return measurement; }
protected override AnalogicDataRegisterDE ReadValues(FileStream fstream, string Name, long HeaderLen, DateTime dateHourMinute) { BitArray myBA; fstream.Position = HeaderLen + ((int) htHeader[Name] * NumBValGr); float measAux = r.ReadSingle(); byte[] BBuffer = new byte[NumBValGr - 4]; BBuffer = r.ReadBytes(NumBValGr - 4); if(BBuffer.Length > 1) { byte[] aux = new byte[1]; aux[0] = BBuffer[1]; myBA = new BitArray(aux); } else myBA = new BitArray(BBuffer); AnalogicDataRegisterDE measurement = new AnalogicDataRegisterDE(dateHourMinute,Name,measAux,0,myBA); return measurement; }
public AnalogicDataRegisterDE[] GetValues(string[] pointName, DateTime dateHourMinute) { ArrayList dataslist = new ArrayList(); AnalogicDataRegisterDE[] measurements = null; AnalogicDataRegisterDE measurement; int NumMinutes = dateHourMinute.Hour * 60 + dateHourMinute.Minute; if(dateHourMinute <= LastUpdate) { if(FileExists) { fs = new FileStream(DataFileName, FileMode.Open, FileAccess.Read); r = new BinaryReader(fs); long headerLen = (NumGRLen + DataUltimaAtuLen + NumBValGrLen) + (NumGR * (IdxLen + CodLocLen + CodNomLen + CodTipLen + ElemOperLen + TipOrigLen + NomeGRLen + NumBlankInHeader)) + (NumBValGr * NumGR + DataDosValoresLen) * NumMinutes + DataDosValoresLen; for(int i=0; i<pointName.Length;i++) { if(htHeader[pointName[i]] != null) { measurement = ReadValues(fs,pointName[i],headerLen,dateHourMinute); dataslist.Add(measurement); } else { measurement = new AnalogicDataRegisterDE(pointName[i],dateHourMinute); dataslist.Add(measurement); } } if(dataslist.Count > 0) measurements = (AnalogicDataRegisterDE[]) dataslist.ToArray(typeof( AnalogicDataRegisterDE)); } } r.Close(); fs.Close(); return measurements; }