Hallo,
ich versuche folgendes Script auf das Logfile der USV ERREPI VRX 700 anzupassen aber ich bekomme es nicht gebacken:
/*
Einlesen des Logfile aus USV ERREPI VRX 700
========================================================
Anleitung:
- LogFile und LogInterval anpassen
- Bei Bedarf auskommentierte Zeilen aktivieren und Positionen anpassen
- Execute drücken, um den automatischen Timer zu erstellen
*/
$LogFile = "C:\\Programme\\UPS\\UPSMAN\\upsdata.csv";
$LogInterval = 20; // Minuten (Standard: 20)
if(file_exists($LogFile))
{
$lines = file($LogFile);
$data = explode(" ", $lines[count($lines) - 1]);
$ts = strtotime($data[0]);
if(date("m.d.Y H:i:s", $ts) != GetValueString(CreateVariableByName($IPS_SELF, "Last Time", 1)))
{
SetValueString(CreateVariableByName($IPS_SELF, "Last Time", 1), date("d.m.Y H:i:s", $ts));
SetValueFloat(CreateVariableByName($IPS_SELF, "INPUT VOLT", 2), strToFloat($data[2]));
SetValueFloat(CreateVariableByName($IPS_SELF, "INPUT FREQUENCY Hz", 2), strToFloat($data[3]));
SetValueFloat(CreateVariableByName($IPS_SELF, "INPUT POWER", 2), strToFloat($data[4]));
SetValueFloat(CreateVariableByName($IPS_SELF, "OUTPUT VOLT", 2), strToFloat($data[5]));
SetValueFloat(CreateVariableByName($IPS_SELF, "OUTPUT FREQUENCY Hz", 2), strToFloat($data[6]));
SetValueFloat(CreateVariableByName($IPS_SELF, "OUTPUT LOAD", 2), strToFloat($data[7]));
SetValueFloat(CreateVariableByName($IPS_SELF, "BATTERY VOLTAGE", 2), strToFloat($data[8]));
SetValueFloat(CreateVariableByName($IPS_SELF, "TEMPERATURE", 2), strToFloat($data[9]));
SetValueFloat(CreateVariableByName($IPS_SELF, "BATTERY CAPACITY", 2), strToFloat($data[10]));
}
// Offset berechnen und Timer stellen
IPS_SetScriptTimer($IPS_SELF, ($ts + $LogInterval * 60 + 10) - time());
}
function strToFloat($value)
{
return (float)(str_replace(",", ".", $value));
}
function CreateVariableByName($id, $name, $type)
{
global $IPS_SELF;
$vid = @IPS_GetVariableIDByName($name, $id);
if($vid===false) {
$vid = IPS_CreateVariable($type);
IPS_SetParent($vid, $id);
IPS_SetName($vid, $name);
IPS_SetInfo($vid, "This Variable was created by Script #$IPS_SELF");
}
return $vid;
}
Auszug aus dem Logfile upsdata.csv
DATE, TIME, INPUT VOLT, INPUT FREQUENCY Hz, INPUT POWER, OUTPUT VOLT, OUTPUT FREQUENCY Hz, OUTPUT LOAD , BATTERY VOLTAGE, TEMPERATURE C°, BATTERY CAPACITY
09/11/2011,19:49:23,226.66,49.96,,227.49,50.00,25.00,28.00,33.00,100.00
09/11/2011,19:54:23,228.88,49.93,,229.44,50.00,25.00,28.00,33.00,100.00
........
Kann mir bitte mal ein PHP Freak Hilfestellung geben
Lukky