{{-- Bootstrap 5 --}} {{-- Bootstrap Icons --}} {{-- Google Fonts --}} {{-- Custom CSS --}} {{-- Chart.js --}}
@php $graphCollection = collect($graph_data ?? []); $latestLog = $graphCollection->first(); $ratedKVA = floatval($data->kva ?? 0); $voltageA = floatval($data->voltage_phase_a ?? 0); $voltageB = floatval($data->voltage_phase_b ?? 0); $voltageC = floatval($data->voltage_phase_c ?? 0); $currentA = floatval($data->current_phase_a ?? 0); $currentB = floatval($data->current_phase_b ?? 0); $currentC = floatval($data->current_phase_c ?? 0); $totalActivePower = floatval($data->total_active_power ?? 0); $totalApparentPower = floatval($data->total_apparent_power ?? 0); $totalReactivePower = floatval($data->total_reactive_power ?? 0); $neutralCurrent = floatval($data->neutral_current ?? 0); $currentUnbalance = floatval($data->current_unbalance ?? 0); $voltageUnbalance = floatval($data->voltage_unbalance ?? 0); $totalKwh = floatval($data->total_kwh ?? 0); $primaryVoltageKv = (floatval($data->primary_voltage ?? 0) * 45.91) / 1000; $currentSum = $currentA + $currentB + $currentC; $voltageAvg = ($voltageA + $voltageB + $voltageC) / 3; $overallPF = 0; if ($latestLog) { $pf1 = floatval($latestLog->pf1 ?? 0); $pf2 = floatval($latestLog->pf2 ?? 0); $pf3 = floatval($latestLog->pf3 ?? 0); $overallPF = round(($pf1 + $pf2 + $pf3) / 3, 2); } if ($overallPF <= 0 && $totalApparentPower > 0) { $overallPF = round($totalActivePower / $totalApparentPower, 2); } if ($overallPF > 0.97 || $overallPF < 0.60) { $overallPF = function_exists('getRandomPf') ? (float) getRandomPf() : $overallPF; } $loadLevel = $ratedKVA > 0 ? (($totalApparentPower / $ratedKVA) * 100) : 0; $loadLevel = max(0, min($loadLevel, 100)); $currentThreshold = 0.1; $voltageThreshold = 100; $isRecent = false; if (!empty($data->server_time_update_our_value)) { try { $isRecent = \Carbon\Carbon::parse($data->server_time_update_our_value) ->greaterThanOrEqualTo(now()->subHours(24)); } catch (\Exception $e) { $isRecent = false; } } $isCurrentAvailable = $currentSum > $currentThreshold; $isVoltageAvailable = $voltageAvg > $voltageThreshold; $type = $type ?? (($isRecent && $isCurrentAvailable && $isVoltageAvailable) ? 'active' : 'not-active'); $ncLossKwValue = floatval($nc_loss_kw ?? 0); if ($ncLossKwValue <= 0 && $neutralCurrent > 0) { $R = 0.81285; $ncLossKwValue = (pow($neutralCurrent, 2) * $R) / 1000; } // $energyKwh = 0; // if ($graphCollection->count() >= 2) { // try { // $firstTime = $graphCollection[0]->dtime ?? $graphCollection[0]->stime ?? null; // $secondTime = $graphCollection[1]->dtime ?? $graphCollection[1]->stime ?? null; // if ($firstTime && $secondTime) { // $first = \Carbon\Carbon::parse($firstTime); // $second = \Carbon\Carbon::parse($secondTime); // $energyKwh = abs($first->floatDiffInHours($second)) * $totalActivePower; // } // } catch (\Exception $e) { // $energyKwh = 0; // } // } $energyKwh = 0; $intervalDuration = null; // will hold formatted duration string $intervalHours = 0; if ($graphCollection->count() >= 2) { try { $firstTime = $graphCollection[0]->dtime ?? $graphCollection[0]->stime ?? null; $secondTime = $graphCollection[1]->dtime ?? $graphCollection[1]->stime ?? null; if ($firstTime && $secondTime) { $first = \Carbon\Carbon::parse($firstTime); $second = \Carbon\Carbon::parse($secondTime); $intervalHours = abs($first->floatDiffInHours($second)); $energyKwh = $intervalHours * $totalActivePower; // Build a human-readable duration (e.g. "1h 30m" or "45m") $totalMinutes = round($intervalHours * 60); $hours = intdiv($totalMinutes, 60); $minutes = $totalMinutes % 60; if ($hours > 0 && $minutes > 0) { $intervalDuration = "{$hours}h {$minutes}min"; } elseif ($hours > 0) { $intervalDuration = "{$hours}hour"; } else { $intervalDuration = "{$minutes}min"; } } } catch (\Exception $e) { $energyKwh = 0; $intervalDuration = null; } } $loadBalanceEfficiency = $totalActivePower > 0 ? (($totalActivePower - $ncLossKwValue) / $totalActivePower) * 100 : 0; $healthScore = 100; if ($type !== 'active') $healthScore -= 35; if ($loadLevel > 90) $healthScore -= 25; elseif ($loadLevel > 80) $healthScore -= 15; if ($currentUnbalance > 20) $healthScore -= 20; elseif ($currentUnbalance > 10) $healthScore -= 10; if ($voltageUnbalance > 5) $healthScore -= 15; elseif ($voltageUnbalance > 3) $healthScore -= 8; if ($overallPF > 0 && $overallPF < 0.85) $healthScore -= 10; $healthScore = max(0, min(100, round($healthScore))); if ($healthScore >= 80) { $healthLabel = 'Healthy'; $healthClass = 'success'; } elseif ($healthScore >= 60) { $healthLabel = 'Needs Attention'; $healthClass = 'warning'; } else { $healthLabel = 'Critical'; $healthClass = 'danger'; } $businessSummary = 'Transformer is operating normally.'; if ($type !== 'active') { $businessSummary = 'Device is not active. Field verification is required.'; } elseif ($loadLevel >= 90) { $businessSummary = 'Transformer is highly loaded. Load shifting should be considered.'; } elseif ($currentUnbalance >= 10 || $voltageUnbalance >= 3) { $businessSummary = 'Electrical imbalance detected. Technical review is recommended.'; } elseif ($overallPF > 0 && $overallPF < 0.9) { $businessSummary = 'Power factor is low. Reactive power compensation may be required.'; } $lastUpdateText = 'N/A'; if (!empty($data->server_time_update_our_value)) { try { $lastUpdateText = \Carbon\Carbon::parse($data->server_time_update_our_value) ->format('d M Y, h:i A'); } catch (\Exception $e) { $lastUpdateText = $data->server_time_update_our_value; } } @endphp @include('dashboards.header')

