var DeviceTypeMake = "";
//*******************Load Monitor Data ****************************
function GetMonitorData(BoxID, UserID, DeviceType) {
    DeviceTypeMake = DeviceType;
    var isbusness;
    $.ajax({
        type: "POST",
        url: "Dashboard.aspx/GetDataType",
        contentType: "application/json; charset=utf-8",
        data: '{"BoxID":"' + BoxID + '","UserID":"' + UserID + '"}',
        dataType: "json",
        success: AjaxMonitorSucceeded,
        error: AjaxMonitorFailed
    });
}
function AjaxMonitorSucceeded(result) {
    LoadMonitorData(result);
}
function AjaxMonitorFailed(result) {
    alert('Failed to load');
}
function LoadMonitorData(result) {
    var items = JSON.parse(result.d);
    LoadMonitorDatavalues(items);
}
function LoadMonitorDatavalues(BusinessList) {
    var Status = 0;
    var CtrMode = 0;
    if (DeviceTypeMake == "1") {
        $(BusinessList).each(function () {
            if (this.Text == "Status") {
                Status = this.Value;
            }
            if (this.Text == "CtrMode") {
                CtrMode = this.Value;
            }
            if (this.Text == "OriginDateTimeSort") {
                if (document.getElementById("lblreportedOn") != null)
                    document.getElementById("lblreportedOn").innerHTML = this.Value;
            }
            if (this.Text == "Supervisor_State") {
                if (document.getElementById("lblSupervisorState") != null)
                    document.getElementById("lblSupervisorState").innerHTML = this.Value;
            }
            if (this.Text == "Gen_Rating") {
                if (document.getElementById("lblGeneratorRating") != null)
                    document.getElementById("lblGeneratorRating").innerHTML = this.Value;
            }
            if (this.Text == "BatteryCharger_OP_Cur") {
                if (document.getElementById("lblBatteryCharger") != null)
                    document.getElementById("lblBatteryCharger").innerHTML = this.Value;
            }
            if (this.Text == "GatewayId") {
                if (document.getElementById("hdnGatewayID") != null)
                    document.getElementById("hdnGatewayID").innerHTML = this.Value;
            }

            if (this.Text == "Coolant_Temp") {
                if (document.getElementById("hdnTemp") != null)
                    document.getElementById("hdnTemp").value = this.Value;
            }
            if (this.Text == "EngineSpeed") {
                if (document.getElementById("hdnSpeed") != null)
                    document.getElementById("hdnSpeed").value = this.Value;
            }
            if (this.Text == "Batt_Volt") {
                if (document.getElementById("hdnBatteryVolt") != null)
                    document.getElementById("hdnBatteryVolt").value = this.Value;
            }
            if (this.Text == "BatteryCharger_OP_Cur") {
                if (document.getElementById("hdnBatteryCharger") != null)
                    document.getElementById("hdnBatteryCharger").value = this.Value;
            }
            if (this.Text == "Gen_Freq") {
                if (document.getElementById("hdnFrequency") != null)
                    document.getElementById("hdnFrequency").value = this.Value;
            }
            if (this.Text == "Gen_LLVolt") {
                if (document.getElementById("hdnLLVolt") != null)
                    document.getElementById("hdnLLVolt").value = this.Value;
            }
            if (this.Text == "Gen_LNVolt") {
                if (document.getElementById("hdnLNVolt") != null)
                    document.getElementById("hdnLNVolt").value = this.Value;
            }
            if (this.Text == "Gen_L1_Current") {
                if (document.getElementById("lblCurrent") != null)
                    document.getElementById("lblCurrent").innerHTML = this.Value;
            }
            if (this.Text == "Engine_RunTime") {
                if (document.getElementById("lblEngineHrs") != null)
                    document.getElementById("lblEngineHrs").innerHTML = this.Value;
            }
            if (this.Text == "Tot_Watts") {
                if (document.getElementById("lblGenTotalWatts") != null)
                    document.getElementById("lblGenTotalWatts").innerHTML = this.Value;
            }
            if (this.Text == "Tot_VA") {
                if (document.getElementById("lblTotVA") != null)
                    document.getElementById("lblTotVA").innerHTML = this.Value;
            }
            if (this.Text == "Tot_VAr") {
                if (document.getElementById("lblTotVAr") != null)
                    document.getElementById("lblTotVAr").innerHTML = this.Value;
            }
            if (this.Text == "Gen_KWh") {
                if (document.getElementById("lblKWh") != null)
                    document.getElementById("lblKWh").innerHTML = this.Value;
            }
            if (this.Text == "Gen_KVAh") {
                if (document.getElementById("lblKVAh") != null)
                    document.getElementById("lblKVAh").innerHTML = this.Value;
            }
            if (this.Text == "Gen_KVArh") {
                if (document.getElementById("lblKVArh") != null)
                    document.getElementById("lblKVArh").innerHTML = this.Value;
            }
            if (this.Text == "Gen_L1_PF") {
                if (document.getElementById("lblPfactor") != null)
                    document.getElementById("lblPfactor").innerHTML = this.Value;
            }
            if (this.Text == "Chrg_Alternator") {
                if (document.getElementById("hdnChrgAlter") != null)
                    document.getElementById("hdnChrgAlter").value = this.Value;
            }
            if (this.Text == "Coolant_Temp") {
                if (document.getElementById("hdnCoolTemp") != null)
                    document.getElementById("hdnCoolTemp").value = this.Value;
            }
            if (this.Text == "Oil_Temp") {
                if (document.getElementById("hdnOilTemp") != null)
                    document.getElementById("hdnOilTemp").value = this.Value;
            }
            if (this.Text == "Oil_Pressure") {
                if (document.getElementById("hdnOilPres") != null)
                    document.getElementById("hdnOilPres").value = this.Value;
            }

            /////
            if (this.Text == "FuelLevel") {
                if (document.getElementById("hdnFuelLvl") != null)
                    document.getElementById("hdnFuelLvl").value = this.Value;
            }
            if (this.Text == "GEN_L1_N_VOLT") {
                if (document.getElementById("lblL1_N") != null)
                    document.getElementById("lblL1_N").innerHTML = this.Value;
            }
            if (this.Text == "GEN_L2_N_VOLT") {
                if (document.getElementById("lblL2_N") != null)
                    document.getElementById("lblL2_N").innerHTML = this.Value;
            }
            if (this.Text == "GEN_L3_N_VOLT") {
                if (document.getElementById("lblL3_N") != null)
                    document.getElementById("lblL3_N").innerHTML = this.Value;
            }
            if (this.Text == "GEN_L1_L2_VOLT") {
                if (document.getElementById("lblL1_L2") != null)
                    document.getElementById("lblL1_L2").innerHTML = this.Value;
            }
            if (this.Text == "GEN_L2_L3_VOLT") {
                if (document.getElementById("lblL2_L3") != null)
                    document.getElementById("lblL2_L3").innerHTML = this.Value;
            }
            if (this.Text == "GEN_L1_L3_VOLT") {
                if (document.getElementById("lblL1_L3") != null)
                    document.getElementById("lblL1_L3").innerHTML = this.Value;
            }
            if (this.Text == "GENCURRENT_L1") {
                if (document.getElementById("lblCurrentL1") != null)
                    document.getElementById("lblCurrentL1").innerHTML = this.Value;
            }
            if (this.Text == "GENCURRENT_L2") {
                if (document.getElementById("lblCurrentL2") != null)
                    document.getElementById("lblCurrentL2").innerHTML = this.Value;
            }
            if (this.Text == "GENCURRENT_L3") {
                if (document.getElementById("lblCurrentL3") != null)
                    document.getElementById("lblCurrentL3").innerHTML = this.Value;
            }
            if (this.Text == "Gen_L1_Watts") {
                if (document.getElementById("lblWattsL1") != null)
                    document.getElementById("lblWattsL1").innerHTML = this.Value;
            }
            if (this.Text == "Gen_L2_Watts") {
                if (document.getElementById("lblWattsL2") != null)
                    document.getElementById("lblWattsL2").innerHTML = this.Value;
            }
            if (this.Text == "Gen_L3_Watts") {
                if (document.getElementById("lblWattsL3") != null)
                    document.getElementById("lblWattsL3").innerHTML = this.Value;
            }
            if (this.Text == "FuelLevel") {
                var num = this.Value;
                var n = (parseFloat(num) / 100 * 2000);
                if (document.getElementById("lblFuel") != null)
                    document.getElementById("lblFuel").innerHTML = 'Fuel Level (' + String(n) + ' liter\'s)';
            }
        });
        GenInput();
        GenOutput();
        if (Status == "0")
            UnloadData();
        SetDeviceStatus(CtrMode);
        if (document.getElementById("hdnFirstTimeLoad").value != "1")
            FirstTimeLoadValues();
    }
    else {
        $(BusinessList).each(function () {
            if (this.Text == "Status") {
                Status = this.Value;
            }
            if (this.Text == "CtrMode") {
                CtrMode = this.Value;
            }
            if (this.Text == "OriginDateTimeSort") {
                if (document.getElementById("lblreportedOn") != null)
                    document.getElementById("lblreportedOn").innerHTML = this.Value;
            }
            if (this.Text == "Supervisor_State") {
                if (document.getElementById("lblSupervisorState") != null)
                    document.getElementById("lblSupervisorState").innerHTML = this.Value;
            }
            if (this.Text == "Gen_Rating") {
                if (document.getElementById("lblGeneratorRating") != null)
                    document.getElementById("lblGeneratorRating").innerHTML = this.Value;
            }
            if (this.Text == "BatteryCharger_OP_Cur") {
                if (document.getElementById("lblBatteryCharger") != null)
                    document.getElementById("lblBatteryCharger").innerHTML = this.Value;
            }

            if (this.Text == "Coolant_Temp") {
                if (document.getElementById("hdnTemp") != null)
                    document.getElementById("hdnTemp").value = this.Value;
            }
            if (this.Text == "EngineSpeed") {
                if (document.getElementById("hdnSpeed") != null)
                    document.getElementById("hdnSpeed").value = this.Value;
            }
            if (this.Text == "Batt_Volt") {
                if (document.getElementById("hdnBatteryVolt") != null)
                    document.getElementById("hdnBatteryVolt").value = this.Value;
            }

            if (this.Text == "S1_Freq") {
                if (document.getElementById("hdnFrequency") != null)
                    document.getElementById("hdnFrequency").value = this.Value;
            }
            if (this.Text == "S1_LL_Volt") {
                if (document.getElementById("hdnLLVolt") != null)
                    document.getElementById("hdnLLVolt").value = this.Value;
            }
            if (this.Text == "S1_LN_Volt") {
                if (document.getElementById("hdnLNVolt") != null)
                    document.getElementById("hdnLNVolt").value = this.Value;
            }
            if (this.Text == "Gen_L1_Current") {
                if (document.getElementById("lblCurrent") != null)
                    document.getElementById("lblCurrent").innerHTML = this.Value;
            }
            if (this.Text == "S1_Tot_Watts") {
                if (document.getElementById("lblGenTotalWatts") != null)
                    document.getElementById("lblGenTotalWatts").innerHTML = this.Value;
            }
            if (this.Text == "S1_Tot_VA") {
                if (document.getElementById("lblTotVA") != null)
                    document.getElementById("lblTotVA").innerHTML = this.Value;
            }
            if (this.Text == "S1_Tot_VAr") {
                if (document.getElementById("lblTotVAr") != null)
                    document.getElementById("lblTotVAr").innerHTML = this.Value;
            }
            if (this.Text == "S1_KWh") {
                if (document.getElementById("lblKWh") != null)
                    document.getElementById("lblKWh").innerHTML = this.Value;
            }
            if (this.Text == "S1_KVAh") {
                if (document.getElementById("lblKVAh") != null)
                    document.getElementById("lblKVAh").innerHTML = this.Value;
            }
            if (this.Text == "S1_KVArh") {
                if (document.getElementById("lblKVArh") != null)
                    document.getElementById("lblKVArh").innerHTML = this.Value;
            }
            if (this.Text == "S1_AvgPF") {
                if (document.getElementById("lblPfactor") != null)
                    document.getElementById("lblPfactor").innerHTML = this.Value;
            }
            if (this.Text == "S2_Freq") {
                if (document.getElementById("S2_hdnFrequency") != null)
                    document.getElementById("S2_hdnFrequency").value = this.Value;
            }
            if (this.Text == "S2_LL_Volt") {
                if (document.getElementById("S2_hdnLLVolt") != null)
                    document.getElementById("S2_hdnLLVolt").value = this.Value;
            }
            if (this.Text == "S2_LN_Volt") {
                if (document.getElementById("S2_hdnLNVolt") != null)
                    document.getElementById("S2_hdnLNVolt").value = this.Value;
            }
            if (this.Text == "S2_Tot_Watts") {
                if (document.getElementById("lblS2_TotWatts") != null)
                    document.getElementById("lblS2_TotWatts").innerHTML = this.Value;
            }
            if (this.Text == "S2_Tot_VA") {
                if (document.getElementById("lblS2_TotVA") != null)
                    document.getElementById("lblS2_TotVA").innerHTML = this.Value;
            }
            if (this.Text == "S2_Tot_VAr") {
                if (document.getElementById("lblS2_TotVar") != null)
                    document.getElementById("lblS2_TotVar").innerHTML = this.Value;
            }
            if (this.Text == "S2_KWh") {
                if (document.getElementById("lblS2_Kwh") != null)
                    document.getElementById("lblS2_Kwh").innerHTML = this.Value;
            }
            if (this.Text == "S2_KVAh") {
                if (document.getElementById("lblS2_KVAh") != null)
                    document.getElementById("lblS2_KVAh").innerHTML = this.Value;
            }
            if (this.Text == "S2_KVArh") {
                if (document.getElementById("lblS2_KVArh") != null)
                    document.getElementById("lblS2_KVArh").innerHTML = this.Value;
            }
            if (this.Text == "S2_AvgPF") {
                if (document.getElementById("lblS2_PF") != null)
                    document.getElementById("lblS2_PF").innerHTML = this.Value;
            }
            if (this.Text == "S1_L1_N_Voltage") {
                if (document.getElementById("lblL1_N") != null)
                    document.getElementById("lblL1_N").innerHTML = this.Value;
            }
            if (this.Text == "S1_L2_N_Voltage") {
                if (document.getElementById("lblL2_N") != null)
                    document.getElementById("lblL2_N").innerHTML = this.Value;
            }
            if (this.Text == "S1_L3_N_Voltage") {
                if (document.getElementById("lblL3_N") != null)
                    document.getElementById("lblL3_N").innerHTML = this.Value;
            }
            if (this.Text == "S1_L1_L2_Voltage") {
                if (document.getElementById("lblL1_L2") != null)
                    document.getElementById("lblL1_L2").innerHTML = this.Value;
            }
            if (this.Text == "S1_L2_L3_Voltage") {
                if (document.getElementById("lblL2_L3") != null)
                    document.getElementById("lblL2_L3").innerHTML = this.Value;
            }
            if (this.Text == "S1_L3_L1_Voltage") {
                if (document.getElementById("lblL1_L3") != null)
                    document.getElementById("lblL1_L3").innerHTML = this.Value;
            }
            if (this.Text == "S1_L1_Current") {
                if (document.getElementById("lblCurrentL1") != null)
                    document.getElementById("lblCurrentL1").innerHTML = this.Value;
            }
            if (this.Text == "S1_L2_Current") {
                if (document.getElementById("lblCurrentL2") != null)
                    document.getElementById("lblCurrentL2").innerHTML = this.Value;
            }
            if (this.Text == "S1_L3_Current") {
                if (document.getElementById("lblCurrentL3") != null)
                    document.getElementById("lblCurrentL3").innerHTML = this.Value;
            }
            if (this.Text == "S1_L1_Watts") {
                if (document.getElementById("lblWattsL1") != null)
                    document.getElementById("lblWattsL1").innerHTML = this.Value;
            }
            if (this.Text == "S1_L2_Watts") {
                if (document.getElementById("lblWattsL2") != null)
                    document.getElementById("lblWattsL2").innerHTML = this.Value;
            }
            if (this.Text == "S1_L3_Watts") {
                if (document.getElementById("lblWattsL3") != null)
                    document.getElementById("lblWattsL3").innerHTML = this.Value;
            }
            if (this.Text == "S2_L1_N_Voltage") {
                if (document.getElementById("lblS2_L1N") != null)
                    document.getElementById("lblS2_L1N").innerHTML = this.Value;
            }
            if (this.Text == "S2_L2_N_Voltage") {
                if (document.getElementById("lblS2_L2N") != null)
                    document.getElementById("lblS2_L2N").innerHTML = this.Value;
            }
            if (this.Text == "S2_L3_N_Voltage") {
                if (document.getElementById("lblS3_L1N") != null)
                    document.getElementById("lblS3_L1N").innerHTML = this.Value;
            }
            if (this.Text == "S2_L1_L2_Voltage") {
                if (document.getElementById("lblS2_L1L2") != null)
                    document.getElementById("lblS2_L1L2").innerHTML = this.Value;
            }
            if (this.Text == "S2_L2_L3_Voltage") {
                if (document.getElementById("lblS2_L2L3") != null)
                    document.getElementById("lblS2_L2L3").innerHTML = this.Value;
            }
            if (this.Text == "S2_L3_L1_Voltage") {
                if (document.getElementById("lblS2_L1L3") != null)
                    document.getElementById("lblS2_L1L3").innerHTML = this.Value;
            }
            if (this.Text == "S2_L1_Current") {
                if (document.getElementById("lblS2_L1Current") != null)
                    document.getElementById("lblS2_L1Current").innerHTML = this.Value;
            }
            if (this.Text == "S2_L2_Current") {
                if (document.getElementById("lblS2_L2Current") != null)
                    document.getElementById("lblS2_L2Current").innerHTML = this.Value;
            }

            if (this.Text == "S2_L3_Current") {
                if (document.getElementById("lblS2_L3Current") != null)
                    document.getElementById("lblS2_L3Current").innerHTML = this.Value;
            }
            if (this.Text == "S2_L1_Watts") {
                if (document.getElementById("lblS2_L1Watts") != null)
                    document.getElementById("lblS2_L1Watts").innerHTML = this.Value;
            }
            if (this.Text == "S2_L2_Watts") {
                if (document.getElementById("lblS2_L2Watts") != null)
                    document.getElementById("lblS2_L2Watts").innerHTML = this.Value;
            }
            if (this.Text == "S2_L3_Watts") {
                if (document.getElementById("lblS2_L3Watts") != null)
                    document.getElementById("lblS2_L3Watts").innerHTML = this.Value;
            }

            if (this.Text == "S1_Open") {
                if (this.Value == "1") {
                    if (document.getElementById("idS1OC") != null)
                        document.getElementById("idS1OC").style.color = "Green";
                    if (document.getElementById("idS2OC") != null)
                        document.getElementById("idS2OC").style.color = "Gray";
                }
            }
            if (this.Text == "S2_Open") {
                if (this.Value == "1") {
                    if (document.getElementById("idS2OC") != null)
                        document.getElementById("idS2OC").style.color = "Green";
                    if (document.getElementById("idS1OC") != null)
                        document.getElementById("idS1OC").style.color = "Gray";
                }
            }

        });
        GenInput();
        GenOutput();
        GenExpension();
        if (Status == "0")
            UnloadData();
        SetDeviceStatus(CtrMode);
        if (document.getElementById("hdnFirstTimeLoad").value != "1")
            FirstTimeLoadValues();
    }

}
//*******************END*******************************************
//**************UnLoad device*************************************
function UnloadData() {
    if (document.getElementById("hdnTemp") != null)
        document.getElementById("hdnTemp").value = '0';
    if (document.getElementById("hdnBatteryCharger") != null)
        document.getElementById("hdnBatteryCharger").value = '0';
    if (document.getElementById("hdnSpeed") != null)
        document.getElementById("hdnSpeed").value = '0';
    if (document.getElementById("hdnBatteryVolt") != null)
        document.getElementById("hdnBatteryVolt").value = '0';
    if (document.getElementById("hdnFrequency") != null)
        document.getElementById("hdnFrequency").value = '0';
    if (document.getElementById("hdnLLVolt") != null)
        document.getElementById("hdnLLVolt").value = '0';
    if (document.getElementById("hdnLNVolt") != null)
        document.getElementById("hdnLNVolt").value = '0';
    if (document.getElementById("lblCurrent") != null)
        document.getElementById("lblCurrent").innerHTML = '0';
    if (document.getElementById("lblEngineHrs") != null)
        document.getElementById("lblEngineHrs").innerHTML = '00:00:00';
    if (document.getElementById("lblGenTotalWatts") != null)
        document.getElementById("lblGenTotalWatts").innerHTML = '0.0';
    if (document.getElementById("lblTotVA") != null)
        document.getElementById("lblTotVA").innerHTML = '0.0';
    if (document.getElementById("lblTotVAr") != null)
        document.getElementById("lblTotVAr").innerHTML = '0.0';
    if (document.getElementById("lblKWh") != null)
        document.getElementById("lblKWh").innerHTML = '0';
    if (document.getElementById("lblKVAh") != null)
        document.getElementById("lblKVAh").innerHTML = '0';
    if (document.getElementById("lblKVArh") != null)
        document.getElementById("lblKVArh").innerHTML = '0';
    if (document.getElementById("lblPfactor") != null)
        document.getElementById("lblPfactor").innerHTML = '0';
    if (document.getElementById("hdnChrgAlter") != null)
        document.getElementById("hdnChrgAlter").value = '0';
    if (document.getElementById("hdnCoolTemp") != null)
        document.getElementById("hdnCoolTemp").value = '0';
    if (document.getElementById("hdnOilTemp") != null)
        document.getElementById("hdnOilTemp").value = '0';
    if (document.getElementById("hdnOilPres") != null)
        document.getElementById("hdnOilPres").value = '0';
    if (document.getElementById("hdnFuelLvl") != null)
        document.getElementById("hdnFuelLvl").value = '0';
    if (document.getElementById("lblL1_N") != null)
        document.getElementById("lblL1_N").innerHTML = '0';
    if (document.getElementById("lblL2_N") != null)
        document.getElementById("lblL2_N").innerHTML = '0';
    if (document.getElementById("lblL3_N") != null)
        document.getElementById("lblL3_N").innerHTML = '0';
    if (document.getElementById("lblL1_L2") != null)
        document.getElementById("lblL1_L2").innerHTML = '0';
    if (document.getElementById("lblL2_L3") != null)
        document.getElementById("lblL2_L3").innerHTML = '0';
    if (document.getElementById("lblL1_L3") != null)
        document.getElementById("lblL1_L3").innerHTML = '0';
    if (document.getElementById("lblCurrentL1") != null)
        document.getElementById("lblCurrentL1").innerHTML = '0';
    if (document.getElementById("lblCurrentL2") != null)
        document.getElementById("lblCurrentL2").innerHTML = '0';
    if (document.getElementById("lblCurrentL3") != null)
        document.getElementById("lblCurrentL3").innerHTML = '0';
    if (document.getElementById("lblWattsL1") != null)
        document.getElementById("lblWattsL1").innerHTML = '0';
    if (document.getElementById("lblWattsL2") != null)
        document.getElementById("lblWattsL2").innerHTML = '0';
    if (document.getElementById("lblWattsL3") != null)
        document.getElementById("lblWattsL3").innerHTML = '0';
    if (document.getElementById("lblS2_L1N") != null)
        document.getElementById("lblS2_L1N").innerHTML = '0';
    if (document.getElementById("lblS2_L2N") != null)
        document.getElementById("lblS2_L2N").innerHTML = '0';
    if (document.getElementById("lblS3_L1N") != null)
        document.getElementById("lblS3_L1N").innerHTML = '0';
    if (document.getElementById("lblS2_L1L2") != null)
        document.getElementById("lblS2_L1L2").innerHTML = '0';
    if (document.getElementById("lblS2_L2L3") != null)
        document.getElementById("lblS2_L2L3").innerHTML = '0';
    if (document.getElementById("lblS2_L1L3") != null)
        document.getElementById("lblS2_L1L3").innerHTML = '0';
    if (document.getElementById("lblS2_L1Current") != null)
        document.getElementById("lblS2_L1Current").innerHTML = '0';
    if (document.getElementById("lblS2_L2Current") != null)
        document.getElementById("lblS2_L2Current").innerHTML = '0';
    if (document.getElementById("lblS2_L3Current") != null)
        document.getElementById("lblS2_L3Current").innerHTML = '0';
    if (document.getElementById("lblS2_L1Watts") != null)
        document.getElementById("lblS2_L1Watts").innerHTML = '0';
    if (document.getElementById("lblS2_L2Watts") != null)
        document.getElementById("lblS2_L2Watts").innerHTML = '0';
    if (document.getElementById("lblS2_L3Watts") != null)
        document.getElementById("lblS2_L3Watts").innerHTML = '0';
    if (document.getElementById("S2_hdnFrequency") != null)
        document.getElementById("S2_hdnFrequency").value = '0';
    if (document.getElementById("S2_hdnLLVolt") != null)
        document.getElementById("S2_hdnLLVolt").value = '0';
    if (document.getElementById("S2_hdnLNVolt") != null)
        document.getElementById("S2_hdnLNVolt").value = '0';
    if (document.getElementById("lblFuel") != null)
        document.getElementById("lblFuel").innerHTML = 'Fuel Level (0 liter\'s)';
    if (document.getElementById("idS2OC") != null)
        document.getElementById("idS2OC").style.color = "Gray";
    if (document.getElementById("idS1OC") != null)
        document.getElementById("idS1OC").style.color = "Gray";
    if (document.getElementById("lblSupervisorState") != null)
        document.getElementById("lblSupervisorState").innerHTML = '';
    if (document.getElementById("lblGeneratorRating") != null)
        document.getElementById("lblGeneratorRating").innerHTML = '';
    if (document.getElementById("lblBatteryCharger") != null)
        document.getElementById("lblBatteryCharger").innerHTML = '';
    if (document.getElementById("lblS2_PF") != null)
        document.getElementById("lblS2_PF").innerHTML = '0';
    if (document.getElementById("idManual") != null)
        document.getElementById("idManual").style.color = "Gray";
    if (document.getElementById("idStartSelect") != null)
        document.getElementById("idStartSelect").style.color = "Gray";
    if (document.getElementById("idAuto") != null)
        document.getElementById("idAuto").style.color = "Gray";
    if (document.getElementById("idMute") != null)
        document.getElementById("idMute").style.color = "Gray";
}
//*******************END*******************************************

