Timmer corrected
This commit is contained in:
@@ -84,7 +84,7 @@ class MonitoringServer extends IPSModule {
|
|||||||
$this->SetTimerInterval("UpdateAlarms", $this->ReadPropertyInteger("UpdateintervallAlarms") * 1000);
|
$this->SetTimerInterval("UpdateAlarms", $this->ReadPropertyInteger("UpdateintervallAlarms") * 1000);
|
||||||
$this->SetTimerInterval("UpdateValues", $this->ReadPropertyInteger("UpdateintervallValues") * 1000);
|
$this->SetTimerInterval("UpdateValues", $this->ReadPropertyInteger("UpdateintervallValues") * 1000);
|
||||||
$this->SetTimerInterval("ForceUpdateValues", $this->ReadPropertyInteger("UpdateintervallForceValues") * 1000 * 60);
|
$this->SetTimerInterval("ForceUpdateValues", $this->ReadPropertyInteger("UpdateintervallForceValues") * 1000 * 60);
|
||||||
$this->SetTimerInterval("UpdateFtp", $this->ReadPropertyInteger("UpdateintervallSendFtp") * 1000 * 60);
|
$this->SetTimerInterval("UpdateFtp", $this->ReadPropertyInteger("UpdateintervallSendFtp") * 1000);
|
||||||
|
|
||||||
$this->SetTimerInterval("CheckChanges", 10 * 1000);
|
$this->SetTimerInterval("CheckChanges", 10 * 1000);
|
||||||
|
|
||||||
@@ -582,99 +582,99 @@ class MonitoringServer extends IPSModule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sendFtp(){
|
private function sendFtp(){
|
||||||
$goforit = $this->ReadPropertyBoolean("SendFtp");
|
$goforit = $this->ReadPropertyBoolean("SendFtp");
|
||||||
$ftp_server = $this->ReadPropertyString("FtpHost");
|
$ftp_server = $this->ReadPropertyString("FtpHost");
|
||||||
$ftp_user_name = $this->ReadPropertyString("FtpUser");
|
$ftp_user_name = $this->ReadPropertyString("FtpUser");
|
||||||
$ftp_user_pass = $this->ReadPropertyString("FtpPassword");
|
$ftp_user_pass = $this->ReadPropertyString("FtpPassword");
|
||||||
|
|
||||||
if ($goforit == true or $goforit == 1){
|
if ($goforit == true or $goforit == 1){
|
||||||
IPS_LogMessage ("FTP", "FTP Is ON!!!");
|
IPS_LogMessage ("FTP", "FTP Is ON!!!");
|
||||||
$catNotifyId = $this->ReadPropertyInteger("ParseNotifyCategoryID");
|
$catNotifyId = $this->ReadPropertyInteger("ParseNotifyCategoryID");
|
||||||
$catAnalogId = $this->ReadPropertyInteger("ParseAnalogCategoryID");
|
$catAnalogId = $this->ReadPropertyInteger("ParseAnalogCategoryID");
|
||||||
$catAlarmId = $this->ReadPropertyInteger("ParseAlarmCategoryID");
|
$catAlarmId = $this->ReadPropertyInteger("ParseAlarmCategoryID");
|
||||||
|
|
||||||
$ispName = "";
|
$ispName = "";
|
||||||
$projectName = "";
|
$projectName = "";
|
||||||
$yearName = "";
|
$yearName = "";
|
||||||
|
|
||||||
$usedCat = 0;
|
$usedCat = 0;
|
||||||
if ($catNotifyId > 0) $usedCat = $catNotifyId;
|
if ($catNotifyId > 0) $usedCat = $catNotifyId;
|
||||||
elseif ($catAnalogId > 0) $usedCat = $catAnalogId;
|
elseif ($catAnalogId > 0) $usedCat = $catAnalogId;
|
||||||
elseif ($catAlarmId > 0) $usedCat = $catAlarmId;
|
elseif ($catAlarmId > 0) $usedCat = $catAlarmId;
|
||||||
|
|
||||||
if ($usedCat > 0){
|
if ($usedCat > 0){
|
||||||
$parentid = IPS_GetParent($usedCat);
|
$parentid = IPS_GetParent($usedCat);
|
||||||
$ispName = IPS_GetName($parentid);
|
$ispName = IPS_GetName($parentid);
|
||||||
$projectId = IPS_GetParent($parentid);
|
$projectId = IPS_GetParent($parentid);
|
||||||
$projectName = IPS_GetName($projectId);
|
$projectName = IPS_GetName($projectId);
|
||||||
$yearId = IPS_GetParent($projectId);
|
$yearId = IPS_GetParent($projectId);
|
||||||
$yearName = IPS_GetName($yearId);
|
$yearName = IPS_GetName($yearId);
|
||||||
}
|
}
|
||||||
|
|
||||||
$ftp = ftp_ssl_connect($ftp_server);
|
$ftp = ftp_ssl_connect($ftp_server);
|
||||||
if (!$ftp) {
|
if (!$ftp) {
|
||||||
IPS_LogMessage ("FTP", "FTP-Verbindung fehlgeschlagen.");
|
IPS_LogMessage ("FTP", "FTP-Verbindung fehlgeschlagen.");
|
||||||
///echo "FTP-Verbindung fehlgeschlagen.";
|
///echo "FTP-Verbindung fehlgeschlagen.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
|
||||||
|
if (!$login_result) {
|
||||||
|
IPS_LogMessage ("FTP", "FTP-Login fehlgeschlagen.");
|
||||||
|
///echo "FTP-Login fehlgeschlagen.";
|
||||||
|
ftp_close($ftp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pfad erstellen
|
||||||
|
$ftpPath = "$yearName/$projectName/$ispName";
|
||||||
|
$pathParts = explode("/", $ftpPath);
|
||||||
|
$currentPath = "";
|
||||||
|
foreach ($pathParts as $part) {
|
||||||
|
$currentPath .= "$part/";
|
||||||
|
if (!@ftp_chdir($ftp, $currentPath)) {
|
||||||
|
ftp_mkdir($ftp, $currentPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Temp-Dateipfad vorbereiten
|
||||||
|
$tmpDir = sys_get_temp_dir();
|
||||||
|
|
||||||
|
// Verarbeitungsfunktion
|
||||||
|
$this->generateAndUploadCsv($catNotifyId, $ftp, "$ftpPath/notify.csv", "$tmpDir/notify.csv");
|
||||||
|
$this->generateAndUploadCsv($catAlarmId, $ftp, "$ftpPath/alarms.csv", "$tmpDir/alarms.csv");
|
||||||
|
$this->generateAndUploadCsv($catAnalogId, $ftp, "$ftpPath/analog.csv", "$tmpDir/analog.csv");
|
||||||
|
|
||||||
$login_result = ftp_login($ftp, $ftp_user_name, $ftp_user_pass);
|
|
||||||
if (!$login_result) {
|
|
||||||
IPS_LogMessage ("FTP", "FTP-Login fehlgeschlagen.");
|
|
||||||
///echo "FTP-Login fehlgeschlagen.";
|
|
||||||
ftp_close($ftp);
|
ftp_close($ftp);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pfad erstellen
|
|
||||||
$ftpPath = "$yearName/$projectName/$ispName";
|
|
||||||
$pathParts = explode("/", $ftpPath);
|
|
||||||
$currentPath = "";
|
|
||||||
foreach ($pathParts as $part) {
|
|
||||||
$currentPath .= "$part/";
|
|
||||||
if (!@ftp_chdir($ftp, $currentPath)) {
|
|
||||||
ftp_mkdir($ftp, $currentPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Temp-Dateipfad vorbereiten
|
|
||||||
$tmpDir = sys_get_temp_dir();
|
|
||||||
|
|
||||||
// Verarbeitungsfunktion
|
|
||||||
$this->generateAndUploadCsv($catNotifyId, $ftp, "$ftpPath/notify.csv", "$tmpDir/notify.csv");
|
|
||||||
$this->generateAndUploadCsv($catAlarmId, $ftp, "$ftpPath/alarms.csv", "$tmpDir/alarms.csv");
|
|
||||||
$this->generateAndUploadCsv($catAnalogId, $ftp, "$ftpPath/analog.csv", "$tmpDir/analog.csv");
|
|
||||||
|
|
||||||
ftp_close($ftp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function generateAndUploadCsv($catId, $ftp, $remotePath, $localPath) {
|
|
||||||
if ($catId <= 0) return;
|
|
||||||
|
|
||||||
$data = "Name;Wert\n";
|
|
||||||
|
|
||||||
$catChilds = IPS_GetChildrenIDs($catId);
|
|
||||||
foreach ($catChilds as $catChild) {
|
|
||||||
$objchildids = IPS_GetChildrenIDs($catChild);
|
|
||||||
$parentName = IPS_GetName($catChild);
|
|
||||||
|
|
||||||
foreach ($objchildids as $varId) {
|
|
||||||
if (IPS_VariableExists($varId)) {
|
|
||||||
$varName = IPS_GetName($varId);
|
|
||||||
$formattedValue = GetValueFormatted($varId);
|
|
||||||
$data .= "\"{$parentName}_{$varName}\";\"{$formattedValue}\"\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schreibe Datei lokal
|
private function generateAndUploadCsv($catId, $ftp, $remotePath, $localPath) {
|
||||||
file_put_contents($localPath, $data);
|
if ($catId <= 0) return;
|
||||||
|
|
||||||
// Lade hoch
|
$data = "Name;Wert\n";
|
||||||
ftp_put($ftp, $remotePath, $localPath, FTP_BINARY);
|
|
||||||
}
|
$catChilds = IPS_GetChildrenIDs($catId);
|
||||||
|
foreach ($catChilds as $catChild) {
|
||||||
|
$objchildids = IPS_GetChildrenIDs($catChild);
|
||||||
|
$parentName = IPS_GetName($catChild);
|
||||||
|
|
||||||
|
foreach ($objchildids as $varId) {
|
||||||
|
if (IPS_VariableExists($varId)) {
|
||||||
|
$varName = IPS_GetName($varId);
|
||||||
|
$formattedValue = GetValueFormatted($varId);
|
||||||
|
$data .= "\"{$parentName}_{$varName}\";\"{$formattedValue}\"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Schreibe Datei lokal
|
||||||
|
file_put_contents($localPath, $data);
|
||||||
|
|
||||||
|
// Lade hoch
|
||||||
|
ftp_put($ftp, $remotePath, $localPath, FTP_BINARY);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
+1
-1
@@ -8,6 +8,6 @@
|
|||||||
"date": 1491343200
|
"date": 1491343200
|
||||||
},
|
},
|
||||||
"version": "2.5",
|
"version": "2.5",
|
||||||
"build": 2,
|
"build": 3,
|
||||||
"date": 0
|
"date": 0
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user