Code 2
Code 2
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
//using System.Windows.Shapes;
using System.Runtime.InteropServices;
using MahApps.Metro;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using System.Windows.Interop;
using Microsoft.Win32;
using System.Diagnostics;
using System.ComponentModel;
using System.Threading;
using System.Windows.Threading;
using System.IO;
using System.Collections.ObjectModel;
using System.Text.RegularExpressions;
using System.Data;
using System.Data.OleDb;
using System.Reflection;
using System.Collections;
using System.Globalization;
using System.Net.NetworkInformation;
using System.Windows.Controls.Primitives;
using System.Xml.Linq;
using System.Windows.Shapes;
using Path = System.IO.Path;
using static System.Collections.Specialized.BitVector32;
using BasicElcentral_StartupProject;
using System.Collections.Specialized;
using System.Collections.Concurrent;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting.Messaging;
using CAN_Master.Profile;
using System.Xml;
using System.Net.Http;
using System.Net;
using System.Net.Http.Headers;
using Newtonsoft.Json;
using System.Windows.Interactivity;
using CAN_Master.Resources;
using System.Configuration;
using CAN_Master.Common;
using AutoUpdaterDotNET;
using CAN_Master.Models;
using CAN_Master.Handlers;
using CAN_Master.Helpers;
using log4net;
namespace CAN_Master
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : MetroWindow, INotifyPropertyChanged
{
enum LOG_COLORS
{
NORMAL = 0,
SUCCESS,
WARNING,
ERROR
};
enum LOG_TYPE
{
INFO = 0,
CODE,
DATA,
ERROR,
}
//Constants.
const int WM_CREATE = 0x0001;
const int WM_DEVICECHANGE = 0x0219;
const int AHID_DATARECEIVED = 0x0465;
const int AHID_REP_TYPE_INT_IN = 0;
const int AHID_REP_TYPE_INT_OUT = 1;
const int AHID_REP_TYPE_FEATURE = 2;
const int AHID_OK = 0;
const int AHID_ATTACHED = 1;
const int AHID_REMOVED = 2;
const int AHID_NOT_LISTED = 3;
const int AHID_IO_ERROR = 4;
const int AHID_NOT_INITIALIZED = 5;
const int AHID_LICENSE_ERROR = 6;
const int AHID_OTHER_ERROR = 7;
const int AHID_WRONG_PARAMETER = 8;
public uint ElcentralVID = 0x03EB;
//public uint ElcentralPID = 0x2FE5;
public uint ElcentralPID = 0x2421;
//Variables.
private int _pipeOut;
private int _pipeIn;
//private uint _vid = 1003;
//private uint _pid = 9248;
//private byte _repID = 0;
private uint _repSize = 128;
private int _register;
private int _deregister;
private int _write;
public bool _connected = false;
//private bool _attached;
//private int licenseType;
internal UInt32 hwFirmwareVer = 0;
#endregion
else
{
_connected = false;
//_attached = false;
tbFirmware.Text = "NA";
_deregister = AHid_Deregister(_pipeOut);
//_deregister = AHid_Deregister(_pipeOut_dfu);
_pipeOut = 0;
_pipeIn = 0;
}
}
catch (Exception Ex) { MessageBox.Show($"{Ex.Message}\
n{Ex.ToString()}", "USB Comm Error1"); }
}
else
{
try
{
int _state2 = AHid_Attached(_pipeOut, wParam, lParam);
if (_state2 == AHID_ATTACHED)
{
//_attached = true;
}
else if (_state2 == AHID_REMOVED)
{
//_attached = false;
_connected = false;
tbFirmware.Text = "NA";
_deregister = AHid_Deregister(_pipeOut);
_deregister = AHid_Deregister(_pipeIn);
//_deregister = AHid_Deregister(_pipeOut_dfu);
_pipeOut = 0;
_pipeIn = 0;
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool
handled)
{
// Handle messages...
switch (msg)
{
case WM_CREATE:
MessageBox.Show("Window is now Created");
break;
case WM_DEVICECHANGE:
Dlg_OnDeviceChange(hwnd, msg, wParam, lParam, ref handled);
break;
case AHID_DATARECEIVED:
Dlg_OnDataReceived(hwnd, msg, wParam, lParam, ref handled);
break;
default:
break;
}
return IntPtr.Zero;
}
#endregion
//=========== Method for first time Data from Elcentral (ie Firmware and
Friendly ID)
private async void fetchInitialData()
{
Byte[] buffer = new Byte[_repSize];
//buffer[0] = (Byte)'$';
//buffer[1] = 1; //Function Code to connect the Elcentral Unit
//buffer[2] = 0;
//buffer[3] = 0;
//writeUsbHid(buffer);
// Thread.Sleep(100);
await Task.Delay(100);
buffer[0] = (Byte)'$';
buffer[1] = (Byte)'5'; //Function code for firmware type
buffer[2] = (Byte)1; //Function code for firmware type
writeUsbHid(buffer);
writeUsbHid(buffer);
}
// buffer[0] = (Byte)'$';
// buffer[1] = (Byte)'3'; //Access EEPROM Code byte
// buffer[2] = 6; //code for Write Unit ID
// buffer[3] = (Byte)unitIDStr.Length; //Length of the String
// writeUsbHid(buffer);
// //MessageBox.Show(System.Text.Encoding.UTF8.GetString(buffer, 4,
unitIDStr.Length));
// //MessageBox.Show(buffer[3].ToString() + (char)(buffer[4]));
//}
#endregion
//logging
log4net.Config.XmlConfigurator.Configure();
CarData carData = Task.Run(async () => await
_sessionHelper.GetLocalCarData()).Result;
_sessionHelper.Init(carData);
if (session == null)
RedirectToLoginWindow();
_sessionUser = session;
InitializeComponent();
#region Checking Internet Connectivity
CheckInternetConnection();
NetworkChange.NetworkAvailabilityChanged += NetworkAvailabilityChanged;
#endregion
MetroMain.Title = Constants.Application_Title + " ---- " +
session.UserName;
MetroMain.Title = carData != null ? MetroMain.Title + " ---- " +
carData.CarModel.model : MetroMain.Title;
BindingOperations.EnableCollectionSynchronization(dataGridItems,
lockObject);
InitializeGridHandlers();
Assembly systemAssembly =
System.Reflection.Assembly.GetExecutingAssembly();
//Get the current version
Version applicationVersion = systemAssembly.GetName().Version;
//tbGUIversion.Text = $"GUI Ver: {applicationVersion.Major}.
{applicationVersion.Minor}";
tbGUIversion.Text = $"GUI Ver: {applicationVersion.ToString(3)}";
this.DataContext = this;
ContentRendered += MainWindow_ContentRendered;
}
// Method to access a collection by variable name
public ObservableCollection<byte> GetCollectionByName(string name)
{
// Use reflection to find the property by name
PropertyInfo property = this.GetType().GetProperty(name);
return;
}
return;
}
}
}
}
catch (Exception)
{
//MessageBox.Show(Ex.Message, "Error on Filter");
}
}
private void tbxDecIDData_PreviewTextInput(object sender,
TextCompositionEventArgs e)
{
try
{
Regex _regex = new Regex("[^0-9]"); //regex that matches disallowed
text
}
}
}
catch (Exception)
{
//MessageBox.Show(Ex.Message, "Error on Filter");
}
}
/**
* Check for Binary format conditions
*/
private void tbxBinary_PreviewTextInput(object sender,
TextCompositionEventArgs e)
{
try
{
Regex _regex = new Regex("[^0-1]"); //regex that matches disallowed
text
if (tbBin.Text.Length < 8)
{
UInt16 ab = System.Convert.ToUInt16(tbBin.Text + e.Text, 2);
if (ab >= 256)
{
e.Handled = true;
tbBin.Text = "11111111";
tbBin.CaretIndex = tbBin.Text.Length;
}
}
else
{
e.Handled = true;
}
}
catch (Exception)
{
//MessageBox.Show(Ex.Message, "Error on Filter");
}
}
/**
* Detect the text changes and fix them
*/
private void tbxSampleBin_PreviewKeyDown(object sender, KeyEventArgs e)
{
try
{
var tbxBin = sender as System.Windows.Controls.TextBox;
int carIdx = tbxBin.CaretIndex;
}
abText = abText.Remove(carIdx, 1);
if ((e.Key == Key.D1) || (e.Key == Key.NumPad1)) abText =
abText.Insert(carIdx, "1");
else if ((e.Key == Key.D0) || (e.Key == Key.NumPad0)) abText =
abText.Insert(carIdx, "0");
e.Handled = true;
tbxBin.Text = abText;
tbxBin.CaretIndex = carIdx + 1;
}
/**
* Check for Hexadecimal format conditions
*/
private void tbxHexData_PreviewTextInput(object sender,
TextCompositionEventArgs e)
{
try
{
Regex _regex = new Regex("[^0-9A-F]", RegexOptions.IgnoreCase);
//regex that matches disallowed text
var tbxHex = sender as System.Windows.Controls.TextBox;
tbxHex.CaretIndex = carIdx + 1;
e.Handled = true;
}
else
{
e.Handled = true;
}
}
catch (Exception)
{
//MessageBox.Show(Ex.Message, "Error on Filter");
}
}
/**
* Detect the text changes and fix them
*/
private void tbxSampleHex_PreviewKeyDown(object sender, KeyEventArgs e)
{
var tbxHex = sender as System.Windows.Controls.TextBox;
int carIdx = tbxHex.CaretIndex;
// }
// abText = abText.Remove(carIdx, 1);
// if ((e.Key == Key.D1) || (e.Key == Key.NumPad1)) abText =
abText.Insert(carIdx, "1");
// else if ((e.Key == Key.D0) || (e.Key == Key.NumPad0)) abText =
abText.Insert(carIdx, "0");
// e.Handled = true;
// tbxBin.Text = abText;
// tbxBin.CaretIndex = carIdx + 1;
//}
/**
* Check for Hex Canbus ID format conditions
*/
private void tbxHexID_PreviewTextInput(object sender,
TextCompositionEventArgs e)
{
try
{
Regex _regex = new Regex("[^0-9A-F]", RegexOptions.IgnoreCase);
//regex that matches disallowed text
var tbxHex = sender as System.Windows.Controls.TextBox;
tbxHex.CaretIndex = carIdx + 1;
e.Handled = true;
}
else
{
e.Handled = true;
}
}
catch (Exception)
{
//MessageBox.Show(Ex.Message, "Error on Filter");
}
}
#region LOGGER
//Method to log data on logger
private void logDataNow(string logData, LOG_COLORS logColor =
LOG_COLORS.NORMAL, LOG_TYPE logType = LOG_TYPE.INFO)
{
try
{
Brush foregroundBrush = Brushes.Gainsboro;
if (logColor == LOG_COLORS.SUCCESS)
{
if (logType == LOG_TYPE.DATA) { foregroundBrush = Brushes.Cyan;
}
else { foregroundBrush = Brushes.LimeGreen; }
}
else if (logColor == LOG_COLORS.WARNING) { foregroundBrush =
Brushes.Yellow; }
else if (logColor == LOG_COLORS.ERROR) { foregroundBrush =
Brushes.Red; }
para.Inlines.Add(new
Run("----------------------------------------------------"));
para.Inlines.Add(new Run($"\r> {DateTime.Now}" + "\r\n"));
para.Inlines.Add(new Run("\
r----------------------------------------------------"));
svLog.ScrollToBottom();
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message, "Log error:");
}
}
#endregion
buffer[0] = (Byte)'$';
buffer[1] = (Byte)'1'; //Retrieve
Active Status data
#region Upload / Download Firmware, EEPROM and Serial + HW Rev + Type Info
buffer[0] = (byte)'$';
buffer[1] = (byte)'3'; //Access EEPROM Code
byte
buffer[2] = 101; //code for Read Serial
Number
writeUsbHid(buffer);
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message, "Serial Read error:");
}
}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message, "Firmware Version Read error:");
}
}
dataBlockCount = 0;
//inProgress = 1;
uploadStage = 0;
//Clear the Logger if Auto Clear is checked
//if (tglAutoClearLog.IsChecked == true)
//{
// mainRTB.Document.Blocks.Clear();
//}
await uploadController.CloseAsync();
uploadController = null;
}
buffer[0] = (Byte)'$';
buffer[1] = (Byte)'3'; //Access EEPROM
buffer[2] = (Byte)1; //Write CAN
Ports Data to the EEPROM
buffer[3] = (Byte)0; //Block Number
| Each block is 64 bytes | Block 0 belongs to General settings like CAN ports
config and Power settings
uploadStage++;
}
catch (Exception ex)
{
log.Error("EXPORT - Gen Settings - ERROR" + ex.Message);
}
string carMakeId =
((GetMakeNames)comboCar.SelectedValue).id.ToString();
string carModelId =
((GetModelNames)comboCarModel.SelectedValue).id.ToString();
string engineId =
((EngineType)comboEngineType.SelectedValue)?.Id.ToString() != null ?
((EngineType)comboEngineType.SelectedValue).Id.ToString() : null;
string gearId =
((GearBox)comboGearBox.SelectedItem)?.Id.ToString() != null ?
((GearBox)comboGearBox.SelectedItem).Id.ToString() : null;
string wheelDriveId =
((WheelDrive)comboWheelDrive.SelectedItem)?.Id.ToString() != null ?
((WheelDrive)comboWheelDrive.SelectedItem).Id.ToString() : null;
string year = comboYear?.SelectedValue?.ToString();
buffer[0] = (Byte)'$';
buffer[1] = (Byte)'3'; //Access EEPROM
buffer[2] = (Byte)5;
buffer[3] = (Byte)idx;
int encodedSignalId =
System.Text.Encoding.UTF8.GetBytes(signalId.ToCharArray(), 0, signalId.Length,
buffer, 6);
buffer[5] = (byte)encodedSignalId;
}
}
else if (idx == 18 && CarData_isFetched)
{
string combinedString = $"{carMakeId}-{carModelId}-{year}-
{gearId}-{engineId}-{wheelDriveId}-{baudRate}";
int encodedCarData =
System.Text.Encoding.UTF8.GetBytes(combinedString.ToCharArray(), 0,
combinedString.Length, buffer, 6);
buffer[5] = (byte)encodedCarData;
//writeUsbHid(buffer);
}
writeUsbHid(buffer);
if (++extraDataBlockCount >= 19) uploadStage++;
}
catch (Exception ex)
{
log.Error("EXPORT - Extra Data Blocks - ERROR" + ex.Message);
}
}
//Upload general configuration data related to BTS and CAN messages
else if (uploadStage == OpStages.opDataBlocks)
{
Byte[] buffer = new Byte[64];
int idx = dataBlockCount;
buffer[0] = (Byte)'$';
buffer[1] = (Byte)'3'; //Access EEPROM
buffer[2] = (Byte)3; //Write CAN Msg Data to
the EEPROM
buffer[3] = (Byte)idx; //Block Number | Each
block is 64 bytes | Block 0 and 1 belongs to BTS0 and BTS1 respectively.
}
}
}
}
}
}
}
if (CM1_isFetched && idx == 3)
{
for (int i = 0; i < 8; i++)
{
try
{
if (CMBIT1_DATA_BYTES_COPY[i] == 0 &&
CMBIT1_DATA_BYTES_COPY[i + 8] == 0)
{
buffer[9] |= (byte)(1 << i);
}
}
catch (Exception)
{
}
}
}
}
}
}
}
if (CM4_isFetched && idx == 6)
{
for (int i = 0; i < 8; i++)
{
try
{
if (CMBIT4_DATA_BYTES_COPY[i] == 0 &&
CMBIT4_DATA_BYTES_COPY[i + 8] == 0)
{
buffer[9] |= (byte)(1 << i);
}
}
catch (Exception)
{
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
else
{
buffer[4] = (Byte)CANBUS_MSG_SOURCE[idx]; //CAN Port Number
0 or 1
buffer[35] = (byte)0x00; //Remove the flag for indicating the
fetched signal
// if (tglSwAutoProgram.IsChecked == false)
// {
// await Task.Delay(2000);
// await uploadController.CloseAsync();
// uploadController = null;
// }
// else
// {
// uploadController.SetProgress(1);
// uploadMessages = $"Firmware - DONE!\nUploading serial
number: {tbSerialNumber.Text}";
// uploadController.SetMessage(uploadMessages);
// if (!string.IsNullOrEmpty(tbEEPROMPath.Text))
// {
// await Task.Delay(1000);
// }
// else
// {
// await Task.Delay(5000);
// }
// //Start Next Timer for uploading the serial number
// serialNumSent = false;
// vn5CalibrationRequested = false;
// vn5CalibrationError = false;
// serialUpTimer = new DispatcherTimer();
// serialUpTimer.Interval = TimeSpan.FromMilliseconds(1000);
// serialUpTimer.Tick += serialUpTimer_Tick;
// serialUpTimer.Start();
// }
//}
#endregion
}
else //When the attempts are over
{
//var test = new[] { BTS0_DATA_BYTES, BTS1_DATA_BYTES,
// CMBIT0_DATA_BYTES, CMBIT1_DATA_BYTES,
CMBIT2_DATA_BYTES, CMBIT3_DATA_BYTES,
// CMBIT4_DATA_BYTES, CMBIT5_DATA_BYTES,
CMBIT6_DATA_BYTES, CMBIT7_DATA_BYTES,
// CMBIT8_DATA_BYTES, CMBIT9_DATA_BYTES,
CMBIT10_DATA_BYTES, CMBIT11_DATA_BYTES,
// CMBIT12_DATA_BYTES,
CMBIT13_DATA_BYTES, CMBIT14_DATA_BYTES, CMBIT15_DATA_BYTES };
//var test =
//var tObc = BTS0_DATA_BYTES as ObservableCollection<byte>;
Byte[] buffer = new Byte[64];
uploadStage = 0;
}
}
if (result == MessageDialogResult.Affirmative)
{
// Import button clicked, call your import method
startImporting();
}
}
#endregion
#endregion
dataBlockCount = 0;
extraDataBlockCount = 0;
importStage = 0;
await importController.CloseAsync();
importController = null;
}
buffer[0] = (Byte)'$';
buffer[1] = (Byte)'3'; //Access EEPROM
buffer[2] = (Byte)2; //Read CAN
Ports Data from the EEPROM
buffer[3] = (Byte)0; //Block Number
| Each block is 64 bytes | Block 0 belongs to CAN ports config
importStage++;
}
catch (Exception ex)
{
log.Error("opGenSettings - ERROR" + ex.Message);
}
}
if (importStage == OpStages.opExtraDataBlocks)
{
try
{
Byte[] buffer = new Byte[64];
buffer[0] = (Byte)'$';
buffer[1] = (Byte)'3'; //Access EEPROM
buffer[2] = (Byte)6; //Read CAN
Extra Data from the EEPROM
buffer[3] = (Byte)extraDataBlockCount;
//Block Number | Each block is 64 bytes | Block 0 belongs to CAN ports config
writeUsbHid(buffer);
if (++dataBlockCount >= 18) importStage++;
importMessages = $"Importing configuration data from the CAN
Master unit.\nBlocks Read: {dataBlockCount}";
importController.SetMessage(importMessages);
importController.SetProgress(dataBlockCount);
}
catch (Exception ex)
{
log.Error("opDataBlocks - ERROR" + ex.Message);
}
}
else //When the attempts are over
{
var timer = sender as DispatcherTimer;
timer.Stop();
downloadTimer = null;
dataBlockCount = 0;
extraDataBlockCount = 0;
importStage = 0;
await importController.CloseAsync();
importController = null;
}
}
#endregion
CarModel carModel = new CarModel();
bool[] fetched_members = new bool[18];
String signalIdString = null;
String carMakeIdString = null;
String carModelString = null;
String engineIdString = null;
String wheelDriveIdString = null;
String gearBoxIdString = null;
String yearString = null;
String baudRateString = null;
private Dictionary<int, GetSignalByIdResponse> signalDetailsCache = new
Dictionary<int, GetSignalByIdResponse>();
Dictionary<int, string> idToBufferPosition = new Dictionary<int, string>();
Dictionary<string, int?> vehicleDataIds = new Dictionary<string, int?>();
private async Task<CarData> CreateCarData()
{
try
{
var getCarMake = (GetMakeNames)comboCar?.SelectedValue;
var carMake = new CarMake
{
id = getCarMake.id,
make = getCarMake.make,
};
}
else if (CONNECTED_ALREADY == false) //Request for the data
import
{
CONNECTED_ALREADY = true;
Button_Import_Settings_Clicked(this, null);
}
}
// Received the Serial Number Information
if ((buffer[1] == (byte)'3') && (buffer[2] == (byte)101))
{
int ean_str_length = buffer[3];
string tStr = System.Text.Encoding.UTF8.GetString(buffer,
4, ean_str_length); //Extract String from bytes.
logDataNow($"Serial Number: {tStr}", LOG_COLORS.SUCCESS,
LOG_TYPE.INFO);
}
//Accessed the EEPROM | Read CAN Ports config data blocks
else if ((buffer[1] == (byte)'3') && (buffer[2] == (byte)2))
{
try
{
//Settings for CAN Port 0
//cmbBaudCAN0.SelectedIndex = buffer[4];
UInt16 can0_baudrate = BitConverter.ToUInt16(buffer,
4);
//Didn't work! //cmbBaudCAN0.SelectedIndex =
cmbBaudCAN0.FindString($"{can0_baudrate}");
//Works but LONG! //var cmbItem =
cmbBaudCAN0.Items.OfType<ComboBoxItem>().FirstOrDefault(x =>
x.Content.ToString().Contains($"{can0_baudrate}".ToString()));
//cmbBaudCAN0.SelectedIndex =
cmbBaudCAN0.Items.IndexOf(cmbItem);
cmbBaudCAN0.SelectedIndex =
cmbBaudCAN0.Items.IndexOf(cmbBaudCAN0.Items.OfType<ComboBoxItem>().FirstOrDefault(x
=> x.Content.ToString().Contains($"{can0_baudrate}".ToString())));
if (cmbBaudCAN0.SelectedIndex == -1)
cmbBaudCAN0.SelectedIndex = 4;
//Retrieve the flags | for example the power enable
tglEnCanvPwr.IsChecked = ((buffer[6] & 0x01) == 0x01) ?
true : false;
}
//Accessed the EEPROM | Read CAN Master config data blocks
else if ((buffer[1] == (byte)'3') && (buffer[2] == (byte)4))
{
try
{
int idx = buffer[3];
if (idx > 19) return; //Return if received data is
out of range
CANBUS_MSG_SOURCE[idx] = buffer[4];
//CAN Port Number 0 or 1
CANBUS_MSG_IDS[idx] = BitConverter.ToUInt32(buffer, 5);
//CAN Msg ID
}
string format = string.Empty;
string canPort = string.Empty;
//Set the Message format bit
if (idx <= 1)
{
if (buffer[34] == 1)
(this.FindName($"radBts{idx}MsgTyE") as RadioButton).IsChecked = true;
else (this.FindName($"radBts{idx}MsgTyS") as
RadioButton).IsChecked = true;
}
else if (idx <= 17)
{
if (buffer[34] == 1) (this.FindName($"radCMBit{idx
- 2}MsgTyE") as RadioButton).IsChecked = true;
else { (this.FindName($"radCMBit{idx - 2}MsgTyS")
as RadioButton).IsChecked = true; }
}
Application.Current.Dispatcher.Invoke(() =>
{
}
}
catch (Exception ex)
{
log.Error("Id to buffer position", ex);
}
await Task.WhenAll(fetchTasks);
}
}
else
{
if (bit_isFetched[idx])
{
SetValueToUI(idx, canPort, canMsgId, format,
"Please connect to internet", "Please connect to internet", toggleButton);
}
}
}
catch (Exception ex)
{
log.Error("Error occurred while reading signal data
from buffer", ex);
}
}
//Accessed EPROM | Read CAN Master Extra Data
else if ((buffer[1] == (byte)'3') && (buffer[2] == (byte)6))
{
string decodedString =
System.Text.Encoding.UTF8.GetString(buffer, 6, buffer[5]); //Extract String from
bytes }
string[] parts = decodedString.Split('-');
//importextra
int idx = buffer[3];
if (idx > 19) return;
var fetchedSignalData = buffer[4];
if (idx <= 17)
{
if (fetchedSignalData == 1)
{
//string[] signalBlockNames = { "BT0", "BT1",
"CM1", "CM2", "CM3", "CM4", "CM5", "CM6", "CM7", "CM8", "CM9", "CM10", "CM11",
"CM12", "CM13", "CM14", "CM15", "CM16" };
//if (idx < signalBlockNames.Length)
//{
// if (parts.Length > 0)
// {
// signalIdString = parts[0]; // Assuming
signal ID is at zero index
// idToBufferPosition[idx] = signalIdString;
// bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
// }
//}
if (idx == 0)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
BTS0_isFetched = true;
}
}
if (idx == 1)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
BTS1_isFetched = true;
}
}
if (idx == 2)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM0_isFetched = true;
}
}
if (idx == 3)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM1_isFetched = true;
}
}
if (idx == 4)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM2_isFetched = true;
}
}
if (idx == 5)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM3_isFetched = true;
}
}
if (idx == 6)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM4_isFetched = true;
}
}
if (idx == 7)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM5_isFetched = true;
}
}
if (idx == 8)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM6_isFetched = true;
}
}
if (idx == 9)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM7_isFetched = true;
}
}
if (idx == 10)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM8_isFetched = true;
}
}
if (idx == 11)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM9_isFetched = true;
}
}
if (idx == 12)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM10_isFetched = true;
}
}
if (idx == 13)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM11_isFetched = true;
}
}
if (idx == 14)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM12_isFetched = true;
}
}
if (idx == 15)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM13_isFetched = true;
}
}
if (idx == 16)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM14_isFetched = true;
}
}
if (idx == 17)
{
if (parts.Length > 0)
{
signalIdString = parts[0]; // Assuming
signal ID is at zero index
idToBufferPosition[idx] = signalIdString;
bit_isFetched[idx] =
Convert.ToBoolean(fetchedSignalData);
CM15_isFetched = true;
}
}
foreach (var kvp in idToBufferPosition)
{
// Try to parse the string value to an integer
if (int.TryParse(kvp.Value, out int
parsedValue))
{
// If parsing is successful, store the
integer value in _selectedSignalIds
_selectedSignalIds[kvp.Key] = parsedValue;
}
else
{
_selectedSignalIds[kvp.Key] = 0;
}
}
}
}
else
{
carMakeIdString = parts[0]; //CarMakeId is at
the 0 index
carModelString = parts[1]; //CarModelId is at
the 1st index
yearString = parts[2]; //Year is at 2nd
index
gearBoxIdString = parts[3]; //GearBox is at the
3rd index
engineIdString = parts[4]; //EngineType is at
the 4th index
wheelDriveIdString = parts[5]; //WheelDrive is at
the 5th index
baudRateString = parts[6]; //BaudRate is at
the 6th index
await GetCarMakes(decodedString);
await Task.Delay(1000);
try
{
await CreateCarData();
}
catch (Exception)
{
}
}
}
else if ((buffer[1] == 'R') && (buffer[2] == 0))
{
//buffer[2] is used for sync data page | We are only using
page 0 so far.
try
{
for (int i = 0; i <= 7; i++)
{
byte res = (byte)(buffer[4] & (1 << i));
SolidColorBrush dbr_inactive = Brushes.Black;
SolidColorBrush dbr_active = Brushes.LimeGreen;
//STATUS_BIT_COLOR
if (i < 2)
{
if ((byte)(buffer[3] & (1 << i)) > 0)
{
STATUS_BIT_COLOR[i] = Brushes.Orange;
Button thumbLikeButton =
(Button)this.FindName($"thumbLike{i}");
if (thumbLikeButton != null)
{
thumbLikeButton.IsEnabled = true;
}
}
//else if (isClearButtonClicked ||
isUndoButtonClicked)
//{
// STATUS_BIT_COLOR[i] = dbr_inactive;
//}
else { STATUS_BIT_COLOR[i] = dbr_inactive; }
}
//Application.Current.Dispatcher.Invoke((Action)delegate
//{
// AppendListToGrid(can_id, can_port, can_format,
can_data);
//});
Application.Current.Dispatcher.BeginInvoke((Action)delegate
{
AppendListToGrid(can_id, can_port, can_format,
can_data);
});
}catch(Exception ex)
{
log.Error("ERROR - Scanner Mode Data - Import" +
ex.Message);
}
btnStartStopScanner.SetResourceReference(Button.StyleProperty,
"AccentedGreenSquareButtonStyle");
}
else
{
//Enable the baud rate selection in the Scanner tab
cmbScanBaudCAN0.IsEnabled = true;
cmbScanBaudCAN1.IsEnabled = true;
}
}
// if (buffer[31] == 1)
// {
// errCode = LOG_COLORS.ERROR;
// vn5CalibrationError = true;
// //tStr = $"Err: Check Input Voltage! (VIN < 11V)\r\n>
Previouly Saved VN5 Offset Data:\r\n ";
// tStr = $"Err: Check Input Voltage! (VIN < 11V)";
// }
// else
// {
//}
}
catch (Exception Ex)
{
MessageBox.Show(Ex.Message, "Data receive error");
log.Error("Data recieve error", Ex);
}
}
#endregion End of Handle the Incoming USB data
public void LogTest()
{
int number1 = 3000;
int number2 = 0;
try
{
Console.WriteLine(number1 / number2);
}
catch (DivideByZeroException)
{
log.Error("Division of {0} by zero.");
}
}
//INotifier property change event
public event PropertyChangedEventHandler PropertyChanged;
//Enter Bootloader
private void btnEnterBoot_Click(object sender, RoutedEventArgs e)
{
try
{
}
catch { }
}
/// <summary>
/// Import the Settings from the CAN Master Unit
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Import_Settings_Clicked(object sender, RoutedEventArgs
e)
{
try
{
if (_connected)
{
fetchInitialData();
Task.Delay(100);
PromptUserForImport();
//startImporting();
customFlagDict.Clear();
undoButtonPressedBeforeExport = false;
//Byte[] buffer = new Byte[_repSize];
//buffer[0] = (Byte)'$';
//buffer[1] = (Byte)'3';
//buffer[2] = (Byte)3;
//buffer[3] = (Byte)0; //First Data set | BTS0
//writeUsbHid(buffer);
//Thread.Sleep(100);
}
}
/// <summary>
/// Export the Settings to the CAN Master Unit
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Export_Settings_Clicked(object sender, RoutedEventArgs
e)
{
try
{
if (_connected)
{
startUploading();
isExportSettingsPressed = true;
undoButtonPressedBeforeExport = false;
isClearButtonClicked = false;
exportBytesFromScannerToConfig = false;
}
}
catch (Exception ex)
{
log.Error("Export Settings - ERROR" + ex.Message);
}
}
//Update the General Settings header CAN-V text whenever the baudrate is
changed.
private void cmbBaudCAN0_SelectionChanged(object sender,
SelectionChangedEventArgs e)
{
//string(cmbBaudCAN0.SelectedItem.ToString().SkipWhile(c => !
char.IsDigit(c)).TakeWhile(c => char.IsDigit(c)).ToArray());
//ComboBoxItem cbi = (ComboBoxItem)cmbBaudCAN0.SelectedItem;
tbGSCanvBaud.Text = $"CAN-V
[ {((ComboBoxItem)cmbBaudCAN0.SelectedItem).Content.ToString()} ]";
//Update the General Settings header CAN-DRB text whenever the baudrate is
changed.
private void cmbBaudCAN1_SelectionChanged(object sender,
SelectionChangedEventArgs e)
{
tbGSCandrbBaud.Text = $"CAN-DRB
[ {((ComboBoxItem)cmbBaudCAN1.SelectedItem).Content.ToString()} ]";
public AsyncObservableCollection()
{
}
OnPropertyChanged();
}
}
OnPropertyChanged();
}
}
OnPropertyChanged();
}
}
Task.Factory.StartNew(() =>
{
List<string> singleByte = hexValues.Split('-').ToList();
string hexId = can_Id.ToString("X");
ObservableCollection<bool> defaultBytesSelected =
ExtensionHelper.BitDataCollection(Constants.DEFAULT_ZERO_HEX);
var incomingData = new DataGridItem
{
//RollNo = 1,
Delta = "1254".ToString(),
BinaryId = can_Id,
ID = hexId,
TimeStamp = DateTime.Now.ToString(),
UpdatedTime = DateTime.Now,
//MessageFormat = (can_format == 0) ? "29" : "11", // 29 is
Standard and 11 is Extended message
MessageFormat = (can_format == 0) ? "11" : "29", // 11 is
Standard and 29 is Extended message
Port = (can_port == 1) ? "CAN" : "CAN-V",
Zero = singleByte[0],
zeroByte = { ByteCollection =
ExtensionHelper.BitDataCollection(singleByte[0].ToString()), BytesSelected =
ExtensionHelper.BitDataCollection(Constants.DEFAULT_ZERO_HEX) },
One = singleByte[1],
oneByte = { ByteCollection =
ExtensionHelper.BitDataCollection(singleByte[1].ToString()), BytesSelected =
ExtensionHelper.BitDataCollection(Constants.DEFAULT_ZERO_HEX) },
Two = singleByte[2],
twoByte = { ByteCollection =
ExtensionHelper.BitDataCollection(singleByte[2].ToString()), BytesSelected =
ExtensionHelper.BitDataCollection(Constants.DEFAULT_ZERO_HEX) },
Three = singleByte[3],
threeByte = { ByteCollection =
ExtensionHelper.BitDataCollection(singleByte[3].ToString()), BytesSelected =
ExtensionHelper.BitDataCollection(Constants.DEFAULT_ZERO_HEX) },
Four = singleByte[4],
fourByte = { ByteCollection =
ExtensionHelper.BitDataCollection(singleByte[4].ToString()), BytesSelected =
ExtensionHelper.BitDataCollection(Constants.DEFAULT_ZERO_HEX) },
Five = singleByte[5],
fiveByte = { ByteCollection =
ExtensionHelper.BitDataCollection(singleByte[5].ToString()), BytesSelected =
ExtensionHelper.BitDataCollection(Constants.DEFAULT_ZERO_HEX) },
Six = singleByte[6],
sixByte = { ByteCollection =
ExtensionHelper.BitDataCollection(singleByte[6].ToString()), BytesSelected =
ExtensionHelper.BitDataCollection(Constants.DEFAULT_ZERO_HEX) },
Seven = singleByte[7],
sevenByte = { ByteCollection =
ExtensionHelper.BitDataCollection(singleByte[7].ToString()), BytesSelected =
ExtensionHelper.BitDataCollection(Constants.DEFAULT_ZERO_HEX) },
HideItem = false
};
lock (lockObject)
{
if (!dictionary.ContainsKey(incomingData.ID))
{
dictionary.TryAdd(incomingData.ID, true);
filterList(incomingData.ID, can_Id);
}
//Updating Rows Serial Numbers.
var updatedGrid = dataGridItems.Where(a => !
a.HideItem).ToList();
updatedGrid.ForEach(o => o.RollNo =
(updatedGrid.IndexOf(updatedGrid.FirstOrDefault(z => z.ID == o.ID)) + 1));
if (dataGridItems.Count > 0 && dataGridItems != null)
{
//existingRow.RollNo = 1;
existingRow.Delta = incomingData.Delta;
existingRow.TimeStamp = DateTime.Now.ToString();
existingRow.Port = incomingData.Port;
existingRow.MessageFormat = incomingData.MessageFormat;
existingRow.Zero = incomingData.Zero;
existingRow.zeroByte.ByteCollection =
incomingData.zeroByte.ByteCollection;
existingRow.zeroByte.OnByteChanged(byteChangedList);
existingRow.One = incomingData.One;
existingRow.oneByte.ByteCollection =
incomingData.oneByte.ByteCollection;
existingRow.oneByte.OnByteChanged(byteChangedList);
existingRow.Two = incomingData.Two;
existingRow.twoByte.ByteCollection =
incomingData.twoByte.ByteCollection;
existingRow.twoByte.OnByteChanged(byteChangedList);
existingRow.Three = incomingData.Three;
existingRow.threeByte.ByteCollection =
incomingData.threeByte.ByteCollection;
existingRow.threeByte.OnByteChanged(byteChangedList);
existingRow.Four = incomingData.Four;
existingRow.fourByte.ByteCollection =
incomingData.fourByte.ByteCollection;
existingRow.fourByte.OnByteChanged(byteChangedList);
existingRow.Five = incomingData.Five;
existingRow.fiveByte.ByteCollection =
incomingData.fiveByte.ByteCollection;
existingRow.fiveByte.OnByteChanged(byteChangedList);
existingRow.Six = incomingData.Six;
existingRow.sixByte.ByteCollection =
incomingData.sixByte.ByteCollection;
existingRow.sixByte.OnByteChanged(byteChangedList);
existingRow.Seven = incomingData.Seven;
existingRow.sevenByte.ByteCollection =
incomingData.sevenByte.ByteCollection;
existingRow.sevenByte.OnByteChanged(byteChangedList);
Dispatcher.BeginInvoke(new Action(delegate ()
{
double timer = 0;
if (nudSecToHide.Value != null)
{
autoHide.IsEnabled = true;
}
autoHideBtn.IsEnabled = true;
//onchecked authide
if (autoHide.IsChecked == true && nudSecToHide.Value != null)
{
is_AutoHide = true;
timer = (double)nudSecToHide.Value;
var existingRows = dataGridItems.ToList().Where(x => !
removedDataGridItems.Contains(x) && !x.ForceHide &&
DateTime.Now.Subtract(x.UpdatedTime).Seconds > timer).ToList();
filterGridList.ItemsSource = filterValues;
}
filterGridList.ItemsSource = filterValues;
}
}
}
}
else
{
gridList.ItemsSource = dataGridItems;
}
}));
});
}
//buffer[3] = (Byte)cmbScanBaudCAN0.SelectedIndex;
//buffer[4] = (Byte)cmbScanBaudCAN1.SelectedIndex;
is_scanner_running = !is_scanner_running;
if (!is_scanner_running)
{
btnStartStopScanner.SetResourceReference(Button.StyleProperty,
"AccentedSquareButtonStyle");
StoreCanIDs();
}
writeUsbHid(buffer);
}
catch(Exception ex)
{
log.Error("ERROR - Scanner start/Stop" + ex.Message);
}
}
dt.Rows.Add(arrayGridItem);
}
Clipboard.Clear();
ApplicationCommands.Copy.Execute(null, dg);
if (saveFileDialog.ShowDialog() == true)
{
var clip2 = Clipboard.GetText();
File.WriteAllText(saveFileDialog.FileName, clip2.Replace('\t',
','), Encoding.UTF8);
Process.Start(saveFileDialog.FileName);
}
dg.UnselectAllCells();
dg.SelectionMode = DataGridSelectionMode.Single;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
Clipboard.Clear();
}
}
Dispatcher.BeginInvoke(new Action(delegate ()
{
filterValues.Add(newData);
filterGridList.ItemsSource = filterValues;
}));
}
return result;
}
}
private void CheckBox_Click(object sender, RoutedEventArgs e)
{
DataGridCell cell = (DataGridCell)sender as DataGridCell;
DataGridItem item = (DataGridItem)cell.DataContext as DataGridItem;
item.IsSelected = !item.IsSelected;
if (item.IsSelected)
{
var index = dataGridItems.IndexOf(item);
dataGridItems.Move(index, 0);
filterValues.Move(index, 0);
rowIndex = -1;
if (!is_scanner_running)
{
var updatedGrid = dataGridItems.Where(a => !
a.HideItem).ToList();
updatedGrid.ForEach(o => o.RollNo =
(updatedGrid.IndexOf(updatedGrid.FirstOrDefault(z => z.ID == o.ID)) + 1));
}
//dataGridItems.Move(rowIndex, 0);
//filterValues.Move(rowIndex, 0);
// Move the selected item to the top of the DataGrid
//var selectedItem = (DataGridItem)gridList.SelectedItem;
//if (selectedItem != null)
//{
// gridList.Items.Remove(selectedItem);
// gridList.Items.Insert(0, selectedItem);
//}
//gridList.Items.SortDescriptions.Clear();
//// Move the selected item to the top
}
}
catch (Exception ex)
{
ExceptionHandler.DebugException(ex);
}
}
private bool GetMouseTargetRow(Visual theTarget, GetPosition position)
{
if (theTarget == null) return false;
Rect rect = VisualTreeHelper.GetDescendantBounds(theTarget);
Point point = position((IInputElement)theTarget);
return rect.Contains(point);
}
index++;
}
return result;
}
if (prev == curr)
return true;
else
return false;
}
if (prev != curr)
return true;
else
return false;
}
private void ResetControlsForIdx(int idx)
{
ToggleButton tBtn = (ToggleButton)FindName($"toggle{idx}");
if (tBtn != null)
{
tBtn.IsChecked = true;
//Undo_Checked_Clicked(tBtn, new RoutedEventArgs());
}
}
private async void Output1_Click(object sender, RoutedEventArgs e)
{
ExportRequest param = new ExportRequest()
{
BitDataBytes = BTS0_DATA_BYTES,
ChkboxName = "cbBts0Msg_custom",
TabIndex = 0,
RadioBtnPrefix = "radBts",
SeparatorKey = "B",
SepratorIgnore = "I",
RadioBtnStandardMsgType = radBts0MsgTyS,
RadioBtnExtendedMsgType = radBts0MsgTyE,
CanMsgIdIndex = 0,
CanMsgSourceIndex = 0,
};
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
//var dictionary =
selectedData.GetType().GetProperties().ToDictionary(property => property.Name,
property => property.GetValue(selectedData));
//var hexval = dictionary.Where(x => x.Key ==
byteName).FirstOrDefault();
//var selectedCollection = (dynamic)hexval.Value;
//var comingArray =
(ObservableCollection<bool>)selectedCollection.ByteCollection;
//var comingByte = ConvertBoolArrayToByte(comingArray.ToArray());
//var updatedTriggerByte =
ConvertBoolArrayToByte(changeBitTriggerBoolArray.Reverse().ToArray());
//byte _currentByte = 0;
//bool isBitAlreadyExist = false;
//bool isSelectBitChange = false;
//bool[] _boolArray = new bool[8];
//int tabIndex = 0;
//var rbPref = "radBts";
//var sepratorKey = "B";
//var sepratorIgnore = "I";
//else
// radBts0MsgTyE.IsChecked = true;
// //if byte value exported true then click compare radio button
// radioBtnCompare.IsChecked = true;
// //if the bit export value is false then set it to true for mask
// BTS0_DATA_BYTES[byteNumber] = (bitValue == true) ?
currentMaskByte : _currentByte;
// BTS0_DATA_BYTES[triggerNumber] = currentMaskByte;
//}
// else
// {
// BTS0_DATA_BYTES[byteNumber] = (bitValue == true) ? (byte)
(currentMaskByte + previousMaskByte) : (byte)(_currentByte + previousMaskByte);
// BTS0_DATA_BYTES[triggerNumber] = (bitValue == true) ? (byte)
(currentMaskByte + prevTriggerByte) : prevTriggerByte;
// radioBtnCompare.IsChecked = true;
// }
//}
// if (result == MessageDialogResult.Affirmative)
// {
// CANBUS_MSG_SOURCE[0] = (byte)portValue;
// CANBUS_MSG_IDS[0] = canId;
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
//Commented code for every position. Will remove after customer
feedback.
#region CommentedCode
//List<bool> objList = new List<bool>();
//MenuItem chk = (MenuItem)sender;
//var selectedData = (DataGridItem)chk.DataContext;
//uint canId = Convert.ToUInt32(selectedData.ID, 16);
//var canPort = selectedData.Port;
//var canFormat = selectedData.MessageFormat;
//var dictionary =
selectedData.GetType().GetProperties().ToDictionary(property => property.Name,
property => property.GetValue(selectedData));
//var hexval = dictionary.Where(x => x.Key ==
byteName).FirstOrDefault();
//var selectedCollection = (dynamic)hexval.Value;
//var comingArray =
(ObservableCollection<bool>)selectedCollection.ByteCollection;
//var comingByte = ConvertBoolArrayToByte(comingArray.ToArray());
//var updatedTriggerByte =
ConvertBoolArrayToByte(changeBitTriggerBoolArray.Reverse().ToArray());
//byte _currentByte = 0;
//bool isBitAlreadyExist = false;
//bool isSelectBitChange = false;
//bool[] _boolArray = new bool[8];
////if the value has changed at same bit position of the same byte
//isSelectBitChange = IsSelectBitChanged(prevTriggerBoolArray,
_boolArray, bitIndex);
//int tabIndex = 1;
//var rbPref = "radBts";
//var sepratorKey = "B";
//var sepratorIgnore = "I";
//else
// radBts1MsgTyE.IsChecked = true;
// //if byte value exported true then click compare radio button
// radioBtnCompare.IsChecked = true;
// //if the bit export value is false then set it to true for mask
// BTS1_DATA_BYTES[byteNumber] = (bitValue == true) ?
currentMaskByte : _currentByte;
// BTS1_DATA_BYTES[triggerNumber] = currentMaskByte;
//}
// else
// {
// BTS1_DATA_BYTES[byteNumber] = (bitValue == true) ? (byte)
(currentMaskByte + previousMaskByte) : (byte)(_currentByte + previousMaskByte);
// BTS1_DATA_BYTES[triggerNumber] = (bitValue == true) ? (byte)
(currentMaskByte + prevTriggerByte) : prevTriggerByte;
// radioBtnCompare.IsChecked = true;
// }
//}
////replace previous data with new one
//else if (CANBUS_MSG_IDS[1] != canId)
//{
// var result = await MetroMain.ShowMessageAsync("Do you want to
replace the data?", $"Another bit is already exist with id {prevMsgId} at tab UT-
2", MessageDialogStyle.AffirmativeAndNegative, settings: dialogSettings);
// if (result == MessageDialogResult.Affirmative)
// {
// CANBUS_MSG_SOURCE[1] = (byte)portValue;
// CANBUS_MSG_IDS[1] = canId;
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
//var dictionary =
selectedData.GetType().GetProperties().ToDictionary(property => property.Name,
property => property.GetValue(selectedData));
//var hexval = dictionary.Where(x => x.Key ==
byteName).FirstOrDefault();
//var selectedCollection = (dynamic)hexval.Value;
//var comingArray =
(ObservableCollection<bool>)selectedCollection.ByteCollection;
//var comingByte = ConvertBoolArrayToByte(comingArray.ToArray());
//var updatedTriggerByte =
ConvertBoolArrayToByte(changeBitTriggerBoolArray.Reverse().ToArray());
//byte _currentByte = 0;
//bool isBitAlreadyExist = false;
//bool isSelectBitChange = false;
//bool[] _boolArray = new bool[8];
////if the value has changed at same bit position of the same byte
//isSelectBitChange = IsSelectBitChanged(prevTriggerBoolArray,
_boolArray, bitIndex);
//}
//else
//{
// isBitAlreadyExist =
CheckIfCurrentBitIsAlreadyExist(prevMaskBoolArray, boolArray, bitIndex);
//}
//int tabIndex = 0;
//var rbPref = "radCMBit";
//var sepratorKey = "B";
//var sepratorIgnore = "I";
// //if byte value exported true then click compare radio button
// radioBtnCompare.IsChecked = true;
// //if the bit export value is false then set it to true for mask
// CMBIT0_DATA_BYTES[byteNumber] = (bitValue == true) ?
currentMaskByte : _currentByte;
// CMBIT0_DATA_BYTES[triggerNumber] = currentMaskByte;
//}
// else
// {
// CMBIT0_DATA_BYTES[byteNumber] = (bitValue == true) ? (byte)
(currentMaskByte + previousMaskByte) : (byte)(_currentByte + previousMaskByte);
// CMBIT0_DATA_BYTES[triggerNumber] = (bitValue == true) ?
(byte)(currentMaskByte + prevTriggerByte) : prevTriggerByte;
// radioBtnCompare.IsChecked = true;
// }
//}
////replace previous data with new one
//else if (CANBUS_MSG_IDS[2] != canId)
//{
// var result = await MetroMain.ShowMessageAsync("Do you want to
replace the data?", $"Another bit is already exist with id {prevMsgId} at tab CM
Position 1", MessageDialogStyle.AffirmativeAndNegative, settings: dialogSettings);
// if (result == MessageDialogResult.Affirmative)
// {
// CANBUS_MSG_SOURCE[2] = (byte)portValue;
// CANBUS_MSG_IDS[2] = canId;
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
//var dictionary =
selectedData.GetType().GetProperties().ToDictionary(property => property.Name,
property => property.GetValue(selectedData));
//var hexval = dictionary.Where(x => x.Key ==
byteName).FirstOrDefault();
//var selectedCollection = (dynamic)hexval.Value;
//var comingArray =
(ObservableCollection<bool>)selectedCollection.ByteCollection;
//var comingByte = ConvertBoolArrayToByte(comingArray.ToArray());
//var updatedTriggerByte =
ConvertBoolArrayToByte(changeBitTriggerBoolArray.Reverse().ToArray());
//byte _currentByte = 0;
//bool isBitAlreadyExist = false;
//bool isSelectBitChange = false;
//bool[] _boolArray = new bool[8];
////if the value has changed at same bit position of the same byte
//isSelectBitChange = IsSelectBitChanged(prevTriggerBoolArray,
_boolArray, bitIndex);
// //if byte value exported true then click compare radio button
// radioBtnCompare.IsChecked = true;
// //if the bit export value is false then set it to true for mask
// CMBIT1_DATA_BYTES[byteNumber] = (bitValue == true) ?
currentMaskByte : _currentByte;
// CMBIT1_DATA_BYTES[triggerNumber] = currentMaskByte;
//}
// else
// {
// CMBIT1_DATA_BYTES[byteNumber] = (bitValue == true) ? (byte)
(currentMaskByte + previousMaskByte) : (byte)(_currentByte + previousMaskByte);
// CMBIT1_DATA_BYTES[triggerNumber] = (bitValue == true) ?
(byte)(currentMaskByte + prevTriggerByte) : prevTriggerByte;
// radioBtnCompare.IsChecked = true;
// }
//}
////replace previous data with new one
//else if (CANBUS_MSG_IDS[3] != canId)
//{
// var result = await MetroMain.ShowMessageAsync("Do you want to
replace the data?", $"Another bit is already exist with id {prevMsgId} at tab CM
Position 2", MessageDialogStyle.AffirmativeAndNegative, settings: dialogSettings);
// if (result == MessageDialogResult.Affirmative)
// {
// CANBUS_MSG_SOURCE[3] = (byte)portValue;
// CANBUS_MSG_IDS[3] = canId;
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
//var dictionary =
selectedData.GetType().GetProperties().ToDictionary(property => property.Name,
property => property.GetValue(selectedData));
//var hexval = dictionary.Where(x => x.Key ==
byteName).FirstOrDefault();
//var selectedCollection = (dynamic)hexval.Value;
//var comingArray =
(ObservableCollection<bool>)selectedCollection.ByteCollection;
//var comingByte = ConvertBoolArrayToByte(comingArray.ToArray());
//var updatedTriggerByte =
ConvertBoolArrayToByte(changeBitTriggerBoolArray.Reverse().ToArray());
//byte _currentByte = 0;
//bool isBitAlreadyExist = false;
//bool isSelectBitChange = false;
//bool[] _boolArray = new bool[8];
////if the value has changed at same bit position of the same byte
//isSelectBitChange = IsSelectBitChanged(prevTriggerBoolArray,
_boolArray, bitIndex);
//int tabIndex = 2;
//var rbPref = "radCMBit";
//var sepratorKey = "B";
//var sepratorIgnore = "I";
// //if byte value exported true then click compare radio button
// radioBtnCompare.IsChecked = true;
// //if the bit export value is false then set it to true for mask
// CMBIT2_DATA_BYTES[byteNumber] = (bitValue == true) ?
currentMaskByte : _currentByte;
// CMBIT2_DATA_BYTES[triggerNumber] = currentMaskByte;
//}
// else
// {
// CMBIT2_DATA_BYTES[byteNumber] = (bitValue == true) ? (byte)
(currentMaskByte + previousMaskByte) : (byte)(_currentByte + previousMaskByte);
// CMBIT2_DATA_BYTES[triggerNumber] = (bitValue == true) ?
(byte)(currentMaskByte + prevTriggerByte) : prevTriggerByte;
// radioBtnCompare.IsChecked = true;
// }
//}
////replace previous data with new one
//else if (CANBUS_MSG_IDS[4] != canId)
//{
// var result = await MetroMain.ShowMessageAsync("Do you want to
replace the data?", $"Another bit is already exist with id {prevMsgId} at tab CM
Position 3", MessageDialogStyle.AffirmativeAndNegative, settings: dialogSettings);
// if (result == MessageDialogResult.Affirmative)
// {
// CANBUS_MSG_SOURCE[4] = (byte)portValue;
// CANBUS_MSG_IDS[4] = canId;
// //reset data bytes 0 -7
// for (int i = 0; i < 8; i++)
// {
// CMBIT2_DATA_BYTES[i] = (byte)0;
// CMBIT2_DATA_BYTES[i + 8] = (byte)0;
// var prevRadioButton = $"{rbPref}{tabIndex}{sepratorKey}
{i}{sepratorIgnore}";
// var prevRadioBtnByte =
(RadioButton)this.FindName(prevRadioButton);
// prevRadioBtnByte.IsChecked = true;
// }
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
//Commented code for every position. Will remove after customer
feedback.
#region CommentedCode
//List<bool> objList = new List<bool>();
//MenuItem chk = (MenuItem)sender;
//var selectedData = (DataGridItem)chk.DataContext;
//uint canId = Convert.ToUInt32(selectedData.ID, 16);
//var canPort = selectedData.Port;
//var canFormat = selectedData.MessageFormat;
//var comingArray =
(ObservableCollection<bool>)selectedCollection.ByteCollection;
//var comingByte = ConvertBoolArrayToByte(comingArray.ToArray());
//var updatedTriggerByte =
ConvertBoolArrayToByte(changeBitTriggerBoolArray.Reverse().ToArray());
//byte _currentByte = 0;
//bool isBitAlreadyExist = false;
//bool isSelectBitChange = false;
//bool[] _boolArray = new bool[8];
////if the value has changed at same bit position of the same byte
//isSelectBitChange = IsSelectBitChanged(prevTriggerBoolArray,
_boolArray, bitIndex);
//int tabIndex = 3;
//var rbPref = "radCMBit";
//var sepratorKey = "B";
//var sepratorIgnore = "I";
// //if byte value exported true then click compare radio button
// radioBtnCompare.IsChecked = true;
// //if the bit export value is false then set it to true for mask
// CMBIT3_DATA_BYTES[byteNumber] = (bitValue == true) ?
currentMaskByte : _currentByte;
// CMBIT3_DATA_BYTES[triggerNumber] = currentMaskByte;
//}
// else
// {
// CMBIT3_DATA_BYTES[byteNumber] = (bitValue == true) ? (byte)
(currentMaskByte + previousMaskByte) : (byte)(_currentByte + previousMaskByte);
// CMBIT3_DATA_BYTES[triggerNumber] = (bitValue == true) ?
(byte)(currentMaskByte + prevTriggerByte) : prevTriggerByte;
// radioBtnCompare.IsChecked = true;
// }
//}
////replace previous data with new one
//else if (CANBUS_MSG_IDS[5] != canId)
//{
// var result = await MetroMain.ShowMessageAsync("Do you want to
replace the data?", $"Another bit is already exist with id {prevMsgId} at tab CM
Position 4", MessageDialogStyle.AffirmativeAndNegative, settings: dialogSettings);
// if (result == MessageDialogResult.Affirmative)
// {
// CANBUS_MSG_SOURCE[5] = (byte)portValue;
// CANBUS_MSG_IDS[5] = canId;
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
//var dictionary =
selectedData.GetType().GetProperties().ToDictionary(property => property.Name,
property => property.GetValue(selectedData));
//var hexval = dictionary.Where(x => x.Key ==
byteName).FirstOrDefault();
//var selectedCollection = (dynamic)hexval.Value;
//var comingArray =
(ObservableCollection<bool>)selectedCollection.ByteCollection;
//var comingByte = ConvertBoolArrayToByte(comingArray.ToArray());
//var updatedTriggerByte =
ConvertBoolArrayToByte(changeBitTriggerBoolArray.Reverse().ToArray());
//byte _currentByte = 0;
//bool isBitAlreadyExist = false;
//bool isSelectBitChange = false;
//bool[] _boolArray = new bool[8];
////if the value has changed at same bit position of the same byte
//isSelectBitChange = IsSelectBitChanged(prevTriggerBoolArray,
_boolArray, bitIndex);
//int tabIndex = 4;
//var rbPref = "radCMBit";
//var sepratorKey = "B";
//var sepratorIgnore = "I";
// //if byte value exported true then click compare radio button
// radioBtnCompare.IsChecked = true;
// //if the bit export value is false then set it to true for mask
// CMBIT4_DATA_BYTES[byteNumber] = (bitValue == true) ?
currentMaskByte : _currentByte;
// CMBIT4_DATA_BYTES[triggerNumber] = currentMaskByte;
//}
// else
// {
// CMBIT4_DATA_BYTES[byteNumber] = (bitValue == true) ? (byte)
(currentMaskByte + previousMaskByte) : (byte)(_currentByte + previousMaskByte);
// CMBIT4_DATA_BYTES[triggerNumber] = (bitValue == true) ?
(byte)(currentMaskByte + prevTriggerByte) : prevTriggerByte;
// radioBtnCompare.IsChecked = true;
// }
//}
////replace previous data with new one
//else if (CANBUS_MSG_IDS[6] != canId)
//{
// var result = await MetroMain.ShowMessageAsync("Do you want to
replace the data?", $"Another bit is already exist with id {prevMsgId} at tab CM
Position 5", MessageDialogStyle.AffirmativeAndNegative, settings: dialogSettings);
// if (result == MessageDialogResult.Affirmative)
// {
// CANBUS_MSG_SOURCE[6] = (byte)portValue;
// CANBUS_MSG_IDS[6] = canId;
//var dictionary =
selectedData.GetType().GetProperties().ToDictionary(property => property.Name,
property => property.GetValue(selectedData));
//var hexval = dictionary.Where(x => x.Key ==
byteName).FirstOrDefault();
//var selectedCollection = (dynamic)hexval.Value;
//var comingArray =
(ObservableCollection<bool>)selectedCollection.ByteCollection;
//var comingByte = ConvertBoolArrayToByte(comingArray.ToArray());
//var updatedTriggerByte =
ConvertBoolArrayToByte(changeBitTriggerBoolArray.Reverse().ToArray());
//byte _currentByte = 0;
//bool isBitAlreadyExist = false;
//bool isSelectBitChange = false;
//bool[] _boolArray = new bool[8];
////if the value has changed at same bit position of the same byte
//isSelectBitChange = IsSelectBitChanged(prevTriggerBoolArray,
_boolArray, bitIndex);
//int tabIndex = 5;
//var rbPref = "radCMBit";
//var sepratorKey = "B";
//var sepratorIgnore = "I";
// //if byte value exported true then click compare radio button
// radioBtnCompare.IsChecked = true;
// //if the bit export value is false then set it to true for mask
// CMBIT5_DATA_BYTES[byteNumber] = (bitValue == true) ?
currentMaskByte : _currentByte;
// CMBIT5_DATA_BYTES[triggerNumber] = currentMaskByte;
//}
// else
// {
// CMBIT5_DATA_BYTES[byteNumber] = (bitValue == true) ? (byte)
(currentMaskByte + previousMaskByte) : (byte)(_currentByte + previousMaskByte);
// CMBIT5_DATA_BYTES[triggerNumber] = (bitValue == true) ?
(byte)(currentMaskByte + prevTriggerByte) : prevTriggerByte;
// radioBtnCompare.IsChecked = true;
// }
//}
////replace previous data with new one
//else if (CANBUS_MSG_IDS[7] != canId)
//{
// var result = await MetroMain.ShowMessageAsync("Do you want to
replace the data?", $"Another bit is already exist with id {prevMsgId} at tab CM
Position 6", MessageDialogStyle.AffirmativeAndNegative, settings: dialogSettings);
// if (result == MessageDialogResult.Affirmative)
// {
// CANBUS_MSG_SOURCE[7] = (byte)portValue;
// CANBUS_MSG_IDS[7] = canId;
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
var dictionary =
selectedData.GetType().GetProperties().ToDictionary(property => property.Name,
property => property.GetValue(selectedData));
var hexval = dictionary.Where(x => x.Key == byteName).FirstOrDefault();
var selectedCollection = (dynamic)hexval.Value;
var comingArray =
(ObservableCollection<bool>)selectedCollection.ByteCollection;
var comingByte = ConvertBoolArrayToByte(comingArray.ToArray());
var updatedTriggerByte =
ConvertBoolArrayToByte(changeBitTriggerBoolArray.Reverse().ToArray());
byte _currentByte = 0;
bool isBitAlreadyExist = false;
bool isSelectBitChange = false;
bool[] _boolArray = new bool[8];
int tabIndex = 6;
var rbPref = "radCMBit";
var sepratorKey = "B";
var sepratorIgnore = "I";
//if byte value exported true then click compare radio button
radioBtnCompare.IsChecked = true;
//if the bit export value is false then set it to true for mask
CMBIT6_DATA_BYTES[byteNumber] = (bitValue == true) ?
currentMaskByte : _currentByte;
CMBIT6_DATA_BYTES[triggerNumber] = currentMaskByte;
}
else
{
CMBIT6_DATA_BYTES[byteNumber] = (bitValue == true) ? (byte)
(currentMaskByte + previousMaskByte) : (byte)(_currentByte + previousMaskByte);
CMBIT6_DATA_BYTES[triggerNumber] = (bitValue == true) ? (byte)
(currentMaskByte + prevTriggerByte) : prevTriggerByte;
radioBtnCompare.IsChecked = true;
}
}
//replace previous data with new one
else if (CANBUS_MSG_IDS[8] != canId)
{
var result = await MetroMain.ShowMessageAsync("Do you want to
replace the data?", $"Another bit is already exist with id {prevMsgId} at tab CM
Position 7", MessageDialogStyle.AffirmativeAndNegative, settings: dialogSettings);
if (result == MessageDialogResult.Affirmative)
{
CANBUS_MSG_SOURCE[8] = (byte)portValue;
CANBUS_MSG_IDS[8] = canId;
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
}
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
//Commented code for every position. Will remove after customer
feedback.
}
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
}
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
}
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
}
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
}
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
}
ExportBytesToConfiguration(param);
if (isFetchFromCloud)
{
ResetControlsForIdx(param.CanMsgIdIndex);
}
return;
}
private bool exportBytesFromScannerToConfig = false;
/// <summary>
/// Generic method to execute export process with required parameters such
as:
/// <list type="bullet">
/// <item><description>Message Indexes</description></item>
/// <item><description>Byte Data Collections</description></item>
/// <item><description>Radio Button references, etc</description></item>
/// </list>
/// </summary>
/// <param name="request"></param>
private async void ExportBytesToConfiguration(ExportRequest request)
{
exportBytesFromScannerToConfig = true;
isExportSettingsPressed = false;
var sourceIndex = request.CanMsgSourceIndex;
var idIndex = request.CanMsgIdIndex;
if (exportedItem.HasSelectedBits)
{
var dataGridItem = dataGridItems.ToList().FirstOrDefault(a => a.ID
== exportedItem.HexCanId);
if (dataGridItem != null)
{
var canPort = dataGridItem.Port;
var canFormat = dataGridItem.MessageFormat;
uint canId = Convert.ToUInt32(dataGridItem.ID, 16);
var portValue = ExtensionHelper.GetCanPortInteger(canPort);
//bool[] maskBoolArray =
ConvertByteToBoolArray(previousMaskByte);
//bool[] prevMaskBoolArray =
maskBoolArray.Reverse().ToArray();
//byte _currentByte = 0;
//bool isBitAlreadyExist = false;
//if (!bitValue)
//{
// triggerArray[bitIndex] = true;
// bool[] _currentMaskBoolArray =
triggerArray.Reverse().ToArray();
// _currentByte =
ConvertBoolArrayToByte(_currentMaskBoolArray);
//}
//else
//{
// isBitAlreadyExist =
CheckIfCurrentBitIsAlreadyExist(prevMaskBoolArray, maskArray, bitIndex);
//}
//alreadyExists.Add(isBitAlreadyExist);
maskArray = selectionList.ToArray();
byte maskByte =
ConvertBoolArrayToByte(maskArray.Reverse().ToArray());
byte triggerByte =
ConvertBoolArrayToByte(triggerArray.Reverse().ToArray());
if (result == MessageDialogResult.Affirmative)
{
CANBUS_MSG_SOURCE[sourceIndex] = (byte)portValue;
CANBUS_MSG_IDS[idIndex] = canId;
//ChangeTextBlockColor(prevIgnoreRadioBtnByte,
Brushes.White);
//var prevCompareRadioButton = $"{rbPref}
{tabIndex}{sepratorKey}{i}{sepratorKey}";
//var prevCompareRadioBtnByte =
(RadioButton)this.FindName(prevCompareRadioButton);
//prevCompareRadioBtnByte.IsChecked = false;
}
request.BitDataBytes[byteNumber] = maskByte;
request.BitDataBytes[triggerNumber] = triggerByte;
// else
// {
// CMBIT0_DATA_BYTES[byteNumber] = (bitValue ==
true) ? (byte)(currentMaskByte + previousMaskByte) : (byte)(_currentByte +
previousMaskByte);
// CMBIT0_DATA_BYTES[triggerNumber] = (bitValue ==
true) ? (byte)(currentMaskByte + prevTriggerByte) : prevTriggerByte;
// radioBtnCompare.IsChecked = true;
// }
//}
}
}
}
else
{
var result = await MetroMain.ShowMessageAsync("Export Selection",
"No bits are selected! Please select bits for export.",
MessageDialogStyle.Affirmative);
}
}
messageIdDict.Add(textBoxName,
CANBUS_MSG_IDS[Convert.ToInt32(tabIndex)]);
messageSourceDict.Add(textBoxName,
CANBUS_MSG_SOURCE[Convert.ToInt32(tabIndex)]);
messageFormatDict.Add(rbStandardName, (bool)rbStandard.IsChecked);
else
CANBUS_MSG_IDS[Convert.ToInt32(tabIndex)] = 0;
if (inputSource.Value > 0)
CANBUS_MSG_SOURCE[Convert.ToInt32(tabIndex)] =
inputSource.Value;
else
CANBUS_MSG_SOURCE[Convert.ToInt32(tabIndex)] = 0;
if (inputFormatStandard.Key != null)
{
if (inputFormatStandard.Value == false) //prev selected option
is not 'standard'
{
if (rbExtended.IsChecked == false)
rbExtended.IsChecked = true; //it would be 'extended'
definitely
}
if (msgFormatStandard.Key != null)
{
if (msgFormatStandard.Value == false) //prev selected option is
not 'standard'
{
if (rbExtended.IsChecked == false)
rbExtended.IsChecked = true; //it would be 'extended'
definitely
}
if (msgId.Key != null)
messageIdDict.Remove(msgId.Key);
if (msgSource.Key != null)
messageSourceDict.Remove(msgSource.Key);
if (msgFormatStandard.Key != null)
messageFormatDict.Remove(msgFormatStandard.Key);
}
messageIdDict.Add(textBoxName, CANBUS_MSG_IDS[tabIndexCan]);
messageSourceDict.Add(textBoxName, CANBUS_MSG_SOURCE[tabIndexCan]);
messageFormatDict.Add(rbStandardName, (bool)rbStandard.IsChecked);
else
CANBUS_MSG_IDS[tabIndexCan] = 0;
if (inputSource.Value > 0)
CANBUS_MSG_SOURCE[tabIndexCan] = inputSource.Value;
else
CANBUS_MSG_SOURCE[tabIndexCan] = 0;
if (inputFormatStandard.Key != null)
{
if (inputFormatStandard.Value == false) //prev selected option
is not 'standard'
{
if (rbExtended.IsChecked == false)
rbExtended.IsChecked = true; //it would be 'extended'
definitely
}
}
else
{
if (rbStandard.IsChecked == false)
rbStandard.IsChecked = true;
}
if (msgFormatStandard.Key != null)
{
if (msgFormatStandard.Value == false) //prev selected option is
not 'standard'
{
if (rbExtended.IsChecked == false)
rbExtended.IsChecked = true; //it would be 'extended'
definitely
}
if (msgId.Key != null)
messageIdDict.Remove(msgId.Key);
if (msgSource.Key != null)
messageSourceDict.Remove(msgSource.Key);
if (msgFormatStandard.Key != null)
messageFormatDict.Remove(msgFormatStandard.Key);
}
/**
* Sending connectivity status on window loaded
*/
public async void MetroMain_Loaded(object sender, RoutedEventArgs e)
{
await FetchedSignalTypes();
if (SystemInformationHelper.CheckInternet())
{
await GetCarModels();
}
else
{
//Car carBrands = await SessionHelper.CheckLocalCarBrands();
//if (carBrands != null)
//{
// var carMakeCollection = new
ObservableCollection<GetMakeNames>(carBrands.getMakeNames);
// this.comboCar.ItemsSource = carMakeCollection;
// // var selectedItem =
(GetMakeNames)comboCar.SelectedValue;
// // this.comboCarModel.ItemsSource =
carModelCollection.Where(o => o.makeId == selectedItem.id);
// //}
//}
}
Session session = await SessionHelper.CheckLocalSession();
if (session != null)
{
await GetCarMakes();
cmbScanBaudCAN0.SelectedIndex = session.CanVIndex ?? 1;
//cmbBaudCAN0.SelectedIndex = session.CanVIndex ?? 1;
cmbScanBaudCAN1.SelectedIndex = session.CanIndex ?? 1;
await ConnectivityStatus(true, session.Token);
}
}
/**
* Making sure to turn OFF the scanner mode when closing.
*/
private void Window_Closing(object sender, CancelEventArgs e)
{
Byte[] buffer = new Byte[64];
buffer[0] = (Byte)'$';
buffer[1] = (Byte)'0'; //Interact with CAN Scanner
e.Cancel = true;
if (SystemInformationHelper.CheckInternet())
{
Session session = Task.Run(() =>
SessionHelper.CheckLocalSession().GetAwaiter().GetResult()).GetAwaiter().GetResult(
);
if (session != null)
{
Task.Run(() => ConnectivityStatus(false,
session.Token).GetAwaiter().GetResult()).GetAwaiter().GetResult();
}
}
Task.Run(() =>
StoreCanIDs().GetAwaiter().GetResult()).GetAwaiter().GetResult();
e.Cancel = false;
}
//Temporary Message ID
public ObservableCollection<UInt32> CANBUS_MSG_IDS_COPY { get; set; }
public Dictionary<int, string> MSG_FORMAT_COPY { get; set; } = new
Dictionary<int, string>();
public Dictionary<int, string> CAN_PORT_COPY { get; set; } = new
Dictionary<int, string>();
if ((saveDialog.ShowDialog() == true))
{
//start setup for profile controller
var dialogSettings = new MetroDialogSettings()
{
AnimateShow = false,
AnimateHide = false
};
await Task.Delay(100);
profileController.SetProgress(20);
try
{
var customBtsPref = "cbBts";
var customPref = "cbCM";
var customPost = "Msg_custom";
eProfile.Name = (saveDialog.FileName);
eProfile.SetValue("CAN_Master_Profile", "DATE",
DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
eProfile.SetValue("CAN_Master_Profile", "FIRMWARE",
tbFirmware.Text);
eProfile.SetValue("CAN_Master_Profile", "GUI_VER",
$"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(3)}
");
//Logical Functions
eProfile.SetValue("BTS0", "Byte_0_LogicFunction",
BTS0_DATA_BYTES[16]);
eProfile.SetValue("BTS0", "Byte_1_LogicFunction",
BTS0_DATA_BYTES[17]);
eProfile.SetValue("BTS0", "Byte_2_LogicFunction",
BTS0_DATA_BYTES[18]);
eProfile.SetValue("BTS0", "Byte_3_LogicFunction",
BTS0_DATA_BYTES[19]);
eProfile.SetValue("BTS0", "Byte_4_LogicFunction",
BTS0_DATA_BYTES[20]);
eProfile.SetValue("BTS0", "Byte_5_LogicFunction",
BTS0_DATA_BYTES[21]);
eProfile.SetValue("BTS0", "Byte_6_LogicFunction",
BTS0_DATA_BYTES[22]);
eProfile.SetValue("BTS0", "Byte_7_LogicFunction",
BTS0_DATA_BYTES[23]);
#endregion
#region BTS1
eProfile.SetValue("BTS1", "Source", CANBUS_MSG_SOURCE[1]);
eProfile.SetValue("BTS1", "Message_ID", CANBUS_MSG_IDS[1]);
var selectedFormat1 = radBts1MsgTyS.IsChecked == true ? "STD" :
"EXT";
eProfile.SetValue("BTS1", "Format", selectedFormat1);
eProfile.SetValue("BTS1", "Byte_0_Mask", BTS1_DATA_BYTES[0]);
eProfile.SetValue("BTS1", "Byte_1_Mask", BTS1_DATA_BYTES[1]);
eProfile.SetValue("BTS1", "Byte_2_Mask", BTS1_DATA_BYTES[2]);
eProfile.SetValue("BTS1", "Byte_3_Mask", BTS1_DATA_BYTES[3]);
eProfile.SetValue("BTS1", "Byte_4_Mask", BTS1_DATA_BYTES[4]);
eProfile.SetValue("BTS1", "Byte_5_Mask", BTS1_DATA_BYTES[5]);
eProfile.SetValue("BTS1", "Byte_6_Mask", BTS1_DATA_BYTES[6]);
eProfile.SetValue("BTS1", "Byte_7_Mask", BTS1_DATA_BYTES[7]);
eProfile.SetValue("BTS1", "Byte_0_Trigger",
BTS1_DATA_BYTES[8]);
eProfile.SetValue("BTS1", "Byte_1_Trigger",
BTS1_DATA_BYTES[9]);
eProfile.SetValue("BTS1", "Byte_2_Trigger",
BTS1_DATA_BYTES[10]);
eProfile.SetValue("BTS1", "Byte_3_Trigger",
BTS1_DATA_BYTES[11]);
eProfile.SetValue("BTS1", "Byte_4_Trigger",
BTS1_DATA_BYTES[12]);
eProfile.SetValue("BTS1", "Byte_5_Trigger",
BTS1_DATA_BYTES[13]);
eProfile.SetValue("BTS1", "Byte_6_Trigger",
BTS1_DATA_BYTES[14]);
eProfile.SetValue("BTS1", "Byte_7_Trigger",
BTS1_DATA_BYTES[15]);
//Logical Functions
eProfile.SetValue("BTS1", "Byte_0_LogicFunction",
BTS1_DATA_BYTES[16]);
eProfile.SetValue("BTS1", "Byte_1_LogicFunction",
BTS1_DATA_BYTES[17]);
eProfile.SetValue("BTS1", "Byte_2_LogicFunction",
BTS1_DATA_BYTES[18]);
eProfile.SetValue("BTS1", "Byte_3_LogicFunction",
BTS1_DATA_BYTES[19]);
eProfile.SetValue("BTS1", "Byte_4_LogicFunction",
BTS1_DATA_BYTES[20]);
eProfile.SetValue("BTS1", "Byte_5_LogicFunction",
BTS1_DATA_BYTES[21]);
eProfile.SetValue("BTS1", "Byte_6_LogicFunction",
BTS1_DATA_BYTES[22]);
eProfile.SetValue("BTS1", "Byte_7_LogicFunction",
BTS1_DATA_BYTES[23]);
#endregion
eProfile.SetValue($"BTS{index}", "Custom",
customCheckBox0.IsChecked);
}
//Logical Functions
eProfile.SetValue("CM_Position_1", "Byte_0_LogicFunction",
CMBIT0_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_1", "Byte_1_LogicFunction",
CMBIT0_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_1", "Byte_2_LogicFunction",
CMBIT0_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_1", "Byte_3_LogicFunction",
CMBIT0_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_1", "Byte_4_LogicFunction",
CMBIT0_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_1", "Byte_5_LogicFunction",
CMBIT0_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_1", "Byte_6_LogicFunction",
CMBIT0_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_1", "Byte_7_LogicFunction",
CMBIT0_DATA_BYTES[23]);
#endregion
#region CM Position 2
eProfile.SetValue("CM_Position_2", "Source",
CANBUS_MSG_SOURCE[3]);
eProfile.SetValue("CM_Position_2", "Message_ID",
CANBUS_MSG_IDS[3]);
var selectedFormat3 = radCMBit1MsgTyS.IsChecked == true ? "STD"
: "EXT";
eProfile.SetValue("CM_Position_2", "Format", selectedFormat3);
eProfile.SetValue("CM_Position_2", "Byte_0_Mask",
CMBIT1_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_2", "Byte_0_Trigger",
CMBIT1_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_2", "Byte_1_Mask",
CMBIT1_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_2", "Byte_1_Trigger",
CMBIT1_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_2", "Byte_2_Mask",
CMBIT1_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_2", "Byte_2_Trigger",
CMBIT1_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_2", "Byte_3_Mask",
CMBIT1_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_2", "Byte_3_Trigger",
CMBIT1_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_2", "Byte_4_Mask",
CMBIT1_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_2", "Byte_4_Trigger",
CMBIT1_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_2", "Byte_5_Mask",
CMBIT1_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_2", "Byte_5_Trigger",
CMBIT1_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_2", "Byte_6_Mask",
CMBIT1_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_2", "Byte_6_Trigger",
CMBIT1_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_2", "Byte_7_Mask",
CMBIT1_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_2", "Byte_7_Trigger",
CMBIT1_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_2", "Byte_0_LogicFunction",
CMBIT1_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_2", "Byte_1_LogicFunction",
CMBIT1_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_2", "Byte_2_LogicFunction",
CMBIT1_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_2", "Byte_3_LogicFunction",
CMBIT1_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_2", "Byte_4_LogicFunction",
CMBIT1_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_2", "Byte_5_LogicFunction",
CMBIT1_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_2", "Byte_6_LogicFunction",
CMBIT1_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_2", "Byte_7_LogicFunction",
CMBIT1_DATA_BYTES[23]);
#endregion
#region CM Position 3
eProfile.SetValue("CM_Position_3", "Source",
CANBUS_MSG_SOURCE[4]);
eProfile.SetValue("CM_Position_3", "Message_ID",
CANBUS_MSG_IDS[4]);
var selectedFormat4 = radCMBit2MsgTyS.IsChecked == true ? "STD"
: "EXT";
eProfile.SetValue("CM_Position_3", "Format", selectedFormat4);
eProfile.SetValue("CM_Position_3", "Byte_0_Mask",
CMBIT2_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_3", "Byte_0_Trigger",
CMBIT2_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_3", "Byte_1_Mask",
CMBIT2_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_3", "Byte_1_Trigger",
CMBIT2_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_3", "Byte_2_Mask",
CMBIT2_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_3", "Byte_2_Trigger",
CMBIT2_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_3", "Byte_3_Mask",
CMBIT2_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_3", "Byte_3_Trigger",
CMBIT2_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_3", "Byte_4_Mask",
CMBIT2_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_3", "Byte_4_Trigger",
CMBIT2_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_3", "Byte_5_Mask",
CMBIT2_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_3", "Byte_5_Trigger",
CMBIT2_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_3", "Byte_6_Mask",
CMBIT2_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_3", "Byte_6_Trigger",
CMBIT2_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_3", "Byte_7_Mask",
CMBIT2_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_3", "Byte_7_Trigger",
CMBIT2_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_3", "Byte_0_LogicFunction",
CMBIT2_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_3", "Byte_1_LogicFunction",
CMBIT2_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_3", "Byte_2_LogicFunction",
CMBIT2_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_3", "Byte_3_LogicFunction",
CMBIT2_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_3", "Byte_4_LogicFunction",
CMBIT2_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_3", "Byte_5_LogicFunction",
CMBIT2_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_3", "Byte_6_LogicFunction",
CMBIT2_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_3", "Byte_7_LogicFunction",
CMBIT2_DATA_BYTES[23]);
#endregion
#region CM Position 4
eProfile.SetValue("CM_Position_4", "Source",
CANBUS_MSG_SOURCE[5]);
eProfile.SetValue("CM_Position_4", "Message_ID",
CANBUS_MSG_IDS[5]);
var selectedFormat5 = radCMBit3MsgTyS.IsChecked == true ? "STD"
: "EXT";
eProfile.SetValue("CM_Position_4", "Format", selectedFormat5);
eProfile.SetValue("CM_Position_4", "Byte_0_Mask",
CMBIT3_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_4", "Byte_0_Trigger",
CMBIT3_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_4", "Byte_1_Mask",
CMBIT3_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_4", "Byte_1_Trigger",
CMBIT3_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_4", "Byte_2_Mask",
CMBIT3_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_4", "Byte_2_Trigger",
CMBIT3_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_4", "Byte_3_Mask",
CMBIT3_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_4", "Byte_3_Trigger",
CMBIT3_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_4", "Byte_4_Mask",
CMBIT3_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_4", "Byte_4_Trigger",
CMBIT3_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_4", "Byte_5_Mask",
CMBIT3_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_4", "Byte_5_Trigger",
CMBIT3_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_4", "Byte_6_Mask",
CMBIT3_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_4", "Byte_6_Trigger",
CMBIT3_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_4", "Byte_7_Mask",
CMBIT3_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_4", "Byte_7_Trigger",
CMBIT3_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_4", "Byte_0_LogicFunction",
CMBIT3_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_4", "Byte_1_LogicFunction",
CMBIT3_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_4", "Byte_2_LogicFunction",
CMBIT3_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_4", "Byte_3_LogicFunction",
CMBIT3_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_4", "Byte_4_LogicFunction",
CMBIT3_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_4", "Byte_5_LogicFunction",
CMBIT3_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_4", "Byte_6_LogicFunction",
CMBIT3_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_4", "Byte_7_LogicFunction",
CMBIT3_DATA_BYTES[23]);
#endregion
#region CM Position 5
eProfile.SetValue("CM_Position_5", "Source",
CANBUS_MSG_SOURCE[6]);
eProfile.SetValue("CM_Position_5", "Message_ID",
CANBUS_MSG_IDS[6]);
var selectedFormat6 = radCMBit4MsgTyS.IsChecked == true ? "STD"
: "EXT";
eProfile.SetValue("CM_Position_5", "Format", selectedFormat6);
eProfile.SetValue("CM_Position_5", "Byte_0_Mask",
CMBIT4_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_5", "Byte_0_Trigger",
CMBIT4_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_5", "Byte_1_Mask",
CMBIT4_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_5", "Byte_1_Trigger",
CMBIT4_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_5", "Byte_2_Mask",
CMBIT4_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_5", "Byte_2_Trigger",
CMBIT4_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_5", "Byte_3_Mask",
CMBIT4_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_5", "Byte_3_Trigger",
CMBIT4_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_5", "Byte_4_Mask",
CMBIT4_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_5", "Byte_4_Trigger",
CMBIT4_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_5", "Byte_5_Mask",
CMBIT4_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_5", "Byte_5_Trigger",
CMBIT4_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_5", "Byte_6_Mask",
CMBIT4_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_5", "Byte_6_Trigger",
CMBIT4_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_5", "Byte_7_Mask",
CMBIT4_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_5", "Byte_7_Trigger",
CMBIT4_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_5", "Byte_0_LogicFunction",
CMBIT4_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_5", "Byte_1_LogicFunction",
CMBIT4_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_5", "Byte_2_LogicFunction",
CMBIT4_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_5", "Byte_3_LogicFunction",
CMBIT4_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_5", "Byte_4_LogicFunction",
CMBIT4_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_5", "Byte_5_LogicFunction",
CMBIT4_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_5", "Byte_6_LogicFunction",
CMBIT4_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_5", "Byte_7_LogicFunction",
CMBIT4_DATA_BYTES[23]);
#endregion
#region CM Position 6
eProfile.SetValue("CM_Position_6", "Source",
CANBUS_MSG_SOURCE[7]);
eProfile.SetValue("CM_Position_6", "Message_ID",
CANBUS_MSG_IDS[7]);
var selectedFormat7 = radCMBit5MsgTyS.IsChecked == true ? "STD"
: "EXT";
eProfile.SetValue("CM_Position_6", "Format", selectedFormat7);
eProfile.SetValue("CM_Position_6", "Byte_0_Mask",
CMBIT5_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_6", "Byte_0_Trigger",
CMBIT5_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_6", "Byte_1_Mask",
CMBIT5_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_6", "Byte_1_Trigger",
CMBIT5_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_6", "Byte_2_Mask",
CMBIT5_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_6", "Byte_2_Trigger",
CMBIT5_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_6", "Byte_3_Mask",
CMBIT5_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_6", "Byte_3_Trigger",
CMBIT5_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_6", "Byte_4_Mask",
CMBIT5_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_6", "Byte_4_Trigger",
CMBIT5_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_6", "Byte_5_Mask",
CMBIT5_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_6", "Byte_5_Trigger",
CMBIT5_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_6", "Byte_6_Mask",
CMBIT5_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_6", "Byte_6_Trigger",
CMBIT5_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_6", "Byte_7_Mask",
CMBIT5_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_6", "Byte_7_Trigger",
CMBIT5_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_6", "Byte_0_LogicFunction",
CMBIT5_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_6", "Byte_1_LogicFunction",
CMBIT5_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_6", "Byte_2_LogicFunction",
CMBIT5_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_6", "Byte_3_LogicFunction",
CMBIT5_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_6", "Byte_4_LogicFunction",
CMBIT5_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_6", "Byte_5_LogicFunction",
CMBIT5_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_6", "Byte_6_LogicFunction",
CMBIT5_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_6", "Byte_7_LogicFunction",
CMBIT5_DATA_BYTES[23]);
#endregion
#region CM Position 7
eProfile.SetValue("CM_Position_7", "Source",
CANBUS_MSG_SOURCE[8]);
eProfile.SetValue("CM_Position_7", "Message_ID",
CANBUS_MSG_IDS[8]);
var selectedFormat8 = radCMBit6MsgTyS.IsChecked == true ? "STD"
: "EXT";
eProfile.SetValue("CM_Position_7", "Format", selectedFormat8);
eProfile.SetValue("CM_Position_7", "Byte_0_Mask",
CMBIT6_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_7", "Byte_0_Trigger",
CMBIT6_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_7", "Byte_1_Mask",
CMBIT6_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_7", "Byte_1_Trigger",
CMBIT6_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_7", "Byte_2_Mask",
CMBIT6_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_7", "Byte_2_Trigger",
CMBIT6_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_7", "Byte_3_Mask",
CMBIT6_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_7", "Byte_3_Trigger",
CMBIT6_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_7", "Byte_4_Mask",
CMBIT6_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_7", "Byte_4_Trigger",
CMBIT6_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_7", "Byte_5_Mask",
CMBIT6_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_7", "Byte_5_Trigger",
CMBIT6_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_7", "Byte_6_Mask",
CMBIT6_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_7", "Byte_6_Trigger",
CMBIT6_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_7", "Byte_7_Mask",
CMBIT6_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_7", "Byte_7_Trigger",
CMBIT6_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_7", "Byte_0_LogicFunction",
CMBIT6_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_7", "Byte_1_LogicFunction",
CMBIT6_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_7", "Byte_2_LogicFunction",
CMBIT6_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_7", "Byte_3_LogicFunction",
CMBIT6_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_7", "Byte_4_LogicFunction",
CMBIT6_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_7", "Byte_5_LogicFunction",
CMBIT6_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_7", "Byte_6_LogicFunction",
CMBIT6_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_7", "Byte_7_LogicFunction",
CMBIT6_DATA_BYTES[23]);
#endregion
#region CM Position 8
eProfile.SetValue("CM_Position_8", "Source",
CANBUS_MSG_SOURCE[9]);
eProfile.SetValue("CM_Position_8", "Message_ID",
CANBUS_MSG_IDS[9]);
var selectedFormat9 = radCMBit7MsgTyS.IsChecked == true ? "STD"
: "EXT";
eProfile.SetValue("CM_Position_8", "Format", selectedFormat9);
eProfile.SetValue("CM_Position_8", "Byte_0_Mask",
CMBIT7_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_8", "Byte_0_Trigger",
CMBIT7_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_8", "Byte_1_Mask",
CMBIT7_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_8", "Byte_1_Trigger",
CMBIT7_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_8", "Byte_2_Mask",
CMBIT7_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_8", "Byte_2_Trigger",
CMBIT7_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_8", "Byte_3_Mask",
CMBIT7_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_8", "Byte_3_Trigger",
CMBIT7_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_8", "Byte_4_Mask",
CMBIT7_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_8", "Byte_4_Trigger",
CMBIT7_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_8", "Byte_5_Mask",
CMBIT7_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_8", "Byte_5_Trigger",
CMBIT7_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_8", "Byte_6_Mask",
CMBIT7_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_8", "Byte_6_Trigger",
CMBIT7_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_8", "Byte_7_Mask",
CMBIT7_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_8", "Byte_7_Trigger",
CMBIT7_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_8", "Byte_0_LogicFunction",
CMBIT7_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_8", "Byte_1_LogicFunction",
CMBIT7_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_8", "Byte_2_LogicFunction",
CMBIT7_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_8", "Byte_3_LogicFunction",
CMBIT7_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_8", "Byte_4_LogicFunction",
CMBIT7_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_8", "Byte_5_LogicFunction",
CMBIT7_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_8", "Byte_6_LogicFunction",
CMBIT7_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_8", "Byte_7_LogicFunction",
CMBIT7_DATA_BYTES[23]);
#endregion
await Task.Delay(100);
profileController.SetProgress(50);
#region CM Position 9
eProfile.SetValue("CM_Position_9", "Source",
CANBUS_MSG_SOURCE[10]);
eProfile.SetValue("CM_Position_9", "Message_ID",
CANBUS_MSG_IDS[10]);
var selectedFormat10 = radCMBit8MsgTyS.IsChecked == true ?
"STD" : "EXT";
eProfile.SetValue("CM_Position_9", "Format", selectedFormat10);
eProfile.SetValue("CM_Position_9", "Byte_0_Mask",
CMBIT8_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_9", "Byte_0_Trigger",
CMBIT8_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_9", "Byte_1_Mask",
CMBIT8_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_9", "Byte_1_Trigger",
CMBIT8_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_9", "Byte_2_Mask",
CMBIT8_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_9", "Byte_2_Trigger",
CMBIT8_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_9", "Byte_3_Mask",
CMBIT8_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_9", "Byte_3_Trigger",
CMBIT8_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_9", "Byte_4_Mask",
CMBIT8_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_9", "Byte_4_Trigger",
CMBIT8_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_9", "Byte_5_Mask",
CMBIT8_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_9", "Byte_5_Trigger",
CMBIT8_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_9", "Byte_6_Mask",
CMBIT8_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_9", "Byte_6_Trigger",
CMBIT8_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_9", "Byte_7_Mask",
CMBIT8_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_9", "Byte_7_Trigger",
CMBIT8_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_9", "Byte_0_LogicFunction",
CMBIT8_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_9", "Byte_1_LogicFunction",
CMBIT8_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_9", "Byte_2_LogicFunction",
CMBIT8_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_9", "Byte_3_LogicFunction",
CMBIT8_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_9", "Byte_4_LogicFunction",
CMBIT8_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_9", "Byte_5_LogicFunction",
CMBIT8_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_9", "Byte_6_LogicFunction",
CMBIT8_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_9", "Byte_7_LogicFunction",
CMBIT8_DATA_BYTES[23]);
#endregion
#region CM Position 10
eProfile.SetValue("CM_Position_10", "Source",
CANBUS_MSG_SOURCE[11]);
eProfile.SetValue("CM_Position_10", "Message_ID",
CANBUS_MSG_IDS[11]);
var selectedFormat11 = radCMBit9MsgTyS.IsChecked == true ?
"STD" : "EXT";
eProfile.SetValue("CM_Position_10", "Format",
selectedFormat11);
eProfile.SetValue("CM_Position_10", "Byte_0_Mask",
CMBIT9_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_10", "Byte_0_Trigger",
CMBIT9_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_10", "Byte_1_Mask",
CMBIT9_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_10", "Byte_1_Trigger",
CMBIT9_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_10", "Byte_2_Mask",
CMBIT9_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_10", "Byte_2_Trigger",
CMBIT9_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_10", "Byte_3_Mask",
CMBIT9_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_10", "Byte_3_Trigger",
CMBIT9_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_10", "Byte_4_Mask",
CMBIT9_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_10", "Byte_4_Trigger",
CMBIT9_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_10", "Byte_5_Mask",
CMBIT9_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_10", "Byte_5_Trigger",
CMBIT9_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_10", "Byte_6_Mask",
CMBIT9_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_10", "Byte_6_Trigger",
CMBIT9_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_10", "Byte_7_Mask",
CMBIT9_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_10", "Byte_7_Trigger",
CMBIT9_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_10", "Byte_0_LogicFunction",
CMBIT9_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_10", "Byte_1_LogicFunction",
CMBIT9_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_10", "Byte_2_LogicFunction",
CMBIT9_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_10", "Byte_3_LogicFunction",
CMBIT9_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_10", "Byte_4_LogicFunction",
CMBIT9_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_10", "Byte_5_LogicFunction",
CMBIT9_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_10", "Byte_6_LogicFunction",
CMBIT9_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_10", "Byte_7_LogicFunction",
CMBIT9_DATA_BYTES[23]);
#endregion
#region CM Position 11
eProfile.SetValue("CM_Position_11", "Source",
CANBUS_MSG_SOURCE[12]);
eProfile.SetValue("CM_Position_11", "Message_ID",
CANBUS_MSG_IDS[12]);
var selectedFormat12 = radCMBit10MsgTyS.IsChecked == true ?
"STD" : "EXT";
eProfile.SetValue("CM_Position_11", "Format",
selectedFormat12);
eProfile.SetValue("CM_Position_11", "Byte_0_Mask",
CMBIT10_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_11", "Byte_0_Trigger",
CMBIT10_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_11", "Byte_1_Mask",
CMBIT10_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_11", "Byte_1_Trigger",
CMBIT10_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_11", "Byte_2_Mask",
CMBIT10_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_11", "Byte_2_Trigger",
CMBIT10_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_11", "Byte_3_Mask",
CMBIT10_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_11", "Byte_3_Trigger",
CMBIT10_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_11", "Byte_4_Mask",
CMBIT10_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_11", "Byte_4_Trigger",
CMBIT10_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_11", "Byte_5_Mask",
CMBIT10_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_11", "Byte_5_Trigger",
CMBIT10_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_11", "Byte_6_Mask",
CMBIT10_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_11", "Byte_6_Trigger",
CMBIT10_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_11", "Byte_7_Mask",
CMBIT10_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_11", "Byte_7_Trigger",
CMBIT10_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_11", "Byte_0_LogicFunction",
CMBIT10_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_11", "Byte_1_LogicFunction",
CMBIT10_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_11", "Byte_2_LogicFunction",
CMBIT10_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_11", "Byte_3_LogicFunction",
CMBIT10_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_11", "Byte_4_LogicFunction",
CMBIT10_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_11", "Byte_5_LogicFunction",
CMBIT10_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_11", "Byte_6_LogicFunction",
CMBIT10_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_11", "Byte_7_LogicFunction",
CMBIT10_DATA_BYTES[23]);
#endregion
#region CM Position 12
eProfile.SetValue("CM_Position_12", "Source",
CANBUS_MSG_SOURCE[13]);
eProfile.SetValue("CM_Position_12", "Message_ID",
CANBUS_MSG_IDS[13]);
eProfile.SetValue("CM_Position_12", "Source",
CANBUS_MSG_SOURCE[13]);
eProfile.SetValue("CM_Position_12", "Message_ID",
CANBUS_MSG_IDS[13]);
var selectedFormat13 = radCMBit11MsgTyS.IsChecked == true ?
"STD" : "EXT";
eProfile.SetValue("CM_Position_12", "Format",
selectedFormat13);
eProfile.SetValue("CM_Position_12", "Byte_0_Mask",
CMBIT11_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_12", "Byte_0_Trigger",
CMBIT11_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_12", "Byte_1_Mask",
CMBIT11_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_12", "Byte_1_Trigger",
CMBIT11_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_12", "Byte_2_Mask",
CMBIT11_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_12", "Byte_2_Trigger",
CMBIT11_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_12", "Byte_3_Mask",
CMBIT11_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_12", "Byte_3_Trigger",
CMBIT11_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_12", "Byte_4_Mask",
CMBIT11_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_12", "Byte_4_Trigger",
CMBIT11_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_12", "Byte_5_Mask",
CMBIT11_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_12", "Byte_5_Trigger",
CMBIT11_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_12", "Byte_6_Mask",
CMBIT11_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_12", "Byte_6_Trigger",
CMBIT11_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_12", "Byte_7_Mask",
CMBIT11_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_12", "Byte_7_Trigger",
CMBIT11_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_12", "Byte_0_LogicFunction",
CMBIT11_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_12", "Byte_1_LogicFunction",
CMBIT11_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_12", "Byte_2_LogicFunction",
CMBIT11_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_12", "Byte_3_LogicFunction",
CMBIT11_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_12", "Byte_4_LogicFunction",
CMBIT11_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_12", "Byte_5_LogicFunction",
CMBIT11_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_12", "Byte_6_LogicFunction",
CMBIT11_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_12", "Byte_7_LogicFunction",
CMBIT11_DATA_BYTES[23]);
#endregion
#region CM Position 13
eProfile.SetValue("CM_Position_13", "Source",
CANBUS_MSG_SOURCE[14]);
eProfile.SetValue("CM_Position_13", "Message_ID",
CANBUS_MSG_IDS[14]);
var selectedFormat14 = radCMBit12MsgTyS.IsChecked == true ?
"STD" : "EXT";
eProfile.SetValue("CM_Position_13", "Format",
selectedFormat14);
eProfile.SetValue("CM_Position_13", "Byte_0_Mask",
CMBIT12_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_13", "Byte_0_Trigger",
CMBIT12_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_13", "Byte_1_Mask",
CMBIT12_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_13", "Byte_1_Trigger",
CMBIT12_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_13", "Byte_2_Mask",
CMBIT12_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_13", "Byte_2_Trigger",
CMBIT12_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_13", "Byte_3_Mask",
CMBIT12_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_13", "Byte_3_Trigger",
CMBIT12_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_13", "Byte_4_Mask",
CMBIT12_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_13", "Byte_4_Trigger",
CMBIT12_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_13", "Byte_5_Mask",
CMBIT12_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_13", "Byte_5_Trigger",
CMBIT12_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_13", "Byte_6_Mask",
CMBIT12_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_13", "Byte_6_Trigger",
CMBIT12_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_13", "Byte_7_Mask",
CMBIT12_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_13", "Byte_7_Trigger",
CMBIT12_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_13", "Byte_0_LogicFunction",
CMBIT12_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_13", "Byte_1_LogicFunction",
CMBIT12_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_13", "Byte_2_LogicFunction",
CMBIT12_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_13", "Byte_3_LogicFunction",
CMBIT12_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_13", "Byte_4_LogicFunction",
CMBIT12_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_13", "Byte_5_LogicFunction",
CMBIT12_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_13", "Byte_6_LogicFunction",
CMBIT12_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_13", "Byte_7_LogicFunction",
CMBIT12_DATA_BYTES[23]);
#endregion
await Task.Delay(100);
profileController.SetProgress(80);
#region CM Position 14
eProfile.SetValue("CM_Position_14", "Source",
CANBUS_MSG_SOURCE[15]);
eProfile.SetValue("CM_Position_14", "Message_ID",
CANBUS_MSG_IDS[15]);
var selectedFormat15 = radCMBit13MsgTyS.IsChecked == true ?
"STD" : "EXT";
eProfile.SetValue("CM_Position_14", "Format",
selectedFormat15);
eProfile.SetValue("CM_Position_14", "Byte_0_Mask",
CMBIT13_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_14", "Byte_0_Trigger",
CMBIT13_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_14", "Byte_1_Mask",
CMBIT13_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_14", "Byte_1_Trigger",
CMBIT13_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_14", "Byte_2_Mask",
CMBIT13_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_14", "Byte_2_Trigger",
CMBIT13_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_14", "Byte_3_Mask",
CMBIT13_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_14", "Byte_3_Trigger",
CMBIT13_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_14", "Byte_4_Mask",
CMBIT13_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_14", "Byte_4_Trigger",
CMBIT13_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_14", "Byte_5_Mask",
CMBIT13_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_14", "Byte_5_Trigger",
CMBIT13_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_14", "Byte_6_Mask",
CMBIT13_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_14", "Byte_6_Trigger",
CMBIT13_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_14", "Byte_7_Mask",
CMBIT13_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_14", "Byte_7_Trigger",
CMBIT13_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_14", "Byte_0_LogicFunction",
CMBIT13_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_14", "Byte_1_LogicFunction",
CMBIT13_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_14", "Byte_2_LogicFunction",
CMBIT13_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_14", "Byte_3_LogicFunction",
CMBIT13_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_14", "Byte_4_LogicFunction",
CMBIT13_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_14", "Byte_5_LogicFunction",
CMBIT13_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_14", "Byte_6_LogicFunction",
CMBIT13_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_14", "Byte_7_LogicFunction",
CMBIT13_DATA_BYTES[23]);
#endregion
#region CM Position 15
eProfile.SetValue("CM_Position_15", "Source",
CANBUS_MSG_SOURCE[16]);
eProfile.SetValue("CM_Position_15", "Message_ID",
CANBUS_MSG_IDS[16]);
var selectedFormat16 = radCMBit14MsgTyS.IsChecked == true ?
"STD" : "EXT";
eProfile.SetValue("CM_Position_15", "Format",
selectedFormat16);
eProfile.SetValue("CM_Position_15", "Byte_0_Mask",
CMBIT14_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_15", "Byte_0_Trigger",
CMBIT14_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_15", "Byte_1_Mask",
CMBIT14_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_15", "Byte_1_Trigger",
CMBIT14_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_15", "Byte_2_Mask",
CMBIT14_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_15", "Byte_2_Trigger",
CMBIT14_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_15", "Byte_3_Mask",
CMBIT14_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_15", "Byte_3_Trigger",
CMBIT14_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_15", "Byte_4_Mask",
CMBIT14_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_15", "Byte_4_Trigger",
CMBIT14_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_15", "Byte_5_Mask",
CMBIT14_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_15", "Byte_5_Trigger",
CMBIT14_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_15", "Byte_6_Mask",
CMBIT14_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_15", "Byte_6_Trigger",
CMBIT14_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_15", "Byte_7_Mask",
CMBIT14_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_15", "Byte_7_Trigger",
CMBIT14_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_15", "Byte_0_LogicFunction",
CMBIT14_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_15", "Byte_1_LogicFunction",
CMBIT14_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_15", "Byte_2_LogicFunction",
CMBIT14_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_15", "Byte_3_LogicFunction",
CMBIT14_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_15", "Byte_4_LogicFunction",
CMBIT14_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_15", "Byte_5_LogicFunction",
CMBIT14_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_15", "Byte_6_LogicFunction",
CMBIT14_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_15", "Byte_7_LogicFunction",
CMBIT14_DATA_BYTES[23]);
#endregion
#region CM Position 16
eProfile.SetValue("CM_Position_16", "Source",
CANBUS_MSG_SOURCE[17]);
eProfile.SetValue("CM_Position_16", "Message_ID",
CANBUS_MSG_IDS[17]);
var selectedFormat17 = radCMBit15MsgTyS.IsChecked == true ?
"STD" : "EXT";
eProfile.SetValue("CM_Position_16", "Format",
selectedFormat17);
eProfile.SetValue("CM_Position_16", "Byte_0_Mask",
CMBIT15_DATA_BYTES[0]);
eProfile.SetValue("CM_Position_16", "Byte_0_Trigger",
CMBIT15_DATA_BYTES[0 + 8]);
eProfile.SetValue("CM_Position_16", "Byte_1_Mask",
CMBIT15_DATA_BYTES[1]);
eProfile.SetValue("CM_Position_16", "Byte_1_Trigger",
CMBIT15_DATA_BYTES[1 + 8]);
eProfile.SetValue("CM_Position_16", "Byte_2_Mask",
CMBIT15_DATA_BYTES[2]);
eProfile.SetValue("CM_Position_16", "Byte_2_Trigger",
CMBIT15_DATA_BYTES[2 + 8]);
eProfile.SetValue("CM_Position_16", "Byte_3_Mask",
CMBIT15_DATA_BYTES[3]);
eProfile.SetValue("CM_Position_16", "Byte_3_Trigger",
CMBIT15_DATA_BYTES[3 + 8]);
eProfile.SetValue("CM_Position_16", "Byte_4_Mask",
CMBIT15_DATA_BYTES[4]);
eProfile.SetValue("CM_Position_16", "Byte_4_Trigger",
CMBIT15_DATA_BYTES[4 + 8]);
eProfile.SetValue("CM_Position_16", "Byte_5_Mask",
CMBIT15_DATA_BYTES[5]);
eProfile.SetValue("CM_Position_16", "Byte_5_Trigger",
CMBIT15_DATA_BYTES[5 + 8]);
eProfile.SetValue("CM_Position_16", "Byte_6_Mask",
CMBIT15_DATA_BYTES[6]);
eProfile.SetValue("CM_Position_16", "Byte_6_Trigger",
CMBIT15_DATA_BYTES[6 + 8]);
eProfile.SetValue("CM_Position_16", "Byte_7_Mask",
CMBIT15_DATA_BYTES[7]);
eProfile.SetValue("CM_Position_16", "Byte_7_Trigger",
CMBIT15_DATA_BYTES[7 + 8]);
//Logical Functions
eProfile.SetValue("CM_Position_16", "Byte_0_LogicFunction",
CMBIT15_DATA_BYTES[16]);
eProfile.SetValue("CM_Position_16", "Byte_1_LogicFunction",
CMBIT15_DATA_BYTES[17]);
eProfile.SetValue("CM_Position_16", "Byte_2_LogicFunction",
CMBIT15_DATA_BYTES[18]);
eProfile.SetValue("CM_Position_16", "Byte_3_LogicFunction",
CMBIT15_DATA_BYTES[19]);
eProfile.SetValue("CM_Position_16", "Byte_4_LogicFunction",
CMBIT15_DATA_BYTES[20]);
eProfile.SetValue("CM_Position_16", "Byte_5_LogicFunction",
CMBIT15_DATA_BYTES[21]);
eProfile.SetValue("CM_Position_16", "Byte_6_LogicFunction",
CMBIT15_DATA_BYTES[22]);
eProfile.SetValue("CM_Position_16", "Byte_7_LogicFunction",
CMBIT15_DATA_BYTES[23]);
#endregion
eProfile.SetValue($"CM_Position_{tab}", "Custom",
customCheckBox.IsChecked);
customIndex++;
}
//Vehicle Settings
//var carMake = comboCar.Items;
//var allItems = comboCar.Items.SourceCollection;
//var carList = comboCar.Items.Cast<GetMakeNames>().ToList();
//var carMAkeT = carList.FindIndex(o => o.make == "Honda");
CarData carData = await SessionHelper.CheckLocalCarData();
if (carData != null)
{
//eProfile.SetValue("Vehicle_Settings", "tester", carData);
//var selectedCarMake =
(GetMakeNames)comboCar.Items.CurrentItem;
//var selectedMake = selectedCarMake.make;
var selectedMake = (GetMakeNames)comboCar.SelectedValue;
eProfile.SetValue(Constants.VehicleSettings,
Constants.CarMakeId, selectedMake.id);
eProfile.SetValue(Constants.VehicleSettings,
Constants.CarMakeName, selectedMake.make);
var selectedCarModel =
(GetModelNames)comboCarModel.SelectedValue;
eProfile.SetValue(Constants.VehicleSettings,
Constants.CarModelId, selectedCarModel.id);
eProfile.SetValue(Constants.VehicleSettings,
Constants.CarModelName, selectedCarModel.model);
var selectedWheelDrive =
(WheelDrive)comboWheelDrive.SelectedValue;
eProfile.SetValue(Constants.VehicleSettings,
Constants.CarWheelId, selectedWheelDrive?.Id);
eProfile.SetValue(Constants.VehicleSettings,
Constants.CarWheelName, selectedWheelDrive?.Name);
}
catch (Exception ex)
{
//Stop the profile await controller if this is still visible
if (profileController != null)
{
await profileController.CloseAsync();
profileController = null;
}
}
}
if ((openDialog.ShowDialog() == true))
{
eProfile.Name = openDialog.FileName;
profileController.Minimum = 0;
profileController.Maximum = 100;
try
{
isFetchingProfile = true;
int ver = eProfile.GetValue("CAN_Master_Profile", "GUI_VER", -
1);
var firmware = eProfile.GetValue("CAN_Master_Profile",
"FIRMWARE");
var powerToggleBtn =
Convert_ObjtoByte(eProfile.GetValue("General_Settings", "Can_0_OutputPower"));
var can0PowerDownCheck =
Convert_ObjtoByte(eProfile.GetValue("General_Settings", "Can_0_AutoPowerDown"));
var can0PowerTimer =
Convert_ObjtoByte(eProfile.GetValue("General_Settings",
"Can_0_AutoPowerDown_Timer"));
var can0WakeUpDRB =
Convert_ObjtoByte(eProfile.GetValue("General_Settings", "Can_0_WakeUp_DRB"));
var can0WakeUpDRBonRegMsg =
Convert_ObjtoByte(eProfile.GetValue("General_Settings", "Can_0_WakeUp_DRB_onMsg"));
var can1AcceptSleep =
Convert_ObjtoByte(eProfile.GetValue("General_Settings",
"Can_1_Accept_Sleep_Call"));
var can1AcceptWakeUp =
Convert_ObjtoByte(eProfile.GetValue("General_Settings",
"Can_1_Accept_WakeUp_Call"));
var can1SendSleep =
Convert_ObjtoByte(eProfile.GetValue("General_Settings", "Can_1_Send_Sleep_Call"));
cmbBaudCAN0.SelectedIndex = canBaud0;
cmbBaudCAN1.SelectedIndex = canBaud1;
tglEnCanvPwr.IsChecked = powerToggleBtn == 1;
cbCMCanvPwrDown.IsChecked = can0PowerDownCheck == 1;
nudPwrInactTimer.Value = cbCMCanvPwrDown.IsChecked == true ?
can0PowerTimer : 0;
cbCMCanvWakeupDRB.IsChecked = can0WakeUpDRB == 1;
cbCMCanvWakeupOnRegMsg.IsChecked = can0WakeUpDRBonRegMsg == 1;
cbDRBAcceptSleepReq.IsChecked = can1AcceptSleep == 1;
cbDRBAcceptWakepReq.IsChecked = can1AcceptWakeUp == 1;
cbDRBSendSleepReq.IsChecked = can1SendSleep == 1;
int tabIndex = 0;
var rbPref = "radBts";
var rbCMPref = "radCMBit";
var sepratorKey = "B";
var sepratorKeyIgnore = "I";
if (isAlreadyExist)
{
result = await MetroMain.ShowMessageAsync("Do you want to
fetch profile?", "It is going to be reset",
MessageDialogStyle.AffirmativeAndNegative, settings: dialogSetting);
}
if (result == MessageDialogResult.Affirmative || !
isAlreadyExist)
{
await Task.Delay(100);
profileController.SetProgress(10);
#region BTS0
CANBUS_MSG_SOURCE[0] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Source"));
CANBUS_MSG_IDS[0] =
Convert_ObjtoUInt32(eProfile.GetValue("BTS0", "Message_ID"));
BTS0_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_0_Mask"));
BTS0_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_1_Mask"));
BTS0_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_2_Mask"));
BTS0_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_3_Mask"));
BTS0_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_4_Mask"));
BTS0_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_5_Mask"));
BTS0_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_6_Mask"));
BTS0_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_7_Mask"));
BTS0_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_0_Trigger"));
BTS0_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_1_Trigger"));
BTS0_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_2_Trigger"));
BTS0_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_3_Trigger"));
BTS0_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_4_Trigger"));
BTS0_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_5_Trigger"));
BTS0_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_6_Trigger"));
BTS0_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("BTS0", "Byte_7_Trigger"));
#region BTS1
tabIndex = 1;
CANBUS_MSG_SOURCE[1] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Source"));
CANBUS_MSG_IDS[1] =
Convert_ObjtoUInt32(eProfile.GetValue("BTS1", "Message_ID"));
BTS1_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_0_Mask"));
BTS1_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_1_Mask"));
BTS1_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_2_Mask"));
BTS1_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_3_Mask"));
BTS1_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_4_Mask"));
BTS1_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_5_Mask"));
BTS1_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_6_Mask"));
BTS1_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_7_Mask"));
BTS1_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_0_Trigger"));
BTS1_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_1_Trigger"));
BTS1_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_2_Trigger"));
BTS1_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_3_Trigger"));
BTS1_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_4_Trigger"));
BTS1_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_5_Trigger"));
BTS1_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_6_Trigger"));
BTS1_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("BTS1", "Byte_7_Trigger"));
#region CM Position 1
tabIndex = 0;
await Task.Delay(100);
profileController.SetProgress(50);
#endregion
#region CM Position 2
tabIndex = 1;
CANBUS_MSG_SOURCE[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Source"));
CANBUS_MSG_IDS[3] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_2", "Message_ID"));
CMBIT1_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_0_Mask"));
CMBIT1_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_1_Mask"));
CMBIT1_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_2_Mask"));
CMBIT1_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_3_Mask"));
CMBIT1_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_4_Mask"));
CMBIT1_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_5_Mask"));
CMBIT1_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_6_Mask"));
CMBIT1_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_7_Mask"));
CMBIT1_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_0_Trigger"));
CMBIT1_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_1_Trigger"));
CMBIT1_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_2_Trigger"));
CMBIT1_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_3_Trigger"));
CMBIT1_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_4_Trigger"));
CMBIT1_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_5_Trigger"));
CMBIT1_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_6_Trigger"));
CMBIT1_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_2", "Byte_7_Trigger"));
#endregion
await Task.Delay(100);
profileController.SetProgress(30);
#region CM Position 3
tabIndex = 2;
CANBUS_MSG_SOURCE[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Source"));
CANBUS_MSG_IDS[4] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_3", "Message_ID"));
CMBIT2_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_0_Mask"));
CMBIT2_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_1_Mask"));
CMBIT2_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_2_Mask"));
CMBIT2_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_3_Mask"));
CMBIT2_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_4_Mask"));
CMBIT2_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_5_Mask"));
CMBIT2_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_6_Mask"));
CMBIT2_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_7_Mask"));
CMBIT2_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_0_Trigger"));
CMBIT2_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_1_Trigger"));
CMBIT2_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_2_Trigger"));
CMBIT2_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_3_Trigger"));
CMBIT2_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_4_Trigger"));
CMBIT2_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_5_Trigger"));
CMBIT2_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_6_Trigger"));
CMBIT2_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_3", "Byte_7_Trigger"));
#endregion
#region CM Position 4
tabIndex = 3;
CANBUS_MSG_SOURCE[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Source"));
CANBUS_MSG_IDS[5] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_4", "Message_ID"));
CMBIT3_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_0_Mask"));
CMBIT3_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_1_Mask"));
CMBIT3_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_2_Mask"));
CMBIT3_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_3_Mask"));
CMBIT3_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_4_Mask"));
CMBIT3_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_5_Mask"));
CMBIT3_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_6_Mask"));
CMBIT3_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_7_Mask"));
CMBIT3_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_0_Trigger"));
CMBIT3_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_1_Trigger"));
CMBIT3_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_2_Trigger"));
CMBIT3_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_3_Trigger"));
CMBIT3_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_4_Trigger"));
CMBIT3_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_5_Trigger"));
CMBIT3_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_6_Trigger"));
CMBIT3_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_4", "Byte_7_Trigger"));
#endregion
#region CM Position 5
tabIndex = 4;
CANBUS_MSG_SOURCE[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Source"));
CANBUS_MSG_IDS[6] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_5", "Message_ID"));
CMBIT4_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_0_Mask"));
CMBIT4_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_1_Mask"));
CMBIT4_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_2_Mask"));
CMBIT4_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_3_Mask"));
CMBIT4_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_4_Mask"));
CMBIT4_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_5_Mask"));
CMBIT4_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_6_Mask"));
CMBIT4_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_7_Mask"));
CMBIT4_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_0_Trigger"));
CMBIT4_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_1_Trigger"));
CMBIT4_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_2_Trigger"));
CMBIT4_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_3_Trigger"));
CMBIT4_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_4_Trigger"));
CMBIT4_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_5_Trigger"));
CMBIT4_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_6_Trigger"));
CMBIT4_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_5", "Byte_7_Trigger"));
#endregion
#region CM Position 6
tabIndex = 5;
CANBUS_MSG_SOURCE[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Source"));
CANBUS_MSG_IDS[7] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_6", "Message_ID"));
CMBIT5_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_0_Mask"));
CMBIT5_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_1_Mask"));
CMBIT5_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_2_Mask"));
CMBIT5_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_3_Mask"));
CMBIT5_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_4_Mask"));
CMBIT5_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_5_Mask"));
CMBIT5_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_6_Mask"));
CMBIT5_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_7_Mask"));
CMBIT5_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_0_Trigger"));
CMBIT5_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_1_Trigger"));
CMBIT5_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_2_Trigger"));
CMBIT5_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_3_Trigger"));
CMBIT5_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_4_Trigger"));
CMBIT5_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_5_Trigger"));
CMBIT5_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_6_Trigger"));
CMBIT5_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_6", "Byte_7_Trigger"));
#endregion
await Task.Delay(100);
profileController.SetProgress(50);
#region CM Position 7
tabIndex = 6;
CANBUS_MSG_SOURCE[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Source"));
CANBUS_MSG_IDS[8] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_7", "Message_ID"));
CMBIT6_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_0_Mask"));
CMBIT6_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_1_Mask"));
CMBIT6_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_2_Mask"));
CMBIT6_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_3_Mask"));
CMBIT6_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_4_Mask"));
CMBIT6_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_5_Mask"));
CMBIT6_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_6_Mask"));
CMBIT6_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_7_Mask"));
CMBIT6_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_0_Trigger"));
CMBIT6_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_1_Trigger"));
CMBIT6_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_2_Trigger"));
CMBIT6_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_3_Trigger"));
CMBIT6_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_4_Trigger"));
CMBIT6_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_5_Trigger"));
CMBIT6_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_6_Trigger"));
CMBIT6_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_7", "Byte_7_Trigger"));
#endregion
#region CM Position 8
tabIndex = 7;
#endregion
#region CM Position 9
tabIndex = 8;
CANBUS_MSG_SOURCE[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Source"));
CANBUS_MSG_IDS[10] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_9", "Message_ID"));
CMBIT8_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_0_Mask"));
CMBIT8_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_1_Mask"));
CMBIT8_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_2_Mask"));
CMBIT8_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_3_Mask"));
CMBIT8_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_4_Mask"));
CMBIT8_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_5_Mask"));
CMBIT8_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_6_Mask"));
CMBIT8_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_7_Mask"));
CMBIT8_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_0_Trigger"));
CMBIT8_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_1_Trigger"));
CMBIT8_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_2_Trigger"));
CMBIT8_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_3_Trigger"));
CMBIT8_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_4_Trigger"));
CMBIT8_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_5_Trigger"));
CMBIT8_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_6_Trigger"));
CMBIT8_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_9", "Byte_7_Trigger"));
#endregion
#region CM Position 10
tabIndex = 9;
CANBUS_MSG_SOURCE[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Source"));
CANBUS_MSG_IDS[11] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_10", "Message_ID"));
CMBIT9_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_0_Mask"));
CMBIT9_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_1_Mask"));
CMBIT9_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_2_Mask"));
CMBIT9_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_3_Mask"));
CMBIT9_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_4_Mask"));
CMBIT9_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_5_Mask"));
CMBIT9_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_6_Mask"));
CMBIT9_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_7_Mask"));
CMBIT9_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_0_Trigger"));
CMBIT9_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_1_Trigger"));
CMBIT9_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_2_Trigger"));
CMBIT9_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_3_Trigger"));
CMBIT9_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_4_Trigger"));
CMBIT9_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_5_Trigger"));
CMBIT9_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_6_Trigger"));
CMBIT9_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_10", "Byte_7_Trigger"));
#endregion
#region CM Position 11
tabIndex = 10;
CANBUS_MSG_SOURCE[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Source"));
CANBUS_MSG_IDS[12] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_11", "Message_ID"));
CMBIT10_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_0_Mask"));
CMBIT10_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_1_Mask"));
CMBIT10_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_2_Mask"));
CMBIT10_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_3_Mask"));
CMBIT10_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_4_Mask"));
CMBIT10_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_5_Mask"));
CMBIT10_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_6_Mask"));
CMBIT10_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_7_Mask"));
CMBIT10_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_0_Trigger"));
CMBIT10_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_1_Trigger"));
CMBIT10_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_2_Trigger"));
CMBIT10_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_3_Trigger"));
CMBIT10_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_4_Trigger"));
CMBIT10_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_5_Trigger"));
CMBIT10_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_6_Trigger"));
CMBIT10_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_11", "Byte_7_Trigger"));
#endregion
await Task.Delay(100);
profileController.SetProgress(70);
#region CM Position 12
tabIndex = 11;
CANBUS_MSG_SOURCE[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Source"));
CANBUS_MSG_IDS[13] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_12", "Message_ID"));
CMBIT11_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_0_Mask"));
CMBIT11_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_1_Mask"));
CMBIT11_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_2_Mask"));
CMBIT11_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_3_Mask"));
CMBIT11_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_4_Mask"));
CMBIT11_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_5_Mask"));
CMBIT11_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_6_Mask"));
CMBIT11_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_7_Mask"));
CMBIT11_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_0_Trigger"));
CMBIT11_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_1_Trigger"));
CMBIT11_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_2_Trigger"));
CMBIT11_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_3_Trigger"));
CMBIT11_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_4_Trigger"));
CMBIT11_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_5_Trigger"));
CMBIT11_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_6_Trigger"));
CMBIT11_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_12", "Byte_7_Trigger"));
#region CM Position 13
tabIndex = 12;
CANBUS_MSG_SOURCE[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Source"));
CANBUS_MSG_IDS[14] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_13", "Message_ID"));
CMBIT12_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_0_Mask"));
CMBIT12_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_1_Mask"));
CMBIT12_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_2_Mask"));
CMBIT12_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_3_Mask"));
CMBIT12_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_4_Mask"));
CMBIT12_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_5_Mask"));
CMBIT12_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_6_Mask"));
CMBIT12_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_7_Mask"));
CMBIT12_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_0_Trigger"));
CMBIT12_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_1_Trigger"));
CMBIT12_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_2_Trigger"));
CMBIT12_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_3_Trigger"));
CMBIT12_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_4_Trigger"));
CMBIT12_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_5_Trigger"));
CMBIT12_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_6_Trigger"));
CMBIT12_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_13", "Byte_7_Trigger"));
#endregion
#region CM Position 14
tabIndex = 13;
CANBUS_MSG_SOURCE[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Source"));
CANBUS_MSG_IDS[15] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_14", "Message_ID"));
CMBIT13_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_0_Mask"));
CMBIT13_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_1_Mask"));
CMBIT13_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_2_Mask"));
CMBIT13_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_3_Mask"));
CMBIT13_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_4_Mask"));
CMBIT13_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_5_Mask"));
CMBIT13_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_6_Mask"));
CMBIT13_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_7_Mask"));
CMBIT13_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_0_Trigger"));
CMBIT13_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_1_Trigger"));
CMBIT13_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_2_Trigger"));
CMBIT13_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_3_Trigger"));
CMBIT13_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_4_Trigger"));
CMBIT13_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_5_Trigger"));
CMBIT13_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_6_Trigger"));
CMBIT13_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_14", "Byte_7_Trigger"));
#endregion
#region CM Position 15
tabIndex = 14;
CANBUS_MSG_SOURCE[16] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Source"));
CANBUS_MSG_IDS[16] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_15", "Message_ID"));
CMBIT14_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_0_Mask"));
CMBIT14_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_1_Mask"));
CMBIT14_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_2_Mask"));
CMBIT14_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_3_Mask"));
CMBIT14_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_4_Mask"));
CMBIT14_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_5_Mask"));
CMBIT14_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_6_Mask"));
CMBIT14_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_7_Mask"));
CMBIT14_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_0_Trigger"));
CMBIT14_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_1_Trigger"));
CMBIT14_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_2_Trigger"));
CMBIT14_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_3_Trigger"));
CMBIT14_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_4_Trigger"));
CMBIT14_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_5_Trigger"));
CMBIT14_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_6_Trigger"));
CMBIT14_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_15", "Byte_7_Trigger"));
#endregion
#region CM Position 16
tabIndex = 15;
CANBUS_MSG_SOURCE[17] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Source"));
CANBUS_MSG_IDS[17] =
Convert_ObjtoUInt32(eProfile.GetValue("CM_Position_16", "Message_ID"));
CMBIT15_DATA_BYTES[0] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_0_Mask"));
CMBIT15_DATA_BYTES[1] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_1_Mask"));
CMBIT15_DATA_BYTES[2] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_2_Mask"));
CMBIT15_DATA_BYTES[3] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_3_Mask"));
CMBIT15_DATA_BYTES[4] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_4_Mask"));
CMBIT15_DATA_BYTES[5] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_5_Mask"));
CMBIT15_DATA_BYTES[6] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_6_Mask"));
CMBIT15_DATA_BYTES[7] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_7_Mask"));
CMBIT15_DATA_BYTES[8] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_0_Trigger"));
CMBIT15_DATA_BYTES[9] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_1_Trigger"));
CMBIT15_DATA_BYTES[10] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_2_Trigger"));
CMBIT15_DATA_BYTES[11] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_3_Trigger"));
CMBIT15_DATA_BYTES[12] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_4_Trigger"));
CMBIT15_DATA_BYTES[13] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_5_Trigger"));
CMBIT15_DATA_BYTES[14] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_6_Trigger"));
CMBIT15_DATA_BYTES[15] =
Convert_ObjtoByte(eProfile.GetValue("CM_Position_16", "Byte_7_Trigger"));
#endregion
customIndex++;
}
object carModelName =
eProfile.GetValue(Constants.VehicleSettings, Constants.CarModelName);
int carModelId =
Convert.ToInt32(eProfile.GetValue(Constants.VehicleSettings,
Constants.CarModelId));
CarModel carModel = new CarModel
{
id = carModelId,
model = carModelName.ToString(),
};
int carYear =
Convert.ToInt32(eProfile.GetValue(Constants.VehicleSettings, Constants.CarYear));
object carEngineTypeName =
eProfile.GetValue(Constants.VehicleSettings, Constants.CarEngineTypeName);
int carEngineTypeId =
Convert.ToInt32(eProfile.GetValue(Constants.VehicleSettings,
Constants.CarEngineTypeId));
EngineType engineType = null;
if (carEngineTypeName != null)
{
engineType.Id = carEngineTypeId;
engineType.Name = carEngineTypeName.ToString();
}
object carGearBoxName =
eProfile.GetValue(Constants.VehicleSettings, Constants.CarGearBoxName);
int carGearBoxId =
Convert.ToInt32(eProfile.GetValue(Constants.VehicleSettings,
Constants.CarGearBoxId));
GearBox gearBox = null;
if (carGearBoxName != null)
{
gearBox.Id = carGearBoxId;
gearBox.Name = carGearBoxName.ToString();
}
object carWheelName =
eProfile.GetValue(Constants.VehicleSettings, Constants.CarWheelName);
int carWheelId =
Convert.ToInt32(eProfile.GetValue(Constants.VehicleSettings,
Constants.CarWheelId));
WheelDrive wheelDrive = null;
if (carWheelName != null)
{
wheelDrive.Id = carWheelId;
wheelDrive.Name = carWheelName.ToString();
};
var carRegistraion =
eProfile.GetValue(Constants.VehicleSettings, Constants.CarRegistrationNumber);
isFetchingProfile = false;
}
catch (Exception ex)
{
//Stop the profile await controller if this is still visible
if (profileController != null)
{
await profileController.CloseAsync();
profileController = null;
}
[JsonProperty("hostname")]
public string Hostname { get; set; }
[JsonProperty("city")]
public string City { get; set; }
[JsonProperty("region")]
public string Region { get; set; }
[JsonProperty("country")]
public string Country { get; set; }
[JsonProperty("loc")]
public string Loc { get; set; }
[JsonProperty("org")]
public string Org { get; set; }
[JsonProperty("postal")]
public string Postal { get; set; }
}
return ipInfo.Ip;
}
//source value
var source = CANBUS_MSG_SOURCE[Convert.ToInt32(tabIndex)];
//message Id
var msgId = CANBUS_MSG_IDS[Convert.ToInt32(tabIndex)];
if (source == 0)
{
signalReport.Close();
await this.ShowMessageAsync("CAN Source!", "CAN Source can not
be NONE", MessageDialogStyle.Affirmative);
}
else if (msgId == 0)
{
signalReport.Close();
await this.ShowMessageAsync("Message ID!", "Message ID can not
be Zero.", MessageDialogStyle.Affirmative);
}
else if (!IsInternetAvailable())
{
signalReport.Close();
await this.ShowMessageAsync("Internet Disconnected", "Internet
is not available. Unable to call the API.", MessageDialogStyle.Affirmative);
}
else if (carData == null || comboCar.SelectedIndex == -1 ||
comboCarModel.SelectedIndex == -1)
{
signalReport.Close();
await this.ShowMessageAsync("Vehicle!!!", "Please Select
Vehicle First", MessageDialogStyle.Affirmative);
//tabConMain.SelectedIndex = 2;
}
else
{
try
{
string baseURL =
ConfigurationManager.AppSettings.Get("BaseURL").ToString();
//string carMakeNamesURL =
ConfigurationManager.AppSettings.Get("CarMakeNamesURL").ToString();
string signalTypesURL =
ConfigurationManager.AppSettings.Get("SignalTypesURL").ToString();
//signal Type
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12;
httpClient.DefaultRequestHeaders.Authorization = new
AuthenticationHeaderValue("Bearer", jwtToken);
var signalResponse = await
httpClient.GetAsync($"{signalTypesURL}{enAccessMode.Export}");
if (signalResponse.IsSuccessStatusCode)
{
//var message = await
response.Content.ReadAsStringAsync();
//var carMakesNameList =
JsonConvert.DeserializeObject<Car>(message);
//var carMakeCollection = new
ObservableCollection<GetMakeNames>(carMakesNameList.getMakeNames);
//signalReport.cmbCar.ItemsSource = carMakeCollection;
////message Id
//var msgId =
CANBUS_MSG_IDS[Convert.ToInt32(tabIndex)];
if (tabIndex == "1")
{
tabName = "BTS 1";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = BTS1_DATA_BYTES[i];
var rbName = $"{rbBTSPref}{tabIndex}
{sepratorKey}{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbBTSStandardName = $"{rbBTSPref}1{rbPost}
{sepratorS}";
rbBTSStandard =
(RadioButton)this.FindName(rbBTSStandardName);
signalReport.Format.Text = (rbBTSStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[1];
}
if (tabIndex == "2")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 0";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT0_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}0{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[2];
}
if (tabIndex == "3")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 1";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT1_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}1{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[3];
}
if (tabIndex == "4")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 2";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT2_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}2{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[4];
}
if (tabIndex == "5")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 3";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT3_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}3{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[5];
}
if (tabIndex == "6")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 4";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT4_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}4{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[6];
}
if (tabIndex == "7")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 5";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT5_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}5{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[7];
}
if (tabIndex == "8")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 6";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT6_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}6{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[8];
}
if (tabIndex == "9")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 7";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT7_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}7{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[9];
}
if (tabIndex == "10")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 8";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT8_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}8{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[10];
}
if (tabIndex == "11")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 9";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT9_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}9{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[11];
}
if (tabIndex == "12")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 10";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT10_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}10{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[12];
}
if (tabIndex == "13")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 11";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT11_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}11{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[13];
}
if (tabIndex == "14")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 12";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT12_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}12{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[14];
}
if (tabIndex == "15")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 13";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT13_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}13{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[15];
}
if (tabIndex == "16")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 14";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT14_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}14{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[16];
}
if (tabIndex == "17")
{
var index = (Convert.ToInt32(tabIndex) -
2).ToString();
tabName = "CAN 15";
var j = 0;
for (int i = 0; i < 24; i++)
{
if (i == 8 || i == 16) j = 0;
byteValue = CMBIT15_DATA_BYTES[i];
var rbName = $"{rbCANPref}{index}{sepratorKey}
{j}{sepratorKeyIgnore}";
var rbIgnore =
(RadioButton)this.FindName(rbName);
var isIgnored = rbIgnore.IsChecked ?? true;
bytesDict.Add($"byte{i}", (!isIgnored ?
byteValue : (byte)0));
j++;
}
rbCANStandardName = $"{rbCANPref}15{rbPost}
{sepratorS}";
rbCANStandard =
(RadioButton)this.FindName(rbCANStandardName);
signalReport.Format.Text = (rbCANStandard.IsChecked
== true) ? "STD" : "EXT";
sourceValue = CANBUS_MSG_SOURCE[17];
}
//var a1 = bytesDict.ElementAt(16).Value;
//var aa1 = CMB_OPERATION_LIST[a1];
signalReport.Mask0.Text =
bytesDict.ElementAt(0).Value.ToString();
signalReport.Mask1.Text =
bytesDict.ElementAt(1).Value.ToString();
signalReport.Mask2.Text =
bytesDict.ElementAt(2).Value.ToString();
signalReport.Mask3.Text =
bytesDict.ElementAt(3).Value.ToString();
signalReport.Mask4.Text =
bytesDict.ElementAt(4).Value.ToString();
signalReport.Mask5.Text =
bytesDict.ElementAt(5).Value.ToString();
signalReport.Mask6.Text =
bytesDict.ElementAt(6).Value.ToString();
signalReport.Mask7.Text =
bytesDict.ElementAt(7).Value.ToString();
signalReport.Trigger0.Text =
bytesDict.ElementAt(8).Value.ToString();
signalReport.Trigger1.Text =
bytesDict.ElementAt(9).Value.ToString();
signalReport.Trigger2.Text =
bytesDict.ElementAt(10).Value.ToString();
signalReport.Trigger3.Text =
bytesDict.ElementAt(11).Value.ToString();
signalReport.Trigger4.Text =
bytesDict.ElementAt(12).Value.ToString();
signalReport.Trigger5.Text =
bytesDict.ElementAt(13).Value.ToString();
signalReport.Trigger6.Text =
bytesDict.ElementAt(14).Value.ToString();
signalReport.Trigger7.Text =
bytesDict.ElementAt(15).Value.ToString();
signalReport.Logic0.Text =
bytesDict.ElementAt(16).Value.ToString();
signalReport.Logic1.Text =
bytesDict.ElementAt(17).Value.ToString();
signalReport.Logic2.Text =
bytesDict.ElementAt(18).Value.ToString();
signalReport.Logic3.Text =
bytesDict.ElementAt(19).Value.ToString();
signalReport.Logic4.Text =
bytesDict.ElementAt(20).Value.ToString();
signalReport.Logic5.Text =
bytesDict.ElementAt(21).Value.ToString();
signalReport.Logic6.Text =
bytesDict.ElementAt(22).Value.ToString();
signalReport.Logic7.Text =
bytesDict.ElementAt(23).Value.ToString();
signalReport.progressRing.Visibility =
Visibility.Collapsed;
signalReport.Cancel0.IsEnabled = true;
signalReport.canConnection.IsEnabled = true;
signalReport.signalDescription.IsEnabled = true;
//signalReport.Logic0.Text =
CMB_OPERATION_LIST[bytesDict.ElementAt(16).Value];
//signalReport.Logic1.Text =
CMB_OPERATION_LIST[bytesDict.ElementAt(17).Value];
//signalReport.Logic2.Text =
CMB_OPERATION_LIST[bytesDict.ElementAt(18).Value];
//signalReport.Logic3.Text =
CMB_OPERATION_LIST[bytesDict.ElementAt(19).Value];
//signalReport.Logic4.Text =
CMB_OPERATION_LIST[bytesDict.ElementAt(20).Value];
//signalReport.Logic5.Text =
CMB_OPERATION_LIST[bytesDict.ElementAt(21).Value];
//signalReport.Logic6.Text =
CMB_OPERATION_LIST[bytesDict.ElementAt(22).Value];
//signalReport.Logic7.Text =
CMB_OPERATION_LIST[bytesDict.ElementAt(23).Value];
}
}
catch (Exception)
{
signalReport.Close();
await this.ShowMessageAsync("Error", "something went wrong
while fetching deatils", MessageDialogStyle.Affirmative);
}
}
}
else
{
await this.ShowMessageAsync("Device Not Found", "Please Connect
Device First", MessageDialogStyle.Affirmative);
}
}
fetchPopup.tabIndex.Content = tabIndex;
//ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12;
//var response = await
httpClient.GetAsync($"{carMakeNamesURL}{enAccessMode.Import}");
//signal Type
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12;
httpClient.DefaultRequestHeaders.Authorization = new
AuthenticationHeaderValue("Bearer", jwtToken);
//var signalResponse = await
httpClient.GetAsync($"{signalTypesURL}{enAccessMode.Export}");
var carModel = (GetModelNames)comboCarModel.SelectedItem;
//var year = comboYear.SelectedItem.ToString();
//var signalResponse = await
httpClient.GetAsync($"{signalTypesURL}{enAccessMode.Import}/{carModel.id}/{year}");
var signalResponse = await
httpClient.GetAsync($"{signalTypesURL}{enAccessMode.Import}/{carModel.id}");
if (signalResponse.IsSuccessStatusCode)
{
//var message = await
response.Content.ReadAsStringAsync();
//var carMakesNameList =
JsonConvert.DeserializeObject<Car>(message);
//var carMakeCollection = new
ObservableCollection<GetMakeNames>(carMakesNameList.getMakeNames);
//fetchPopup.cmbCar.ItemsSource = carMakeCollection;
}
cmbSignal.ItemsSource = null;
}
//cmbSignalType0.IsEditable = true;
//cmbSignalType0.IsReadOnly = true;
//cmbSignalType0.Text = "-- Select --";
if (carData == null)
{
//cmbSignalType0.Text = "Please Select Vehicle";
return;
//await this.ShowMessageAsync("Vehicle!!!", "Please Select Vehicle
First", MessageDialogStyle.Affirmative);
}
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
httpClient.DefaultRequestHeaders.Authorization = new
AuthenticationHeaderValue("Bearer", jwtToken);
var response = await httpClient.PostAsync(getSignalReportURL,
httpContent);
if (response.IsSuccessStatusCode)
{
var message = await response.Content.ReadAsStringAsync();
var fileDetailResponse =
JsonConvert.DeserializeObject<FetchSignalReponse>(message);
//totalRecords = fileDetailResponse.totalRecords;
//int maxPage = (int)Math.Ceiling((double)totalRecords /
signalsPerPage);
//maxPages = maxPage;
var i = 1;
var signalFilters = new List<SignalFilter>();
// Sort Signal Reports by Signal Type
//fileDetailResponse.SignalReports.Sort((a, b) =>
string.Compare(a.SignalTypeName, b.SignalTypeName));
fileDetailResponse.SignalReports =
fileDetailResponse.SignalReports.OrderBy(o => o.SignalTypeId).ToList();
if (item.SignalTypeName != currentSignalType)
{
currentSignalType = item.SignalTypeName;
count = 1;
}
SignalFilter signalFilter = new SignalFilter();
signalFilter.Id = item.Id;
signalFilter.FileName = item.FileName;
signalFilter.FileURL = item.FileURL;
signalFilter.BaudRate = item.BaudRate;
signalFilter.isVerified = item.IsVerified;
signalFilter.CANConnection = item.CANConnection;
signalFilter.Year = item.Year;
signalFilter.Description = item.Description;
signalFilter.LikeStatus = item.LikeStatus;
//signalFilter.SignalTypeName = item.SignalTypeName;
signalFilter.SignalTypeName = count != 1 ?
$"{item.SignalTypeName} ({count})" : item.SignalTypeName;
count++;
//this.signalFilterCollection.Add(signalFilter);
signalFilters.Add(signalFilter);
i++;
}
var signalTypeCollection = new
ObservableCollection<SignalFilter>(signalFilters);
//var signalTypeCollection = new
ObservableCollection<SignalFilter>(signalFilters).Reverse();
//cmbSignalType0.ItemsSource = signalTypeCollection;
for (int j = 0; j < totalCount; j++)
{
var cmbSignalType = "cmbSignalType";
var cmbSignal = (ComboBox)this.FindName($"{cmbSignalType}{j}");
cmbSignal.ItemsSource = signalTypeCollection; ;
}
}
}
//Checking
var showHexBts = "cbShowHex_BTS";
var showHexCMBit = "cbShowHex_CMBit";
var showDecBts = "cbShowDec_BTS";
var showDecCMBit = "cbShowDec_CMBit";
var signalReportBtn = "btnSignalReport";
var fetchSignalBtn = "btnFetchSignal";
var clearAllBtn = "btnClear";
var seprator = "seprator";
var thumbLike = "thumbLike";
//btnClear0
CheckBox showHex = idx < 2 ?
(CheckBox)FindName($"{showHexBts}{idx}") : (CheckBox)FindName($"{showHexCMBit}{idx
- 2}");
showHex.Visibility = Visibility.Visible;
Button signalReportBtnHide =
(Button)FindName($"{signalReportBtn}{idx}");
signalReportBtnHide.Visibility = Visibility.Visible;
//Button fetchSignalBtnHide =
(Button)FindName($"{fetchSignalBtn}{idx}");
//fetchSignalBtnHide.Visibility = Visibility.Visible;
if (bit_isFetched[idx])
{
undoButtonPressedBeforeExport = true;
if (tglDataSync.IsChecked == true)
{
if(dataSyncTimer != null)
{
tglDataSync.IsChecked = false;
isExportSettingsPressed = false;
}
}
foreach (var kvp in idToBufferPosition)
{
// Try to parse the string value to an integer
if (int.TryParse(kvp.Value, out int parsedValue))
{
// If parsing is successful, store the integer
value in _selectedSignalIds
_selectedSignalIds[kvp.Key] = parsedValue;
}
else
{
_selectedSignalIds[kvp.Key] = 0;
}
}
if (idx == 0)
{
CANBUS_MSG_IDS[idx] = 0;
CANBUS_MSG_SOURCE[idx] = 0;
BTS0_isFetched = false;
}
if (idx == 1)
{
CANBUS_MSG_IDS[idx] = 0;
CANBUS_MSG_SOURCE[idx] = 0;
BTS1_isFetched = false;
}
if (idx == 2)
{
CANBUS_MSG_IDS[idx] = 0;
CANBUS_MSG_SOURCE[idx] = 0;
CM0_isFetched = false;
}
if (idx == 3)
{
//if (_selectedSignalIds.ContainsKey(idx))
//{
// _selectedSignalIds.Remove(idx);
//}
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT1_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT1_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT1_DATA_BYTES[i + 8 + 8] = (byte)0;
CANBUS_MSG_IDS[idx] = 0;
CANBUS_MSG_SOURCE[idx] = 0;
CM1_isFetched = false;
}
if (idx == 4)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT2_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT2_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT2_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM2_isFetched = false;
}
if (idx == 5)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT3_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT3_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT3_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM3_isFetched = false;
}
if (idx == 6)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT4_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT4_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT4_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM4_isFetched = false;
}
if (idx == 7)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT5_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT5_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT5_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM5_isFetched = false;
}
if (idx == 8)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT6_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT6_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT6_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM6_isFetched = false;
}
if (idx == 9)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT7_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT7_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT7_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM7_isFetched = false;
}
if (idx == 10)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT8_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT8_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT8_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM8_isFetched = false;
}
if (idx == 11)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT9_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT9_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT9_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM9_isFetched = false;
}
if (idx == 12)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT10_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT10_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT10_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM10_isFetched = false;
}
if (idx == 13)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT11_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT11_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT11_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM11_isFetched = false;
}
if (idx == 14)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT12_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT12_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT12_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM12_isFetched = false;
}
if (idx == 15)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT13_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT13_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT13_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM13_isFetched = false;
}
if (idx == 16)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT14_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT14_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT14_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM14_isFetched = false;
}
if (idx == 17)
{
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT15_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT15_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT15_DATA_BYTES[i + 8 + 8] = (byte)0;
}
CANBUS_MSG_SOURCE[idx] = 0;
CANBUS_MSG_IDS[idx] = 0;
CM15_isFetched = false;
}
}
//Separator sepratorHide = (Separator)FindName($"{seprator}
{idx}");
//sepratorHide.Visibility = Visibility.Visible;
//cmbSignalType0.IsEditable = true;
//cmbSignalType0.IsReadOnly = true;
//cmbSignalType0.SelectedItem = null;
//cmbSignalType0.Text = "-- Select --";
}
catch { MessageBox.Show("Could not remove the fetched signal from
the list", "Undo Failed", MessageBoxButton.OK, MessageBoxImage.Error); }
#endregion
}
catch (Exception ex)
{
ExceptionHandler.DebugException(ex);
}
}
if (border != null)
{
DataGridItem item = (DataGridItem)border.DataContext;
await this.SelectBitsForExport(item, border.Tag.ToString(),
selectAllBytes);
}
}
catch (Exception e)
{
ExceptionHandler.DebugException(e);
}
}
if (txtBlock != null)
{
DataGridItem item = (DataGridItem)txtBlock.DataContext;
await this.SelectBitsForExport(item,
txtBlock.Tag.ToString(), selectAllBytes: true);
}
}
}
catch (Exception e)
{
ExceptionHandler.DebugException(e);
}
}
exportedItem.HexCanId = newCanId;
exportedItem.SelectedItems.Clear();
}));
}
/// <summary>
/// Manage and handle filtering data including manual filteration and auto
filteration.
/// </summary>
/// <param name="dataGridItem"></param>
/// <param name="filterValue"></param>
/// <param name="isChecked"></param>
/// <param name="removeFromAutoHide"></param>
public void HandleFilterChanges(DataGridItem dataGridItem, FilterValue
filterValue, bool isChecked, bool removeFromAutoHide = false, bool forceHide =
false)
{
var assd = rowIndex;
var id = dataGridItem.ID;
var roll = dataGridItem.RollNo;
dataGridItem.HideItem = isChecked ? false : true;
dataGridItem.ForceHide = forceHide ? dataGridItem.HideItem : forceHide;
filterValue.isCheck = isChecked;
if (removeFromAutoHide)
{
removedDataGridItems.Remove(dataGridItem);
}
}
comboCar.IsEditable = true;
comboCar.IsReadOnly = true;
comboCar.Text = "-- Select --";
comboCarModel.IsEditable = true;
comboCarModel.IsReadOnly = true;
comboCarModel.Text = "-- Select --";
string baseURL =
ConfigurationManager.AppSettings.Get("BaseURL").ToString();
string carMakeNamesURL =
ConfigurationManager.AppSettings.Get("CarMakeNamesURL").ToString();
var httpClient = new HttpClient()
{
BaseAddress = new Uri(baseURL)
};
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12;
httpClient.DefaultRequestHeaders.Authorization = new
AuthenticationHeaderValue("Bearer", jwtToken);
var response = await httpClient.GetAsync($"{carMakeNamesURL}
{enAccessMode.Export}");
if (response.IsSuccessStatusCode)
{
var message = await response.Content.ReadAsStringAsync();
var carMakesNameList =
JsonConvert.DeserializeObject<Car>(message);
carMakeCollection = new
ObservableCollection<GetMakeNames>(carMakesNameList.getMakeNames);
this.comboCar.ItemsSource = carMakeCollection;
}
}
catch (Exception)
{
await this.ShowMessageAsync("Error", "something went wrong
while fetching details", MessageDialogStyle.Affirmative);
}
}
if (extraString != null)
{
int makeId = Convert.ToInt32(carMakeIdString);
modelId = Convert.ToInt32(carModelString);
int engineId = int.TryParse(engineIdString, out var
parsedValueEngine) ? parsedValueEngine : 0;
int wheelDriveId = int.TryParse(wheelDriveIdString, out var
parsedValue) ? parsedValue : 0;
int gearBoxId = int.TryParse(gearBoxIdString, out var
parsedValueGearBox) ? parsedValueGearBox : 0;
int year = int.TryParse(yearString, out var parsedValueYear) ?
parsedValueYear : -1;
importedCarData = true;
var indexOfCarMake =
carMakeCollection.IndexOf(carMakeCollection.FirstOrDefault(item => item.id ==
makeId));
if (indexOfCarMake == -1 && !isCheckingMake)
{
await this.ShowMessageAsync("No Make Found", "Selected Vehicle
Make is Remove or Changed. Please Select again.", MessageDialogStyle.Affirmative);
comboCarModel.ItemsSource = null;
isCheckingMake = true;
isCheckingModel = true;
}
comboCar.SelectedIndex = indexOfCarMake;
//await Task.Delay(1000);
var indexOfYear = yearListSource.IndexOf(year);
comboYear.SelectedIndex = indexOfYear;
var indexOfEngineType =
EngineTypes.IndexOf(EngineTypes.FirstOrDefault(item => item.Id == engineId));
comboEngineType.SelectedIndex = indexOfEngineType;
var selectedEngineTypeData =
(EngineType)comboEngineType.SelectedValue;
var indexOfGearBox =
GearBoxes.IndexOf(GearBoxes.FirstOrDefault(item => item.Id == gearBoxId));
comboGearBox.SelectedIndex = indexOfGearBox;
var selectedGearTypeData = (GearBox)comboGearBox.SelectedItem;
return;
}
if (carData.Year != null)
{
var indexOfYear = yearListSource.IndexOf((int)carData.Year);
comboYear.SelectedIndex = indexOfYear;
}
if (carData.EngineType != null)
{
var indexOfEngineType =
EngineTypes.IndexOf(EngineTypes.FirstOrDefault(item => item.Name ==
carData.EngineType.Name));
comboEngineType.SelectedIndex = indexOfEngineType;
}
if (carData.GearBox != null)
{
var indexOfGearBox =
GearBoxes.IndexOf(GearBoxes.FirstOrDefault(item => item.Name ==
carData.GearBox.Name));
comboGearBox.SelectedIndex = indexOfGearBox;
}
if (carData.WheelDrive != null)
{
var indexOfWheelDrive =
WheelDrives.IndexOf(WheelDrives.FirstOrDefault(item => item.Name ==
carData.WheelDrive.Name));
comboWheelDrive.SelectedIndex = indexOfWheelDrive;
}
textRegistration.Text = carData.Registration;
}
}
string baseURL =
ConfigurationManager.AppSettings.Get("BaseURL").ToString();
string getCarModelURL =
ConfigurationManager.AppSettings.Get("GetCarModelURL").ToString();
if (response.IsSuccessStatusCode)
{
var message = await response.Content.ReadAsStringAsync();
var carModelNameList =
JsonConvert.DeserializeObject<Model>(message);
var carModelList = new
ObservableCollection<GetModelNames>(carModelNameList.getModelNames);
//this.comboCar.ItemsSource = carMakeCollection;
if (httpResponse.IsSuccessStatusCode)
{
return "Success";
}
else
{
var contentStream = await
httpResponse.Content.ReadAsStringAsync();
var errorResponse =
JsonConvert.DeserializeObject<HttpErrorResponse>(contentStream);
response = errorResponse.Error;
}
}
catch (Exception e)
{
ExceptionHandler.DebugException(e, "LOGOUT - API - ERROR: "
+ e.Message);
response = Constants.SOMETHING_WENT_WRONG;
}
}
}
else response = Constants.SOMETHING_WENT_WRONG;
return response;
}
if (httpResponse.IsSuccessStatusCode)
{
return "Success";
}
else
{
var contentStream = await
httpResponse.Content.ReadAsStringAsync();
var errorResponse =
JsonConvert.DeserializeObject<HttpErrorResponse>(contentStream);
response = errorResponse.Error;
}
}
catch (Exception e)
{
ExceptionHandler.DebugException(e, "CONNECTIVITY STATUS -
API - ERROR: " + e.Message);
response = Constants.SOMETHING_WENT_WRONG;
}
}
}
else response = Constants.SOMETHING_WENT_WRONG;
return response;
}
// in order to use the same object of main window, we will hide the
object here instead of close.
this.Hide();
}
if (result == MessageDialogResult.Affirmative)
{
await ResetExportItems(exportedItem.HexCanId, item.ID);
}
else return;
}
}
else exportedItem.HexCanId = item.ID;
#endregion
public bool importedCarData { get; set; }
private async void tiCarSettings_PreviewMouseDown(object sender,
MouseButtonEventArgs e)
{
}
// Helper method to check if the element or its ancestor is the TabItem.
private bool IsTabItemOrDescendant(DependencyObject target,
DependencyObject originalSource)
{
if (target == null || originalSource == null)
return false;
if (target == originalSource)
return true;
return IsTabItemOrDescendant(VisualTreeHelper.GetParent(target),
originalSource);
}
GetModelNames getModel = new GetModelNames();
private async void Combo_Car_SelectionChanged(object sender,
SelectionChangedEventArgs e)
{
try
{
var selectedItem = (GetMakeNames)comboCar.SelectedValue;
if (selectedItem != null)
{
var carModelList = new ObservableCollection<GetModelNames>();
if (IsInternetAvailable())
{
var jwtToken = _sessionUser.Token;
string baseURL =
ConfigurationManager.AppSettings.Get("BaseURL").ToString();
try
{
string getCarModelURL =
ConfigurationManager.AppSettings.Get("GetCarModelURL").ToString();
}
catch (Exception)
{
}
else
{
await this.ShowMessageAsync("Internet Disconnected",
"Internet is not available. Getting Data from local Storage. (Locally)",
MessageDialogStyle.Affirmative);
Model carModels = await
SessionHelper.CheckLocalCarModels();
if (carModels != null)
{
carModelList = new
ObservableCollection<GetModelNames>(carModels.getModelNames.Where(o => o.makeId ==
selectedItem.id));
//var carModelCollection =
allCarModelCollection.Where(o => o.makeId == selectedItem.id);
this.comboCarModel.ItemsSource = null;
this.comboCarModel.ItemsSource = carModelList;
}
}
//Getting data of Car Model with Car Session.
CarData carData = await SessionHelper.CheckLocalCarData();
if (importedCarData)
{
var sessionCarMake = carData.CarMake;
var comboCarMake = (GetMakeNames)comboCar.SelectedItem;
var indexOfModel =
carModelList.IndexOf(carModelList.FirstOrDefault(o => o.id == modelId));
//var indexOfModel =
carModelList.IndexOf(carModelList.FirstOrDefault(o => o.model ==
carData.CarModel.model));
if (indexOfModel == -1 && !isCheckingModel &&
sessionCarMake.make == comboCarMake.make)
{
await this.ShowMessageAsync("No Model Found", "Selected
Vehicle Model is Remove or Changed, Please Select again.",
MessageDialogStyle.Affirmative);
isCheckingModel = true;
}
comboCarModel.SelectedIndex = indexOfModel;
importedCarData = false;
}
else if (carData != null && importedCarData == false)
{
var sessionCarMake = carData.CarMake;
var comboCarMake = (GetMakeNames)comboCar.SelectedItem;
var indexOfModel =
carModelList.IndexOf(carModelList.FirstOrDefault(o => o.model ==
carData.CarModel.model));
if (indexOfModel == -1 && !isCheckingModel &&
sessionCarMake.make == comboCarMake.make)
{
await this.ShowMessageAsync("No Model Found", "Selected
Vehicle Model is Remove or Changed, Please Select again.",
MessageDialogStyle.Affirmative);
isCheckingModel = true;
}
comboCarModel.SelectedIndex = indexOfModel;
}
int carMakeId = 0;
var selectedCar = (GetMakeNames)comboCar.SelectedValue;
carMakeId = selectedCar?.id ?? 0;
int carModelId = 0;
var selectedModel = (GetModelNames)comboCarModel.SelectedValue;
carModelId = selectedModel?.id ?? 0;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
httpClient.DefaultRequestHeaders.Authorization = new
AuthenticationHeaderValue("Bearer", jwtToken);
var response = await httpClient.PostAsync(getSignalReportURL,
httpContent);
var signaleCollection = new ObservableCollection<CarSignals>();
if (response.IsSuccessStatusCode)
{
var message = await response.Content.ReadAsStringAsync();
var fileDetailResponse =
JsonConvert.DeserializeObject<FetchSignalReponse>(message);
totalRecords = fileDetailResponse.totalRecords;
int maxPage = (int)Math.Ceiling((double)totalRecords /
signalsPerPage);
maxPages = maxPage;
var i = 1;
foreach (var item in fileDetailResponse.SignalReports)
{
CarSignals signalFilter = new CarSignals();
signalFilter.Id = i;
signalFilter.FileName = item.FileName;
signalFilter.FileURL = item.FileURL;
signalFilter.BaudRate = item.BaudRate;
signalFilter.isVerified = item.IsVerified;
signalFilter.Status = item.IsVerified ? "Verified" : "Not
Verified";
signalFilter.CANConnection = item.CANConnection;
signalFilter.Description = item.Description;
signalFilter.SignalTypeName = item.SignalTypeName;
signalFilter.Year = item.Year;
//signalFilter.Date = item.Date;
signalFilter.Date = ConvertUtcToLocalTime(item.Date);
signaleCollection.Add(signalFilter);
Session prevSession = await SessionHelper.CheckLocalSession();
if (prevSession != null)
{
if
(baudRateMapping.TryGetValue(signalFilter.BaudRate.ToString(), out BaudRate
baudRateEnum))
//if (Enum.TryParse(signalFilter.BaudRate, out BaudRate
baudRateEnum))
{
prevSession.CanVIndex = (int)baudRateEnum;
}
cmbScanBaudCAN0.SelectedIndex = (int)baudRateEnum;
await _sessionHelper.CreateLocalSession(prevSession);
}
i++;
}
signalListView.ItemsSource = signaleCollection;
signalListView.Visibility = Visibility.Visible;
previous_btn.IsEnabled = currentPage > 1;
next_btn.IsEnabled = currentPage < maxPages;
}
}
public static DateTime ConvertUtcToLocalTime(DateTime dateTime)
{
return TimeZoneInfo.ConvertTimeFromUtc(dateTime, TimeZoneInfo.Local);
}
private async void signalSerach_BTN_Click(object sender, RoutedEventArgs e)
{
//start setup for profile controller
var dialogSettings = new MetroDialogSettings()
{
AnimateShow = false,
AnimateHide = false
};
//Prepare Progress Dialog
var msgTitle = "Vehicle";
var msgContent = "Saving Vehicle Data";
profileController = await this.ShowProgressAsync(msgTitle, msgContent,
settings: dialogSettings);
profileController.SetIndeterminate();
profileController.Minimum = 0;
profileController.Maximum = 100;
profileController.SetProgress(20);
var getCarMake = (GetMakeNames)comboCar.SelectedValue;
var carMake = new CarMake
{
id = getCarMake.id,
make = getCarMake.make,
};
profileController.SetProgress(40);
var getCarModel = (GetModelNames)comboCarModel.SelectedValue;
var carModel = new CarModel
{
id = getCarModel.id,
model = getCarModel.model,
};
profileController.SetProgress(60);
//var yearSlect = comboYear?.SelectedValue;
var carData = new CarData()
{
CarMake = carMake,
CarModel = carModel,
Year = comboYear.SelectedValue != null ?
(int)comboYear.SelectedValue : (int?)null,
//Year = yearSlect != null ? 0 : (int)null,
//Year = null,
Registration = textRegistration.Text,
EngineType = (EngineType)comboEngineType?.SelectedValue,
GearBox = (GearBox)comboGearBox?.SelectedValue,
WheelDrive = (WheelDrive)comboWheelDrive?.SelectedValue
};
profileController.SetProgress(80);
CarData car = _sessionHelper.Init(carData);
await _sessionHelper.CreateLocalCarData(car);
currentPage = 1;
await GetSignalReportListing();
profileController.SetProgress(100);
await profileController.CloseAsync();
profileController = null;
if (car != null)
{
await this.ShowMessageAsync("Vehicle!!!", "Vehicle Saved
Successfull", MessageDialogStyle.Affirmative);
isCheckingModel = false;
isCheckingMake = false;
MetroMain.Title = MetroMain.Title = Constants.Application_Title + "
---- " + _sessionUser.UserName + " ---- " + carData.CarModel.model;
}
else
{
await this.ShowMessageAsync("Error", "something went wrong while
fetching car models.", MessageDialogStyle.Affirmative);
}
}
public void CheckSignalSerachButton()
{
bool isSearchEnable = false;
bool isCarMake = comboCar.SelectedValue != null;
bool isCarMakeOther = true;
bool isCarModel = comboCarModel.SelectedValue != null;
bool isCarModelOther = true;
bool isCarYear = comboYear.SelectedValue != null;
bool isEngineType = comboEngineType.SelectedValue != null;
bool isGearBox = comboGearBox.SelectedValue != null;
bool isWheelDrive = comboWheelDrive.SelectedValue != null;
var carMake = (GetMakeNames)comboCar.SelectedValue;
isCarMakeOther = carMake != null && carMake.make == "Other" ? !
string.IsNullOrEmpty(otherCarMake.Text) : true;
var carModel = (GetModelNames)comboCarModel.SelectedValue;
isCarModelOther = carModel != null && carModel.model == "Other" ? !
string.IsNullOrEmpty(otherCarModel.Text) : true;
//if (isCarMake && isCarModel && isCarYear && isEngineType &&
isWheelDrive && isGearBox && isCarMakeOther && isCarModelOther)
//{
// isSearchEnable = true;
//}
scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset - toScroll);
e.Handled = true;
}
else if (e.Key == Key.Down)
{
// Scroll Down
scrollViewer.ScrollToVerticalOffset(scrollViewer.VerticalOffset + toScroll);
e.Handled = true;
}
}
}
}
private T FindVisualChild<T>(DependencyObject parent) where T :
DependencyObject
{
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
{
DependencyObject child = VisualTreeHelper.GetChild(parent, i);
if (child is T result)
return result;
T childOfChild = FindVisualChild<T>(child);
if (childOfChild != null)
return childOfChild;
}
return null;
}
prevSession.CanIndex = cmbScanBaudCAN1.SelectedIndex;
//Session newSession = SessionHelper.Init(prevSession);
await _sessionHelper.CreateLocalSession(prevSession);
}
var selecteIndex = cmbScanBaudCAN1.SelectedIndex - 1;
if (selecteIndex >= 0)
{
cmbBaudCAN1.SelectedIndex = selecteIndex;
}
}
if (tglDataSync.IsChecked == true)
{
if (dataSyncTimer != null)
{
tglDataSync.IsChecked = false; // When clear button is
pressed then general status is turned OFF
isExportSettingsPressed = false;
}
}
Button btn = (Button)sender;
string tabIndex = new
String(btn.Name.Where(Char.IsDigit).ToArray());
CANBUS_MSG_SOURCE[Convert.ToInt32(tabIndex)] = 0;
CANBUS_MSG_IDS[Convert.ToInt32(tabIndex)] = 0;
}
}
if (tabIndex == "0")
{
tabName = "BTS 0";
//Mask Values
BTS0_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
BTS0_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
BTS0_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
var rbName = $"{rbPref}{tabIndex}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "1")
{
tabName = "BTS 1";
//Mask Values
BTS1_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
BTS1_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
BTS1_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
var rbName = $"{rbPref}{tabIndex}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "2")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT0_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT0_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT0_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "3")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT1_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT1_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT1_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "4")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT2_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT2_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT2_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "5")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT3_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT3_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT3_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "6")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT4_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT4_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT4_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "7")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT5_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT5_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT5_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "8")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT6_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT6_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT6_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "9")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT7_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT7_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT7_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "10")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT8_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT8_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT8_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "11")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT9_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT9_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT9_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "12")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT10_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT10_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT10_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "13")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT11_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT11_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT11_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "14")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT12_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT12_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT12_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "15")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT13_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT13_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT13_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "16")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT14_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT14_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT14_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
else if (tabIndex == "17")
{
tabName = "BTS 1";
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//Mask Values
CMBIT15_DATA_BYTES[byteIndex] = (byte)0;
//Trigger Values
CMBIT15_DATA_BYTES[byteIndex + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT15_DATA_BYTES[byteIndex + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{byteIndex}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
if (parentObject == null)
return null;
T parent = parentObject as T;
if (parent != null)
return parent;
else
return FindParent<T>(parentObject);
}
private T FindFirstChild<T>(DependencyObject parent) where T :
DependencyObject
{
if (parent == null)
return null;
try
{
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12;
httpClient.DefaultRequestHeaders.Authorization = new
AuthenticationHeaderValue("Bearer", jwtToken);
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12;
await httpClient.PostAsync(AddVehicleCanIdURL, httpContent);
//var serverResponse = await
httpClient.PostAsync(AddVehicleCanIdURL, httpContent);
//if (serverResponse.IsSuccessStatusCode)
//{
// var message = await
serverResponse.Content.ReadAsStringAsync();
//}
}
catch (Exception)
{
}
}
#endregion
ComboBox comboBox = sender as ComboBox; // Cast sender to ComboBox
if (comboBox != null)
{
// Get the selected item from the ComboBox
var selectedItem = (SignalFilter)comboBox.SelectedItem;
if (selectedItem != null)
{
Match match = Regex.Match(comboBox.Name, @"\d+");
if (match.Success)
{
string extractedNumber = match.Value;
int idx = int.Parse(extractedNumber);
_selectedSignalIds[idx] = selectedItem.Id;
}
var canDescription = selectedItem.Description;
//var signalName = signalTypeName.Content.ToString();
var signalName = selectedItem.SignalTypeName;
//return;
//var fileurl = signalFileURL.Content.ToString();
var fileurl = selectedItem.FileURL;
bool isVerified = false;
if (selectedItem.isVerified == true)
isVerified = true;
XmlNodeList entryNodes =
xmlDoc.SelectNodes("//Section/entry");
foreach (XmlNode entryNode in entryNodes)
{
var key = entryNode.Attributes["name"].Value;
var value = entryNode.InnerText;
signalInfo.Add(key, value);
}
i++;
}
if (cmbBaudCAN0.Text != baudRate)
{
//Prepare Progress Dialog
var msgTitle = "Buad rate is unmatched";
var msgContent = "Do you want to change baud rate?";
if (index != -1)
{
cmbBaudCAN0.SelectedIndex = index;
}
}
}
}
isSignalSelected = true;
isExportSettingsPressed = false;
}
}
foreach (var kvp in idToBufferPosition)
{
// Try to parse the string value to an integer
if (int.TryParse(kvp.Value, out int parsedValue))
{
// If parsing is successful, store the integer value in
_selectedSignalIds
_selectedSignalIds[kvp.Key] = parsedValue;
}
else
{
_selectedSignalIds[kvp.Key] = 0;
}
}
}
catch (Exception)
{
}
}
public void CloneSignalIntoCollection(int tabIndex, byte[] byteArray)
{
//BTS section
if (tabIndex == 0)
{
BTS0_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
BTS0_DATA_BYTES_COPY.Add(byteArray[index]);
}
//set flag for fetch signal
BTS0_isFetched = true;
}
if (tabIndex == 1)
{
BTS1_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
BTS1_DATA_BYTES_COPY.Add(byteArray[index]);
}
//CMBit section
if (tabIndex == 2)
{
CMBIT0_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT0_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 3)
{
CMBIT1_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT1_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 4)
{
CMBIT2_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT2_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 5)
{
CMBIT3_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT3_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 6)
{
CMBIT4_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT4_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 7)
{
CMBIT5_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT5_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 8)
{
CMBIT6_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT6_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 9)
{
CMBIT7_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT7_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 10)
{
CMBIT8_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT8_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 11)
{
CMBIT9_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT9_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 12)
{
CMBIT10_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT10_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 13)
{
CMBIT11_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT11_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 14)
{
CMBIT12_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT12_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 15)
{
CMBIT13_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT13_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 16)
{
CMBIT14_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT14_DATA_BYTES_COPY.Add(byteArray[index]);
}
if (tabIndex == 17)
{
CMBIT15_DATA_BYTES_COPY.Clear();
for (int index = 0; index < byteArray.Length; index++)
{
CMBIT15_DATA_BYTES_COPY.Add(byteArray[index]);
}
}
public void SetValueToUI(int tabIndex, string canPort, uint msgIdByte,
string format, string canDescription, string signalName, ToggleButton toggleButton)
{
isFetchFromCloud = true;
toggleButton.Visibility = Visibility.Visible;
toggleButton.IsChecked = false;
CANBUS_MSG_IDS_COPY[tabIndex] = msgIdByte;
//msgFormat.Content = format;
//MSG_FORMAT_COPY.Add(tabIndex, msgFormat.Content.ToString());
MSG_FORMAT_COPY.Remove(tabIndex);
CAN_PORT_COPY.Remove(tabIndex);
MSG_FORMAT_COPY.Add(tabIndex, format);
CAN_PORT_COPY.Add(tabIndex, canPort);
CANBUS_MSG_SOURCE_COPY[tabIndex] = ((byte)(canPort.Equals("CAN-V") ?
1 : 2));
}
}
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
Session session = await SessionHelper.CheckLocalSession();
var sessionUser = _sessionUser;
httpClient.DefaultRequestHeaders.Authorization = new
AuthenticationHeaderValue("Bearer", session.Token);
var serverResponse = await httpClient.GetAsync(getSignalByIdURL);
if (serverResponse.IsSuccessStatusCode)
{
var signalDetailmessage = await
serverResponse.Content.ReadAsStringAsync();
var signalDetailResponse =
JsonConvert.DeserializeObject<GetSignalByIdResponse>(signalDetailmessage);
response.Id = signalDetailResponse.Id;
response.Description = signalDetailResponse.Description;
response.SignalType = signalDetailResponse.SignalType;
return response;
}
else
{
var contentStream = await
serverResponse.Content.ReadAsStringAsync();
var errorResponse =
JsonConvert.DeserializeObject<HttpErrorResponse>(contentStream);
await this.ShowMessageAsync("Message", errorResponse.Error,
MessageDialogStyle.Affirmative);
}
}
catch (Exception)
{
this.Close();
await this.ShowMessageAsync("Error", "Signal Details not Fetched",
MessageDialogStyle.Affirmative);
}
return response;
}
ServicePointManager.SecurityProtocol =
SecurityProtocolType.Tls12;
Session session = await SessionHelper.CheckLocalSession();
var sessionUser = _sessionUser;
httpClient.DefaultRequestHeaders.Authorization = new
AuthenticationHeaderValue("Bearer", session.Token);
var serverResponse = await
httpClient.PostAsync(addSignalLikeURL, httpContent);
if (serverResponse.IsSuccessStatusCode)
{
var signalLikeMessage = await
serverResponse.Content.ReadAsStringAsync();
var signalLikeResponse =
JsonConvert.DeserializeObject<AddSignalLikeResponse>(signalLikeMessage);
await this.ShowMessageAsync("Message", "Signal Report
Liked", MessageDialogStyle.Affirmative);
if (signalLikeResponse.IsLike == true)
{
btn.Foreground = Brushes.Orange;
btn.IsEnabled = false;
}
}
else
{
var contentStream = await
serverResponse.Content.ReadAsStringAsync();
var errorResponse =
JsonConvert.DeserializeObject<HttpErrorResponse>(contentStream);
await this.ShowMessageAsync("Message", errorResponse.Error,
MessageDialogStyle.Affirmative);
}
}
}
catch (Exception)
{
this.Close();
await this.ShowMessageAsync("Error", "something went wrong while
adding signal like", MessageDialogStyle.Affirmative);
}
}
private void ClearCMPosition(int tabIndex)
{
var rbPref = "radBts";
var rbCMPref = "radCMBit";
var sepratorKey = "B";
var sepratorKeyIgnore = "I";
CANBUS_MSG_SOURCE[tabIndex] = 0;
CANBUS_MSG_IDS[tabIndex] = 0;
if (tabIndex == 0)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
for (int i = 0; i < 8; i++)
{
BTS0_DATA_BYTES[i] = (byte)0;
BTS0_DATA_BYTES[i + 8] = (byte)0;
BTS0_DATA_BYTES[i + 8 + 8] = (byte)0;
var rbName = $"{rbPref}{tabIndex}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 1)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
for (int i = 0; i < 8; i++)
{
BTS1_DATA_BYTES[i] = (byte)0;
BTS1_DATA_BYTES[i + 8] = (byte)0;
BTS1_DATA_BYTES[i + 8 + 8] = (byte)0;
var rbName = $"{rbPref}{tabIndex}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 2)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (tabIndex - 2).ToString();
for (int i = 0; i < 8; i++)
{
CMBIT0_DATA_BYTES[i] = (byte)0;
CMBIT0_DATA_BYTES[i + 8] = (byte)0;
CMBIT0_DATA_BYTES[i + 8 + 8] = (byte)0;
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 3)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT1_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT1_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT1_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 4)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT2_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT2_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT2_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 5)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT3_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT3_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT3_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 6)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT4_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT4_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT4_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 7)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT5_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT5_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT5_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 8)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT6_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT6_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT6_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 9)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT7_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT7_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT7_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 10)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT8_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT8_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT8_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 11)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT9_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT9_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT9_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 12)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT10_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT10_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT10_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 13)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT11_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT11_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT11_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 14)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT12_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT12_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT12_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 15)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT13_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT13_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT13_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 16)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT14_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT14_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT14_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
else if (tabIndex == 17)
{
if (isFetchFromCloud)
{
ToggleButton tBtn =
(ToggleButton)FindName($"toggle{tabIndex}");
if (tBtn != null)
{
tBtn.IsChecked = true;
}
}
var index = (Convert.ToInt32(tabIndex) - 2).ToString();
//reset data bytes 0 -7
for (int i = 0; i < 8; i++)
{
//Mask Values
CMBIT15_DATA_BYTES[i] = (byte)0;
//Trigger Values
CMBIT15_DATA_BYTES[i + 8] = (byte)0;
//Logical Operatior Indexes.
CMBIT15_DATA_BYTES[i + 8 + 8] = (byte)0;
//radCMBit0B7I
var rbName = $"{rbCMPref}{index}{sepratorKey}{i}
{sepratorKeyIgnore}";
var rbIgnore = (RadioButton)this.FindName(rbName);
if (rbIgnore.IsChecked == false)
rbIgnore.IsChecked = true;
}
}
}
private async void Button_ClearAll_Clicked(object sender, RoutedEventArgs
e)
{
var dialogSettings = new MetroDialogSettings()
{
ColorScheme = MetroDialogColorScheme.Inverted,
};
if (result == MessageDialogResult.Affirmative)
{
isClearButtonClicked = true;
undoButtonPressedBeforeExport = true;
if (tglDataSync.IsChecked == true)
{
if (dataSyncTimer != null)
{
tglDataSync.IsChecked = false; // When clear button is
pressed then general status is turned OFF
isExportSettingsPressed = false;
}
}
if (para == 2)
{
while (stack.Count < 8) stack.Push(0);
}
else if (para == 16)
{
while (stack.Count < 2) stack.Push(0);
}
else if (para > 16)
{
while (stack.Count < 8) stack.Push(0);
}
}
catch (Exception)
{
return null;
}
}
}
public class HexToDecimalConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter,
CultureInfo culture)
{
try
{
string hexValue = value.ToString();
int decValue = int.Parse(hexValue,
System.Globalization.NumberStyles.HexNumber);
return decValue;
}
catch (Exception ex)
{
ExceptionHandler.DebugException(ex);
return value;
}
}
}
}
return !(bool)value;
}
#endregion
}