//*******************Load S1 / S2 Expension Data*******************************
function SetDeviceStatus(val) {
    if (val == "0") {
        if (document.getElementById("idStartSelect") != null)
            document.getElementById("idStartSelect").style.color = "Gray";
        if (document.getElementById("idStop") != null)
            document.getElementById("idStop").style.color = "Green";
        if (document.getElementById("idManual") != null)
            document.getElementById("idManual").style.color = "Gray";
        if (document.getElementById("idAuto") != null)
            document.getElementById("idAuto").style.color = "Gray";
        if (document.getElementById("idMute") != null)
            document.getElementById("idMute").style.color = "Gray";
    }
    else if (val == "1") {
        if (document.getElementById("idStartSelect") != null)
            document.getElementById("idStartSelect").style.color = "Gray";
        if (document.getElementById("idStop") != null)
            document.getElementById("idStop").style.color = "Gray";
        if (document.getElementById("idManual") != null)
            document.getElementById("idManual").style.color = "Gray";
        if (document.getElementById("idAuto") != null)
            document.getElementById("idAuto").style.color = "Green";
        if (document.getElementById("idMute") != null)
            document.getElementById("idMute").style.color = "Gray";
    }
    else if (val == "2") {
        if (document.getElementById("idStartSelect") != null)
            document.getElementById("idStartSelect").style.color = "Gray";
        if (document.getElementById("idStop") != null)
            document.getElementById("idStop").style.color = "Gray";
        if (document.getElementById("idManual") != null)
            document.getElementById("idManual").style.color = "Green";
        if (document.getElementById("idAuto") != null)
            document.getElementById("idAuto").style.color = "Gray";
        if (document.getElementById("idMute") != null)
            document.getElementById("idMute").style.color = "Gray";
    }
    else if (val == "4") {
        if (document.getElementById("idStartSelect") != null)
            document.getElementById("idStartSelect").style.color = "Green";
        if (document.getElementById("idStop") != null)
            document.getElementById("idStop").style.color = "Gray";
        if (document.getElementById("idManual") != null)
            document.getElementById("idManual").style.color = "Gray";
        if (document.getElementById("idAuto") != null)
            document.getElementById("idAuto").style.color = "Gray";
        if (document.getElementById("idMute") != null)
            document.getElementById("idMute").style.color = "Gray";
    }
    else if (val == "5") {
        if (document.getElementById("idStartSelect") != null)
            document.getElementById("idStartSelect").style.color = "Gray";
        if (document.getElementById("idStop") != null)
            document.getElementById("idStop").style.color = "Gray";
        if (document.getElementById("idManual") != null)
            document.getElementById("idManual").style.color = "Gray";
        if (document.getElementById("idAuto") != null)
            document.getElementById("idAuto").style.color = "Gray";
        if (document.getElementById("idMute") != null)
            document.getElementById("idMute").style.color = "Gray";
    }
    else if (val == "6") {
        if (document.getElementById("idStartSelect") != null)
            document.getElementById("idStartSelect").style.color = "Gray";
        if (document.getElementById("idStop") != null)
            document.getElementById("idStop").style.color = "Gray";
        if (document.getElementById("idManual") != null)
            document.getElementById("idManual").style.color = "Gray";
        if (document.getElementById("idAuto") != null)
            document.getElementById("idAuto").style.color = "Gray";
        if (document.getElementById("idMute") != null)
            document.getElementById("idMute").style.color = "Gray";
    }
    else {
        if (document.getElementById("idStartSelect") != null)
            document.getElementById("idStartSelect").style.color = "Gray";
        if (document.getElementById("idStop") != null)
            document.getElementById("idStop").style.color = "Gray";
        if (document.getElementById("idManual") != null)
            document.getElementById("idManual").style.color = "Gray";
        if (document.getElementById("idAuto") != null)
            document.getElementById("idAuto").style.color = "Gray";
        if (document.getElementById("idMute") != null)
            document.getElementById("idMute").style.color = "Gray";
    }
}
//*******************END*******************************

