function updateDetails(details)
{
var candyKey, candyValue;
// ReceptionTime
candyKey = CANDY['ReceptionTime'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#reception-time').html( GetValue(details[CANDY["Timestamp"]]) );
}
// LineName
candyKey = CANDY['LineName'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#line').html( candyValue );
}
// TripNo
candyKey = CANDY['JourneyNumber'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
let tripNoText = candyValue,
lineName = details[CANDY['LineName']];
if(!!lineName && candyValue.includes(lineName) && candyValue.length > lineName.length) {
tripNoText = candyValue.slice(tripNoText.indexOf(lineName) + lineName.length);
}
$('#trip-no').html( tripNoText );
}
else {
$('#trip-no').html( '-' );
}
// Stop Index
candyKey = CANDY['StopIndex'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#stop-index').html( candyValue );
}
else {
$('#stop-index').html( '-' );
}
// Stop Counter
candyKey = CANDY['StopCounter'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#stop-counter').html( candyValue );
}
else {
$('#stop-counter').html( '-' );
}
// Mainswitch
candyKey = CANDY['Mainswitch'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-'+candyKey).html( TRANSLATE['sbi_switch_'+candyValue].toUpperCase() );
if (candyValue == 'on') { shadow = SHADOW_GREEN; }
else { shadow = ''; }
$('#sbi-'+candyKey).css('text-shadow', shadow);
}
// EngineSpeed
candyKey = CANDY['EngineSpeed'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-'+candyKey).html( Math.round(candyValue) );
if (candyValue > 3000) { shadow = SHADOW_RED; }
else if (candyValue > 2000) { shadow = SHADOW_YELLOW; }
else { shadow = ''; }
$('#sbi-'+candyKey).css('text-shadow', shadow);
}
// WheelBasedVehicleSpeed
candyKey = CANDY['WheelBasedVehicleSpeed'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-'+candyKey).html( Math.round(candyValue) + ' km/h' );
if (candyValue > 90) { shadow = SHADOW_RED; }
else if (candyValue > 75) { shadow = SHADOW_YELLOW;}
else { shadow = ''; }
$('#sbi-'+candyKey).css('text-shadow', shadow);
}
// EngineCoolantTemperature
candyKey = CANDY['EngineCoolantTemperature'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-'+candyKey).html( Math.round(candyValue) + ' ℃' );
if (candyValue > 95) { shadow = SHADOW_RED; }
else if (candyValue > 85) { shadow = SHADOW_YELLOW;}
else { shadow = ''; }
$('#sbi-'+candyKey).css('text-shadow', shadow);
}
// HighResolutionTotalVehicleDistance
candyKey = CANDY['HighResolutionTotalVehicleDistance'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-'+candyKey).html( Math.round(candyValue/1000).toLocaleString('de-AT',{maximumFractionDigits:0}) + ' km' );
}
// FuelLevel
candyKey = CANDY['FuelLevel'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-'+candyKey).html( candyValue + ' %' );
if (candyValue < 10) { shadow = SHADOW_RED; }
else if (candyValue < 20) { shadow = SHADOW_YELLOW; }
else { shadow = ''; }
$('#sbi-'+candyKey).css('text-shadow', shadow);
}
// CatalystTankLevel
candyKey = CANDY['CatalystTankLevel'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-'+candyKey).html( candyValue + ' %' );
if (candyValue < 10) { shadow = SHADOW_RED; }
else if (candyValue < 20) { shadow = SHADOW_YELLOW; }
else { shadow = ''; }
$('#sbi-'+candyKey).css('text-shadow', shadow);
}
// PowerSupply
candyKey = CANDY['PowerSupply'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-'+candyKey).html( candyValue + ' volt' );
if (candyValue < 21) { shadow = SHADOW_RED; }
else if (candyValue < 23) { shadow = SHADOW_YELLOW; }
else { shadow = ''; }
$('#sbi-'+candyKey).css('text-shadow', shadow);
}
// EngineOilPressure, EvobusEngineOilPressure
candyKey = CANDY['EngineOilPressure'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-oil-pressure').html( candyValue/100 + ' bar' );
if (candyValue > 800) { shadow = SHADOW_RED; }
else if (candyValue > 500) { shadow = SHADOW_YELLOW; }
else { shadow = ''; }
$('#sbi-oil-pressure').css('text-shadow', shadow);
}
candyKey = CANDY['EvobusEngineOilPressure'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-oil-pressure').html( candyValue + ' bar' );
if (candyValue > 8) { shadow = SHADOW_RED; }
else if (candyValue > 5) { shadow = SHADOW_YELLOW; }
else { shadow = ''; }
$('#sbi-oil-pressure').css('text-shadow', shadow);
}
// EvobusEngineOilRefillingQuantity
candyKey = CANDY['EvobusEngineOilRefillingQuantity'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-'+candyKey).html( candyValue + ' l' );
if (candyValue > 2) { shadow = SHADOW_RED; }
else if (candyValue > 1) { shadow = SHADOW_YELLOW; }
else { shadow = ''; }
$('#sbi-'+candyKey).css('text-shadow', shadow);
}
// Destination
candyKey = CANDY['Destination'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
// $('#sbi-'+candyKey).html( candyValue );
$('#destination').html( candyValue );
}
// LineName
candyKey = CANDY['LineName'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-'+candyKey).html( candyValue );
}
// StopName
candyKey = CANDY['StopName'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
// $('#sbi-'+candyKey).html( candyValue );
// $('#sbi-'+candyKey).attr( 'title', candyValue );
$('#stop-name').html( candyValue );
$('#stop-name').attr( 'title', candyValue );
}
// Door
candyKey = CANDY['Door'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-'+candyKey).html( TRANSLATE['sbi_door_'+candyValue] );
}
// DriverCard1
candyKey = CANDY['DriverCard1'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '')
{
$('#sbi-'+candyKey).html( TRANSLATE['sbi_driver_card_'+candyValue] );
}
// Trip Drive
candyKey = CANDY['TripDrive'];
tripDrive = details[candyKey];
if (typeof tripDrive !== 'undefined' && tripDrive != '')
{
$('#sbi-'+candyKey).html( (parseInt(tripDrive) / 1000).toFixed(2) + ' KM' );
}
else {
$('#sbi-'+candyKey).html( '-' );
}
// Trip Fuel
candyKey = CANDY['TripFuel'];
tripFuel = details[candyKey];
if (typeof tripFuel !== 'undefined' && tripFuel != '')
{
$('#sbi-'+candyKey).html( parseFloat(tripFuel).toFixed(2) + ' L' );
}
else {
$('#sbi-'+candyKey).html( '-' );
}
// Total Fuel Used
candyValue = details[candyKey];
if (typeof tripDrive !== 'undefined' && tripDrive != '' && typeof tripFuel !== 'undefined' && tripFuel != '')
{
$('#fuel-eficiensy').html( parseFloat(100 * tripFuel / tripDrive * 1000).toFixed(2) + ' L/100km' );
}
else {
$('#sbi-'+candyKey).html( '-' );
}
// Comfort
$('#sbi-comfort').html( getComfort(details) );
// ELSY16Bit017
candyKey = CANDY['ELSY16Bit017'];
candyValue = details[candyKey];
if (typeof candyValue !== 'undefined' && candyValue != '' && candyValue != '0')
{
$('#sbi-'+candyKey).html( candyValue / 10 );
}
// Brake Wear
$('#sbi-brakewear').html( getBrakeWear(details) );
// Details version
// $('#sbi-version').html( getDetailsVersion(details) );
}
// =================================================================================================
function getComfort(data)
{
var c = 460;
for (var i = CANDY['ELSY01Bit460']; i <= CANDY['ELSY01Bit468']; i++)
{
if (data[i] == '1')
{
return '
';
}
c++;
}
}
function getBrakeWear(data)
{
var breakWearNames = ['VO LI', 'VO RE', 'AA LI', 'AA RE', 'ZA LI', 'ZA RE'];
var brakeWearParams = [
['EvobusFrontAxleLeftBrakeLiningWear', 'BrakeLiningRemainingFrontAxleLeftWheel'],
['EvobusFrontAxleRightBrakeLiningWear', 'BrakeLiningRemainingFrontAxleRightWheel'],
['EvobusDriveAxleLeftBrakeLiningWear', 'BrakeLiningRemainingRearAxle1LeftWheel'],
['EvobusDriveAxleRightBrakeLiningWear', 'BrakeLiningRemainingRearAxle1RightWheel'],
['EvobusAuxiliaryAxleLeftBrakeLiningWear', 'BrakeLiningRemainingRearAxle2LeftWheel'],
['EvobusAuxiliaryAxleRightBrakeLiningWear', 'BrakeLiningRemainingRearAxle2RightWheel']
];
var brakeWear, b1, b2;
var html = '
';
brakeWearParams.forEach(function(params, key)
{
//if(!!data[CANDY[params[0]]]) {
b1 = !!data[CANDY[params[0]]] ? parseFloat(data[CANDY[params[0]]]) : 0
b2 = !!data[CANDY[params[1]]] ? parseFloat(data[CANDY[params[1]]]) : 0
brakeWear = Math.round( b1 + b2 )
if (brakeWear > 0)
{
html += '';
html += '| ' + breakWearNames[key] + ' | ';
html += '' + brakeWear + ' % | ';
html += '
';
}
//}
});
html += '
';
return html;
}
function getDetailsVersion(data)
{
var infoNames = ['Postbusapp version', 'Tablet App Gateway Version', 'Tablet App Gateway Status', 'Tablet IP', 'Busnode software version', 'Last Tablet Report Time'];
var infoParams = [
'VehicleInterfaceApplication1',
'TabletAppGatewayVersion',
'TabletAppGatewayStatus',
'TabletConnectionIP',
'',
'TabletTime'
];
var info;
var html = '';
infoParams.forEach(function(param, key)
{
info = (data[CANDY[param]] == undefined ? "-" : data[CANDY[param]]);
if(param == "VehicleInterfaceApplication1") {
if(data[CANDY["VehicleInterfaceApplication2"]] != undefined && data[CANDY["VehicleInterfaceApplication2"]] != 'off')
{
info += ('.' + data[CANDY["VehicleInterfaceApplication2"]]);
if(data[CANDY["VehicleInterfaceApplication3"]] != undefined && data[CANDY["VehicleInterfaceApplication3"]] != 'off')
{
info += ('.' + data[CANDY["VehicleInterfaceApplication3"]]);
if(data[CANDY["VehicleInterfaceApplication4"]] != undefined && data[CANDY["VehicleInterfaceApplication4"]] != 'off')
{
info += ('.' + data[CANDY["VehicleInterfaceApplication4"]]);
}
}
}
}
if(param == "TabletTime") {
if(data[CANDY[param]] != undefined && /^\d+$/g.test(data[CANDY[param]])) {
let date = new Date(parseInt(data[CANDY[param]]) * 1000),
year = date.getUTCFullYear() ,
month = date.getMonth(),
day = date.getDate(),
hour = date.getHours(),
minutes = date.getMinutes(),
seconds = date.getSeconds();
if(isNaN(year) || isNaN(month) || isNaN(day) || isNaN(hour) || isNaN(minutes) || isNaN(seconds)) {
info = '-';
}
else {
info = `${(year + '').padStart(4, 0)}-${((month + 1) + '').padStart(2, 0)}-${(day + '').padStart(2, 0)} ${(hour + '').padStart(2, 0)}:${(minutes + '').padStart(2, 0)}:${(seconds + '').padStart(2, 0)}`;
}
}
else {
info = '-';
}
}
html += '';
html += '| ' + infoNames[key] + ': | ';
html += '' + info + ' | ';
html += '
';
});
html += '
';
return html;
}