//-----------------------------------------------------------------------
//
// 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 ObdSimulator.Data
{
using System.Windows.Forms;
///
/// Device information for Auxiliary Emission Control.
///
public partial class AuxiliaryEmissionControlDeviceInfo : UserControl
{
///
/// Initializes a new instance of the class.
///
/// Heading text for panel.
public AuxiliaryEmissionControlDeviceInfo(string heading)
{
this.InitializeComponent();
this.groupBox1.Text = heading;
}
///
/// Provide data to present.
///
/// Payload data.
/// Base number value for data set.
public void setData(byte[] payload, int baseNum)
{
if (payload != null)
{
DataGridViewRowCollection dgvrc = this.dataGridView1.Rows;
for (int i = 0; i < 5; i++)
{
int n = dgvrc.Add(1);
DataGridViewRow dgvr = dgvrc[n];
DataGridViewCellCollection dgvcc = dgvr.Cells;
bool supported1 = ((payload[PidParser.BYTE_A] >> i & 0x01) != 0);
long value1 = (payload[PidParser.BYTE_B + (i * 8)] << 24
| payload[PidParser.BYTE_C + (i * 8)] << 16
| payload[PidParser.BYTE_D + (i * 8)] << 8
| payload[PidParser.BYTE_E + (i * 8)]);
long value2 = (payload[PidParser.BYTE_F + (i * 8)] << 24
| payload[PidParser.BYTE_G + (i * 8)] << 16
| payload[PidParser.BYTE_H + (i * 8)] << 8
| payload[PidParser.BYTE_I + (i * 8)]);
dgvcc[0].Value = "#" + (baseNum + i).ToString();
dgvcc[1].Value = supported1;
dgvcc[2].Value = supported1 ? value1.ToString() : "N/A";
dgvcc[3].Value = supported1 ? value2.ToString() : "N/A";
}
}
}
}
}