//*******************Load Input Data*******************************
function GenInput() {
    $.ajax({
        type: "POST",
        url: "Dashboard.aspx/GetInputValues",
        contentType: "application/json; charset=utf-8",
        data: '',
        dataType: "json",
        success: AjaxGenInputSucceeded,
        error: AjaxGenInputFailed
    });
}
function AjaxGenInputSucceeded(result) {
    GenInputLoad(result);
}
function AjaxGenInputFailed(result) {
    alert('Failed to load');
}
function GenInputLoad(result) {
    var items = JSON.parse(result.d);
    BindGenInput(items);
}
function BindGenInput(GenInputList) {
    var counter = 0;
    var TableCreate = "";
    $('#grdGenInput').empty();
    TableCreate += '<table class="table table-bordered" style="border-collapse:collapse;background-color: #404040; color: white;" cellspacing="0" align="Center" rules="all" border="1"><tr><th align="center"><strong>Input</strong></th><th align="center"><strong>Description</strong></th><th align="center"><strong>Active</strong></th><th align="center"><strong>State</strong></th></tr>';
    $(GenInputList).each(function () {
        if (this.Text == "InputType") {
            TableCreate += '<tr><td align="center" style="font-weight:bold;">' + this.Value + '</td>';
        }
        if (this.Text == "InputDescription") {
            TableCreate += '<td>' + this.Value + '</td>';
        }
        if (this.Text == "InputActiveStatus") {

            TableCreate += '<td align="center"><img src="' + (this.Value == "0" ? "../images/In_Active.png" : "../images/Active.png") + '" Style="width: 15px;"></td>';
        }
        if (this.Text == "InputState") {
            TableCreate += '<td align="center"><img src="' + (this.Value == "0" ? "../images/Switch_Off.png" : "../images/Switch_On.png") + '" Style="width: 50px;"></td>';
        }
    });
    TableCreate += '</table>';
    $('#grdGenInput').append(TableCreate);
}
//*******************END******************************************
//*******************Load Output Data*******************************
function GenOutput() {
    $.ajax({
        type: "POST",
        url: "Dashboard.aspx/GetOutputValues",
        contentType: "application/json; charset=utf-8",
        data: '{}',
        dataType: "json",
        success: AjaxGenOutputSucceeded,
        error: AjaxGenOutputFailed
    });
}
function AjaxGenOutputSucceeded(result) {
    GenOutputLoad(result);
}
function AjaxGenOutputFailed(result) {
    alert('Failed to load');
}
function GenOutputLoad(result) {
    var items = JSON.parse(result.d);
    BindGenOutput(items);
}
function BindGenOutput(GenOutputList) {
    var counter = 0;
    var TableCreate = "";
    $('#grdGenOutput').empty();
    TableCreate += '<table class="table table-bordered" style="border-collapse:collapse;background-color: #404040; color: white;" cellspacing="0" align="Center" rules="all" border="1"><tr><th align="center"><strong>Output</strong></th><th align="center"><strong>Description</strong></th><th align="center"><strong>Active</strong></th><th align="center"><strong>State</strong></th></tr>';
    $(GenOutputList).each(function () {
        if (this.Text == "OutputType") {
            TableCreate += '<tr><td align="center" style="font-weight:bold;">' + this.Value + '</td>';
        }
        if (this.Text == "OutputDescription") {
            TableCreate += '<td>' + this.Value + '</td>';
        }
        if (this.Text == "OutputActiveStatus") {

            TableCreate += '<td align="center"><img src="' + (this.Value == "0" ? "../images/In_Active.png" : "../images/Active.png") + '" Style="width: 15px;"></td>';
        }
        if (this.Text == "OutputState") {
            TableCreate += '<td align="center"><img src="' + (this.Value == "0" ? "../images/Switch_Off.png" : "../images/Switch_On.png") + '" Style="width: 50px;"></td>';
        }
    });
    TableCreate += '</table>';
    $('#grdGenOutput').append(TableCreate);
}
//*******************END******************************************