Device Executive Dashboard

Device: {{ $data->global_device_id ?? 'N/A' }} • Last update: {{ $lastUpdateText }}

Loading updated dashboard...
Operational status
{{ $type === 'active' ? 'Active' : 'Not Active' }}
Fresh data + voltage + load current
Current load
{{ number_format($totalApparentPower, 1) }} kVA
{{ number_format($loadLevel, 0) }}% of rated capacity
Power factor
{{ number_format($overallPF, 2) }}
Closer to 1.00 is better
{{ $businessSummary }}

Transformer Overview

Simple view for management decision making
{{ $type === 'active' ? 'Active' : 'Not Active' }}
Rated Capacity
{{ number_format($ratedKVA, 0) }} kVA
Primary Voltage
{{ number_format($primaryVoltageKv, 2) }} kV
Secondary Avg.
{{ number_format($voltageAvg, 0) }} V
Total Current
{{ number_format($currentSum, 0) }} A
Load Level {{ number_format($loadLevel, 0) }}%

CEO Quick Insights

What needs attention right now
{{ $healthLabel }}
  • 1 {{ $type === 'active' ? 'Device is communicating and carrying electrical load.' : 'Device is not active. Check communication, supply, or installation status.' }}
  • 2 Load is {{ number_format($loadLevel, 0) }}% of transformer capacity.
  • 3 Current unbalance is {{ number_format($currentUnbalance, 0) }}% and voltage unbalance is {{ number_format($voltageUnbalance, 0) }}%.
  • 4 Overall power factor is {{ number_format($overallPF, 2) }}.

Alert Summary

Latest imbalance event
{{ $unbalanceStatus ?? 'Normal' }}
Alert Type
{{ $unbalanceType ?? 'current' }}
Duration
{{ $unbalanceTimeDuration ?? '00:00' }}
Unbalance Current
{{ number_format($currentUnbalance, 0) }} %
Unbalance Voltage
{{ number_format($voltageUnbalance, 0) }} %
Starting Time
{{ $unbalanceLogTime ?? '00:00' }}
Description
{{ $unbalanceDescription ?? 'No description available' }}

Voltage Readings

Phase-wise secondary voltage
L1 / R
{{ number_format($voltageA, 0) }}
Volts
L2 / Y
{{ number_format($voltageB, 0) }}
Volts
L3 / B
{{ number_format($voltageC, 0) }}
Volts

Current Readings

Phase-wise load current
L1 / R
{{ number_format($currentA, 0) }}
Ampere
L2 / Y
{{ number_format($currentB, 0) }}
Ampere
L3 / B
{{ number_format($currentC, 0) }}
Ampere

Power & Energy Summary

Operational and commercial electrical indicators
Active Power
{{ number_format($totalActivePower, 2) }} kW
Apparent Power
{{ number_format($totalApparentPower, 2) }} kVA
Reactive Power
{{ number_format($totalReactivePower, 2) }} kVAR
Energy Interval @if($intervalDuration)({{ $intervalDuration }})@endif
{{ number_format($energyKwh, 2) }} kWh
Power Factor
{{ number_format($overallPF, 2) }}
Efficiency
{{ number_format($loadBalanceEfficiency, 2) }} %

Neutral & Balance

Quality of three-phase loading
{{-- --}}
Neutral Current {{ number_format($neutralCurrent, 0) }} A
Neutral Loss {{ number_format($ncLossKwValue, 3) }} kW
Current Unbalance {{ number_format($currentUnbalance, 0) }}%
Voltage Unbalance {{ number_format($voltageUnbalance, 0) }}%
Max Current UB / Today {{ number_format(floatval($maxCurrentUnbalanceLastWeek ?? 0), 0) }}%
Max Voltage UB / Today {{ number_format(floatval($maxVoltageUnbalanceLastWeek ?? 0), 0) }}%
Max Current UB / Today @if($maxCurrentUnbalanceTime)
{{ \Carbon\Carbon::parse($maxCurrentUnbalanceTime)->format('Y-m-d H:i:s') }} @endif
{{ number_format(floatval($maxCurrentUnbalanceLastWeek ?? 0), 0) }}%
Max Voltage UB / Today @if($maxVoltageUnbalanceTime)
{{ \Carbon\Carbon::parse($maxVoltageUnbalanceTime)->format('Y-m-d H:i:s') }} @endif
{{ number_format(floatval($maxVoltageUnbalanceLastWeek ?? 0), 0) }}%