@extends('layouts.app') @section('center')
{{--
{{--
{{-- Voltages --}} {{-- Currents --}} {{-- Power Factors --}} {{-- KWH --}} @if($data && $data->count() > 0) @php /* |------------------------------------------------------ | $prev_record_time = Unix timestamp of the last row | on the previous page (null on page 1). | Seeded by the controller so cross-page intervals | are always correct. |------------------------------------------------------ */ $prev_time = $prev_record_time ?? null; $cumulative = 0; @endphp @foreach($data as $row) @php /*-------------------------------------------------- | 1. V / I — same fields as currentLog --------------------------------------------------*/ $v1 = (float)($row->v1 ?? 0); $v2 = (float)($row->v2 ?? 0); $v3 = (float)($row->v3 ?? 0); $i1 = (float)($row->i1 ?? 0); $i2 = (float)($row->i2 ?? 0); $i3 = (float)($row->i3 ?? 0); /*-------------------------------------------------- | 2. PF — mirror currentLog exactly: | WaterScada → getRandomPf() (display only) | but use REAL pf for kWh formula | Normal → actual pf1/pf2/pf3 --------------------------------------------------*/ $pf1_real = max(-1, min(1, (float)($row->pf1 ?? 0))); $pf2_real = max(-1, min(1, (float)($row->pf2 ?? 0))); $pf3_real = max(-1, min(1, (float)($row->pf3 ?? 0))); /*-------------------------------------------------- | 3. Time interval = diff between last 2 entries | Uses dtime (packet time), same as currentLog --------------------------------------------------*/ $dtime = $row->dtime ?? null; $current_time = ($dtime && $dtime !== '0000-00-00 00:00:00') ? strtotime($dtime) : null; if ($prev_time !== null && $current_time !== null) { $diff_seconds = abs($current_time - $prev_time); $diff_minutes = $diff_seconds / 60; $interval_hours = $diff_minutes / 60; } else { $diff_seconds = 0; $diff_minutes = 0; $interval_hours = 0; } if ($current_time) $prev_time = $current_time; /*-------------------------------------------------- | 4. kWh = V * I * PF * interval_hours (per phase) | kW Load = (V1*I1*PF1 + V2*I2*PF2 + V3*I3*PF3) / 1000 | kWh_interval = kW_load * interval_hours --------------------------------------------------*/ $p1 = $v1 * $i1 * $pf1_real; $p2 = $v2 * $i2 * $pf2_real; $p3 = $v3 * $i3 * $pf3_real; $kw_load = ($p1 + $p2 + $p3) / 1000; $kwh_interval = $kw_load * $interval_hours; $cumulative += $kwh_interval; @endphp {{-- Time --}} {{-- GlobalID — blue if dmdt_phase==1, same as currentLog --}} {{-- Timing — same logic as currentLog --}} {{-- Voltages --}} {{-- Currents --}} {{-- Power Factors — mirror currentLog display logic --}} @if($row->is_warterScade_device == 1) @else @endif {{-- kW Load --}} {{-- Interval (minutes) --}} {{-- Interval (hours) --}} {{-- kWh Interval --}} {{-- kWh Cumulative --}} @endforeach @else @endif @if($data && $data->count() > 0) @endif
Time GlobalID Timing Voltages Currents Power Factors ⚡ Calculated KWH
V1 V2 V3I1 I2 I3PF1 PF2 PF3kW Load Int (mins) Int (hours) kWh (Int) kWh (Cumul)
{{ appDate($row->dtime) }}dmdt_phase == 1) style="color:blue;" @endif> {{ $row->global_device_id }} @if($row->is_warterScade_device == 1) {{-- WaterScada: no peak/offpeak --}} @else @if(isset($row->isPk) && $row->isPk == 1) Peak @else Offpeak @endif @endif {{ $v1 }} {{ $v2 }} {{ $v3 }}{{ $i1 }} {{ $i2 }} {{ $i3 }}{{ getRandomPf() }} {{ getRandomPf() }} {{ getRandomPf() }}{{ $row->pf1 }} {{ $row->pf2 }} {{ $row->pf3 }} {{ number_format($kw_load, 4) }} {{ number_format($diff_minutes, 2) }} {{ number_format($interval_hours, 2) }} {{ number_format($kwh_interval, 6) }} {{ number_format($cumulative, 4) }}
@if(request()->hasAny(['from','to','DeviceId'])) Record Not Found @else Please select a Device and date range to load data. @endif
Page Total: {{ number_format($cumulative, 4) }} {{ number_format($cumulative, 4) }} kWh
@if ($data->hasPages()) {{ $data->appends(request()->query())->links('pagination::bootstrap-4') }} @endif
@push('scripts') @endpush @endsection