//*******************Load S1 / S2 Expension Data*******************************
function GenExpension() {
    $.ajax({
        type: "POST",
        url: "Dashboard.aspx/GetExpension",
        contentType: "application/json; charset=utf-8",
        data: '{}',
        dataType: "json",
        success: AjaxGenExpensionSucceeded,
        error: AjaxGenExpensionFailed
    });
}
function AjaxGenExpensionSucceeded(result) {
    GenExpensionLoad(result);
}
function AjaxGenExpensionFailed(result) {
    alert('Failed to load');
}
function GenExpensionLoad(result) {
    var items = JSON.parse(result.d);
    BindGenExpension(items);
}
function BindGenExpension(GenExpensionList) {
    var counter = 0;
    var TableCreate = "";
    $('#grdExpension').empty();
    TableCreate += '<table class="table table-bordered" style="border-collapse:collapse;background-color: #404040; color: white;" cellspacing="0" align="Center" rules="all" border="1"><tr><th align="center"><strong>Input</strong></th><th align="center"><strong>Description</strong></th><th align="center"><strong>Active</strong></th><th align="center"><strong>State</strong></th></tr>';
    $(GenExpensionList).each(function () {
        if (this.Text == "InputType") {
            TableCreate += '<tr><td align="center" style="font-weight:bold;">' + this.Value + '</td>';
        }
        if (this.Text == "InputDescription") {
            TableCreate += '<td align="left">' + this.Value + '</td>';
        }
        if (this.Text == "InputActiveStatus") {

            TableCreate += '<td align="center"><img src="' + (this.Value == "0" ? "../images/In_Active.png" : "../images/Active.png") + '" Style="width: 15px;"></td>';
        }
        if (this.Text == "InputState") {
            TableCreate += '<td align="center"><img src="' + (this.Value == "0" ? "../images/Switch_Off.png" : "../images/Switch_On.png") + '" Style="width: 50px;"></td>';
        }
    });
    TableCreate += '</table>';
    $('#grdExpension').append(TableCreate);
}
//*******************END******************************************

