public void WriteRecord(int DglbId, DataRow data) { //Code for serializing record DataRowSerializer serializer = new DataRowSerializer(data.Table); byte[] serializedData; try { serializedData = serializer.SerializeData(data); } catch (SerializerException e) { throw new CommunicationException("Problems with serialization", e); } WriteData(DglbId, serializedData); }
public void ReadRecord(int DglbId, DataRow data) { DataRowSerializer serializer = new DataRowSerializer(data.Table); uint readCount; //Code for reading record try { readCount = serializer.GetSerializedDataLength(); } catch (SerializerException e) { throw new CommunicationException("Problems with getting length of serialized data", e); } //Here we read record UInt16[] receivedData = new UInt16[readCount / 2]; BPModbusDecoder decoder = new BPModbusDecoder(receivedData, DglbId, (int)DevMgmtS_dcte.mgmt_cmd.DGLB_RD_FIRST); decoder._data = ReadData(DglbId, readCount); //Here we deserialize record try { serializer.DeserializeData(decoder.data, data); } catch (SerializerException e) { throw new CommunicationException("Problems with deserialization", e); } }