//-----------------------------------------------------------------------
//
// Copyright © 2012 Nils Hammar. All rights reserved.
//
//-----------------------------------------------------------------------
/*
* Software to access vehicle information via the OBD-II connector.
*
* Copyright © 2012 Nils Hammar
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Alternative licensing is possible, see the licensing document.
*
* The above text may not be removed or modified.
*/
namespace SharedObjects.CAN.Objects
{
using System;
using System.Runtime.Serialization;
///
/// Container class for raw data.
///
[Serializable]
public class RawLogObject
{
///
/// Gets Timestamp for object.
///
public long timestamp { get; private set; }
///
/// Gets Source Address data
///
public uint sourceAddress { get; private set; }
///
/// Gets Mode byte
///
public byte mode { get; private set; }
///
/// Gets PID value
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "int", Justification = "Reviewed, intentional")]
public uint pid_int { get; private set; }
///
/// Gets Data length
///
public uint dataLen { get; private set; }
///
/// Gets Payload data
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Reviewed, intentional")]
public byte[] data { get; private set; }
///
/// Serialize the data.
///
/// Serialization info
/// Serialization context
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "ctx", Justification = "Reviewed, intentional")]
public void GetObjectData(SerializationInfo info, StreamingContext ctx)
{
if (info != null)
{
info.AddValue("sourceAddress", this.sourceAddress);
info.AddValue("mode", this.mode);
info.AddValue("pid_int", this.pid_int);
info.AddValue("dataLen", this.dataLen);
info.AddValue("data", this.data);
}
}
///
/// Initializes a new instance of the class.
///
/// Source Address data
/// Mode byte
/// PID value
/// Data length
/// Payload data
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "int", Justification = "Reviewed, intentional")]
public RawLogObject(uint sourceAddress, byte mode, uint pid_int, uint dataLen, byte[] data)
{
this.timestamp = DateTime.Now.Ticks;
this.sourceAddress = sourceAddress;
this.mode = mode;
this.pid_int = pid_int;
this.dataLen = dataLen;
this.data = data;
}
///
/// Initializes a new instance of the class.
///
/// Serialization info
/// Serialization context
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "ctx", Justification = "Reviewed, intentional")]
protected RawLogObject(SerializationInfo info, StreamingContext ctx)
{
if (info != null)
{
this.sourceAddress = (uint)info.GetValue("sourceAddress", typeof(uint));
this.mode = (byte)info.GetValue("mode", typeof(byte));
this.pid_int = (uint)info.GetValue("pid_int", typeof(uint));
this.dataLen = (uint)info.GetValue("dataLen", typeof(uint));
this.data = (byte[])info.GetValue("data", typeof(byte[]));
}
}
}
}