//*******************Load SLD Data*******************************
function GenMainSLDData(BoxID, UserID) {
    var isbusness;
    $.ajax({
        type: "POST",
        url: "Dashboard_SLD.aspx/BindSLDData",
        contentType: "application/json; charset=utf-8",
        data: '{"BoxID":"' + BoxID + '","UserID":"' + UserID + '"}',
        dataType: "json",
        success: AjaxSLDDataSucceeded,
        error: AjaxSLDDataFailed
    });
}
function AjaxSLDDataSucceeded(result) {
    SLDDataLoad(result);
}
function AjaxSLDDataFailed(result) {
    alert('Failed to load');
}
function SLDDataLoad(result) {
    var items = JSON.parse(result.d);
    BindSLDData1(items);
}
function BindSLDData1(GenMainSLDList) {
    var MainStatus = 0;
    var GenStatus = 0;
    var MainOpenStatus = 0;
    var GenOpenStatus = 0;
    var TableCreate = "";
    var TableCreate1 = "";
    var DevName = "";
    var GenID = "";
    var MainID = "";
    var GenName = "";
    var MainName = "";
    var MainLUStatus = 0;
    var GenLUStatus = 0;
    //$('#divSLDDiagram').empty();
    TableCreate += '<h2 style="border-radius: 9px; border-bottom-left-radius: 0px;"><asp:Label ID="Label21" runat="server" Text="SLD"></asp:Label></h2><table class="table table-dark"><tr style="text-align: center;">';
    $(GenMainSLDList).each(function () {
        if (this.Text == "MainOpenStatus") {
            MainOpenStatus = this.Value;
        }
        if (this.Text == "GenOpenStatus") {
            GenOpenStatus = this.Value;
        }
        if (this.Text == "MainStatus") {
            MainStatus = this.Value;
        }
        if (this.Text == "GenStatus") {
            GenStatus = this.Value;
        }
        if (this.Text == "MainDeviceID") {
            MainID = this.Value;
        }
        if (this.Text == "GenDeviceID") {
            GenID = this.Value;
        }
        if (this.Text == "MainDeviceName") {
            DevName += this.Value;
            MainName = this.Value;
        }
        if (this.Text == "GenDeviceName") {
            DevName += this.Value;
            GenName = this.Value;
        }
        if (this.Text == "MainLastUpdateStatus") {
            MainLUStatus = this.Value;
        }
        if (this.Text == "GenlastUpdateStatus") {
            GenLUStatus = this.Value;
        }
        //Fill SLD Valus
        var a = document.getElementById('hlnkGenName');
        if (a != null) {
            if (GenName != "-" && GenName != null) {
                a.href = "Dashboard.aspx?DeviceID=" + GenID + "&DeviceName=" + GenName + "&DeviceType=1";
                a.innerHTML = GenName;
            }
            else {
                a.innerHTML = "-";
                a.style.pointerEvents = "none";
                a.style.cursor = "default";
            }
        }


        var a1 = document.getElementById('hlnkMainName');
        if (a1 != null) {
            if (MainName != "-" && MainName != null) {
                a1.href = "Dashboard.aspx?DeviceID=" + MainID + "&DeviceName=" + MainName + "&DeviceType=2";
                a1.innerHTML = MainName;
            }
            else {
                a1.innerHTML = "-";
                a1.style.pointerEvents = "none";
                a1.style.cursor = "default";
            }
        }


        //if (document.getElementById("lnkGenName") != null)
        //    document.getElementById("hlnkGenName").setAttribute("href", "Dashboard.aspx?DeviceID=" + GenID + "&DeviceName=" + GenName + "&DeviceType=1");

        if (this.Text == "MainDeviceName") {
            if (document.getElementById("Label11") != null)
                document.getElementById("Label11").innerHTML = this.Value;
            if (document.getElementById("lblDeviceName") != null)
                document.getElementById("lblDeviceName").innerHTML = this.Value;
        }
        if (this.Text == "MainOriginTime") {
            if (document.getElementById("lblreportedon") != null)
                document.getElementById("lblreportedon").innerHTML = this.Value;
        }
        if (this.Text == "GenDeviceName") {
            if (document.getElementById("lnkGenName") != null)
                document.getElementById("lnkGenName").innerText = this.Value;
            if (document.getElementById("lblGenDevName") != null)
                document.getElementById("lblGenDevName").innerText = this.Value;
        }
        if (this.Text == "GenOriginTime") {
            if (document.getElementById("lblGenDevLastReport") != null)
                document.getElementById("lblGenDevLastReport").innerHTML = this.Value;
        }
        if (this.Text == "GenLL_Volt") {
            if (document.getElementById("lblSLD_Gen_L_L") != null)
                document.getElementById("lblSLD_Gen_L_L").innerHTML = this.Value;
        }
        if (this.Text == "GenLN_Volt") {
            if (document.getElementById("lblSLD_Gen_L_N") != null)
                document.getElementById("lblSLD_Gen_L_N").innerHTML = this.Value;
        }
        if (this.Text == "GenCurrent") {
            if (document.getElementById("lblSLD_Gen_Current") != null)
                document.getElementById("lblSLD_Gen_Current").innerHTML = this.Value;
        }
        if (this.Text == "GenFrequency") {
            if (document.getElementById("lblSLD_Gen_Frequency") != null)
                document.getElementById("lblSLD_Gen_Frequency").innerHTML = this.Value;
        }
        if (this.Text == "GenTotalWatts") {
            if (document.getElementById("lblSLD_Gen_kW") != null)
                document.getElementById("lblSLD_Gen_kW").innerHTML = this.Value;
        }
        if (this.Text == "GenFuelLevel") {
            var num = this.Value;
            var n = (parseFloat(num) / 100 * 2000);
            if (document.getElementById("lblSLD_Gen_FuelLlevel") != null)
                document.getElementById("lblSLD_Gen_FuelLlevel").innerHTML = '' + String(n) + ' liter\'s';
        }
        if (this.Text == "GenEngRunTime") {
            if (document.getElementById("lblSLD_Gen_EngRunning") != null)
                document.getElementById("lblSLD_Gen_EngRunning").innerHTML = this.Value;
        }

        if (this.Text == "MainLL_Volt") {
            if (document.getElementById("lblSLD_Main_L_L") != null)
                document.getElementById("lblSLD_Main_L_L").innerHTML = this.Value;
        }
        if (this.Text == "MainLN_Volt") {
            if (document.getElementById("lblSLD_Main_L_N") != null)
                document.getElementById("lblSLD_Main_L_N").innerHTML = this.Value;
        }
        if (this.Text == "MainCurrent") {
            if (document.getElementById("lblSLD_Main_Current") != null)
                document.getElementById("lblSLD_Main_Current").innerHTML = this.Value;
        }
        if (this.Text == "MainFrequency") {
            if (document.getElementById("lblSLD_Main_Frequency") != null)
                document.getElementById("lblSLD_Main_Frequency").innerHTML = this.Value;
        }
        if (this.Text == "MainTotalWatts") {
            if (document.getElementById("lblSLD_Main_kW") != null)
                document.getElementById("lblSLD_Main_kW").innerHTML = this.Value;
        }





        if (this.Text == "MainL1N_Volt") {
            if (document.getElementById("lblSLD_Main_L1N") != null)
                document.getElementById("lblSLD_Main_L1N").innerHTML = this.Value;
        }
        if (this.Text == "MainL2N_Volt") {
            if (document.getElementById("lblSLD_Main_L2N") != null)
                document.getElementById("lblSLD_Main_L2N").innerHTML = this.Value;
        }
        if (this.Text == "MainL3N_Volt") {
            if (document.getElementById("lblSLD_Main_L3N") != null)
                document.getElementById("lblSLD_Main_L3N").innerHTML = this.Value;
        }
        if (this.Text == "MainL1L2_Volt") {
            if (document.getElementById("lblSLD_Main_L1L2") != null)
                document.getElementById("lblSLD_Main_L1L2").innerHTML = this.Value;
        }
        if (this.Text == "MainL2L3_Volt") {
            if (document.getElementById("lblSLD_Main_L2L3") != null)
                document.getElementById("lblSLD_Main_L2L3").innerHTML = this.Value;
        }
        if (this.Text == "MainL1L3_Volt") {
            if (document.getElementById("lblSLD_Main_L1L3") != null)
                document.getElementById("lblSLD_Main_L1L3").innerHTML = this.Value;
        }
        if (this.Text == "MainL1_Cur") {
            if (document.getElementById("lblSLD_Main_L1") != null)
                document.getElementById("lblSLD_Main_L1").innerHTML = this.Value;
        }
        if (this.Text == "MainL2_Cur") {
            if (document.getElementById("lblSLD_Main_L2") != null)
                document.getElementById("lblSLD_Main_L2").innerHTML = this.Value;
        }
        if (this.Text == "MainL3_Cur") {
            if (document.getElementById("lblSLD_Main_L3") != null)
                document.getElementById("lblSLD_Main_L3").innerHTML = this.Value;
        }
        if (this.Text == "GenL1N_Volt") {
            if (document.getElementById("lblSLD_Gen_L1N") != null)
                document.getElementById("lblSLD_Gen_L1N").innerHTML = this.Value;
        }
        if (this.Text == "GenL2N_Volt") {
            if (document.getElementById("lblSLD_Gen_L2N") != null)
                document.getElementById("lblSLD_Gen_L2N").innerHTML = this.Value;
        }
        if (this.Text == "GenL3N_Volt") {
            if (document.getElementById("lblSLD_Gen_L3N") != null)
                document.getElementById("lblSLD_Gen_L3N").innerHTML = this.Value;
        }
        if (this.Text == "GenL1L2_Volt") {
            if (document.getElementById("lblSLD_Gen_L1L2") != null)
                document.getElementById("lblSLD_Gen_L1L2").innerHTML = this.Value;
        }
        if (this.Text == "GenL2L3_Volt") {
            if (document.getElementById("lblSLD_Gen_L2L3") != null)
                document.getElementById("lblSLD_Gen_L2L3").innerHTML = this.Value;
        }
        if (this.Text == "GenL1L3_Volt") {
            if (document.getElementById("lblSLD_Gen_L1L3") != null)
                document.getElementById("lblSLD_Gen_L1L3").innerHTML = this.Value;
        }
        if (this.Text == "GenL1_Cur") {
            if (document.getElementById("lblSLD_Gen_L1") != null)
                document.getElementById("lblSLD_Gen_L1").innerHTML = this.Value;
        }
        if (this.Text == "GenL2_Cur") {
            if (document.getElementById("lblSLD_Gen_L2") != null)
                document.getElementById("lblSLD_Gen_L2").innerHTML = this.Value;
        }
        if (this.Text == "GenL3_Cur") {
            if (document.getElementById("lblSLD_Gen_L3") != null)
                document.getElementById("lblSLD_Gen_L3").innerHTML = this.Value;
        }
        //if (MainOpenStatus == "0" && GenOpenStatus == "0") {
        //    TableCreate1 = '<td><img src="../images/SLD_Offline.png"></td>';
        //}
        //else if (MainOpenStatus == "1" && GenOpenStatus == "0") {
        //    if (MainStatus == "1") {
        //        TableCreate1 = '<td><img src="../images/SLD_Main_Online.png"></td>';
        //    }
        //    else if (MainStatus == "2") {
        //        TableCreate1 = '<td><img src="../images/SLD_Main_Warning.png"></td>';
        //    }
        //    else {
        //        TableCreate1 = '<td><img src="../images/SLD_Offline.png"></td>';
        //    }
        //}
        //else if (MainOpenStatus == "0" && GenOpenStatus == "1") {
        //    if (GenStatus == "1") {
        //        TableCreate1 = '<td><img src="../images/SLD_Gen_Running.png"></td>';
        //    }
        //    else if (GenStatus == "11") {
        //        TableCreate1 = '<td><img src="../images/SLD_Gen_Information.png"></td>';
        //    }
        //    else if (GenStatus == "2") {
        //        TableCreate1 = '<td><img src="../images/SLD_Gen_Warning.png"></td>';
        //    }
        //    else if (GenStatus == "3") {
        //        TableCreate1 = '<td><img src="../images/SLD_Gen_ElectricalTrip.png"></td>';
        //    }
        //    else if (GenStatus == "4") {
        //        TableCreate1 = '<td><img src="../images/SLD_Gen_Shutdown.png"></td>';
        //    }
        //    else if (GenStatus == "5") {
        //        TableCreate1 = '<td><img src="../images/SLD_Gen_Shutdown.png"></td>';
        //    }
        //    else if (GenStatus == "6") {
        //        TableCreate1 = '<td><img src="../images/SLD_Gen_Information.png"></td>';
        //    }
        //    else {
        //        TableCreate1 = '<td><img src="../images/SLD_Offline.png"></td>';
        //    }
        //}
        //TableCreate1 += '</tr><tr><td><asp:Label runat="server" ID="lblSLDSelDevice1" Text="' + DevName + '"></asp:Label></td></tr>';

        if (this.Text == "MainStatus") {
            var imgmain = document.getElementById('imgMainStatus');
            if (imgmain != null)
                imgmain.src = this.Value;
        }

        if (this.Text == "GenStatus") {
            var imgmain1 = document.getElementById('imgGenStatus');
            if (imgmain1 != null)
                imgmain1.src = this.Value;
        }
        if (this.Text == "DevOpenCloseStatus") {
            var imgmain2 = document.getElementById('imgDevOpenCloseStatus');
            if (imgmain2 != null)
                imgmain2.src = this.Value;
        }


    });
    TableCreate += TableCreate1;
    TableCreate += '</table>';
    //$('#divSLDDiagram').append(TableCreate);
    //if (Status == "0")
    //    UnloadData();
    //SetDeviceStatus(CtrMode);
    UnloadSLDData(MainLUStatus, GenLUStatus);
}
function UnloadSLDData(MainStatus, GenStatus) {

    if (GenStatus == "0") {
        if (document.getElementById("lblSLD_Gen_L_L") != null)
            document.getElementById("lblSLD_Gen_L_L").innerHTML = "0";
        if (document.getElementById("lblSLD_Gen_L_N") != null)
            document.getElementById("lblSLD_Gen_L_N").innerHTML = "0";
        if (document.getElementById("lblSLD_Gen_Current") != null)
            document.getElementById("lblSLD_Gen_Current").innerHTML = "0";
        if (document.getElementById("lblSLD_Gen_Frequency") != null)
            document.getElementById("lblSLD_Gen_Frequency").innerHTML = "0";
        if (document.getElementById("lblSLD_Gen_kW") != null)
            document.getElementById("lblSLD_Gen_kW").innerHTML = "0";
        if (document.getElementById("lblSLD_Gen_FuelLlevel") != null)
            document.getElementById("lblSLD_Gen_FuelLlevel").innerHTML = "0";
        if (document.getElementById("lblSLD_Gen_EngRunning") != null)
            document.getElementById("lblSLD_Gen_EngRunning").innerHTML = "0";
        var imgmain1 = document.getElementById('imgGenStatus');
        if (imgmain1 != null)
            imgmain1.src = "../Images/Gen.png";
    }

    if (MainStatus == "0") {
        if (document.getElementById("lblSLD_Main_L_L") != null)
            document.getElementById("lblSLD_Main_L_L").innerHTML = "0";
        if (document.getElementById("lblSLD_Main_L_N") != null)
            document.getElementById("lblSLD_Main_L_N").innerHTML = "0";
        if (document.getElementById("lblSLD_Main_Current") != null)
            document.getElementById("lblSLD_Main_Current").innerHTML = "0";
        if (document.getElementById("lblSLD_Main_Frequency") != null)
            document.getElementById("lblSLD_Main_Frequency").innerHTML = "0";
        if (document.getElementById("lblSLD_Main_kW") != null)
            document.getElementById("lblSLD_Main_kW").innerHTML = "0";
        var imgmain = document.getElementById('imgMainStatus');
        if (imgmain != null)
            imgmain.src = "../Images/Transformer_Offline.png";
    }
    if (MainStatus == "0" && GenStatus == "0") {
        var imgmain2 = document.getElementById('imgDevOpenCloseStatus');
        if (imgmain2 != null)
            imgmain2.src = "../Images/Main_Gen_Open.png";
    }
}
//*******************END******************************************

function LoadChart() {
    ChartGauFreqgauge.value = document.getElementById("hdnFrequency").value;
    ChartGauGenLinetoNeutral.value = document.getElementById("hdnLNVolt").value;
    ChartGauGenLinetoLine.value = document.getElementById("hdnLLVolt").value;
    ChartGauSpeedgauge.value = document.getElementById("hdnSpeed").value;
    ChartBatteryCharger.value = document.getElementById("hdnBatteryCharger").value;
    ChartGauBatteryVoltage.value = document.getElementById("hdnBatteryVolt").value;
    ChartGauChargeAlternator.value = document.getElementById("hdnChrgAlter").value;
    ChartGauCoolantTemperature.value = document.getElementById("hdnCoolTemp").value;
    ChartGauOilTemperature.value = document.getElementById("hdnOilTemp").value;
    ChartGauOilPressure.value = (parseInt(document.getElementById("hdnOilPres").value) / 100);
    ChartGauFuelLevel.value = document.getElementById("hdnFuelLvl").value;
}