Request to FHZ_GetFreeFHTBuffer() in V2

Hi,

ich bekomme den nachfolgenden Fehler bei der Ausführung meines Skriptes „SET_FHT_CLOCK“:

Fatal error: Call to undefined function FHZ_GetFreeFHTBuffer() in [Home\SET_FHT_CLOCK] on line 61

In den Beiträgen der Foren finde ich keine Lösung.

Gibt es eine Lösung für die V2? Wenn ihr mir helfen könntet, wäre es toll.

Vielen Dank im Voraus und viele Grüße
wesseli

Hallo,

Du rufst eine undefinierte Funktion auf.

Ohne Script schlecht was zusagen.

Hallo,

anbei das Script.


<?
/*
*******************************
IP-SYMCON Event Scripting
*******************************
File     : SET_FHT_CLOCK.ips.php
Trigger  : Timer
Interval : call it once per hour  , but not at the full hour, use a custom timer or call the it every 30 minutes :)
Purpose  : Set clock of all FHT'S once every n days
Version  : 2
           - updates only minute value
           - waits for timeslot to be ready to set time
           - doesnt run between between 5 minutes beofre and after full hour
*/

require_once("globals_functions.ips.php");

// define how often clock should be set, every N days
$NDAYS = 3;

// we need this variables, to be created if needed

if (IPS_VariableExists (20887 /*[Home\FHT_SET_MINUTE_FHTID]*/) == false)
   {
   // this is the ID of FHT that needs setting
   IPS_CreateVariable (20887 /*[Home\FHT_SET_MINUTE_FHTID]*/,'Integer');
   }

if (GetValueInteger (20887 /*[Home\FHT_SET_MINUTE_FHTID]*/) > 0 )
   {
   // there is a minute set command waiting, so we send it
   $FHT_ID = GetValueInteger ('FHT_SET_MINUTE_FHTID');
   // this is te FHT to send to
   FHT_SetMinute  ($FHT_ID, intval(date('i')));
   SetValueInteger (20887 /*[Home\FHT_SET_MINUTE_FHTID]*/,0);
   //  switch off the timer
   IPS_SetScriptTimer ('SET_FHT_CLOCK',0);
   $LOGMSG = 'Command sent to ' . $FHT_ID . ' - Set Minute to ' .  date('i') ;
   IPS_LogMessage ('Update FHT Clock', $LOGMSG);
   return;
   }

// there is no minute set command waiting, so we can check for FTH'" that need an update
if (intval(date('i')) > 5 )
   {
   if (intval(date('i')) < 55 )
      {
      // setting the minute at the full hour may cause undesired results (set 10:59 to 10:00 for example)
      // loop thourgh all IPS instances
      //$INSTANCE_LIST=(IPS_GetInstanceIDs());
      $INSTANCE_LIST=(IPS_GetInstanceList());
		// find FHZ and check if enough free buffers
      foreach($INSTANCE_LIST as $IPS_INSTANCE)
         {
         // Get the Module Instance
         $MODULE_INSTANCE=IPS_GetModuleInstance($IPS_INSTANCE);
         // check if this is the FHZ
         if ($MODULE_INSTANCE['moduleguid'] =='{57040540-4432-4220-8D2D-4676B57E223D}')
            {
            // check if all 10 buffers free , otherwise our command maybe not the first in queue to the FHT we want to set and is then sent to late
            $FREE_BUFFERS = FHZ_GetFreeFHTBuffer($MODULE_INSTANCE['instanceid']) ;
            if ($FREE_BUFFERS == 10 )
               {
               // find the FHT's
               $CONNECTED_INSTANCES=IPS_GetModuleInstanceConnections($IPS_INSTANCE);
               foreach($CONNECTED_INSTANCES as $IPS_INSTANCE)
                  {
                  // Get the module instance
                  $MODULE_INSTANCE=IPS_GetModuleInstance($IPS_INSTANCE);
                  // check if this is a FHT
                  if ($MODULE_INSTANCE['moduleguid'] =='{A89F8DFA-A439-4BF1-B7CB-43D047208DDD}')
                     {
                     // this is the variable that remembers when FHT clock was last set
                     $LAST_CLOCK_VARNAME =  'FHT_LAST_CLOCK_SET_' . $MODULE_INSTANCE['instanceid'];
                     if (IPS_VariableExists ($LAST_CLOCK_VARNAME) == false )
                        {
                        // if the variable doesnt exist, then we create it
                        IPS_CreateVariable ($LAST_CLOCK_VARNAME,'Integer');
                        // set it to n days ago plus one second to trigger an immediate update
                        SetValueInteger ($LAST_CLOCK_VARNAME, (TIME() - ($NDAYS * 86400) - 1));
                        }
                     // read when clock was set
                     $LAST_CLOCK_SET =GetValueInteger ($LAST_CLOCK_VARNAME);
                     // if last update more than n days ago then send time to fht
                     if (TIME() - $LAST_CLOCK_SET   >  ($NDAYS * 86400))
                        {
                        $INSTANCE_DATA=IPS_GetInstanceSettings ($MODULE_INSTANCE['instanceid']);
                        // find the variable that tracks the position values
                        $STELL_VARIABLE_NAME = preg_match( '#PositionVar.*"(.*)"#', $INSTANCE_DATA, $m) ? $m[1] : '';
                        // check wehn it was last received
                        $LAST_STELL_UPDATE =IPS_GetUpdateTime ($STELL_VARIABLE_NAME);
                        // Positions come about every 116 seconds,  this is the time left until the next pos comes.
                        // a tx timeslot is available just before, so we send our command 5 beofre the slot is open
                        // if the commands are sent to late , then change this value (111) a bit
                        $MINUTE_TO_SET =  111- (TIME() -$LAST_STELL_UPDATE );
                        if ($MINUTE_TO_SET < 15)
                        {
                        // to close to next timeslot, better take the next one
                         $MINUTE_TO_SET=$MINUTE_TO_SET + 116;
                        }
                        // we rememeber the FHT we need the miute to send to
                        SetValueInteger ('FHT_SET_MINUTE_FHTID',intval($MODULE_INSTANCE['instanceid']));
                        // we call ourselves just before the timeslot is ready
                        IPS_SetScriptTimer ('SET_FHT_CLOCK',intval( $MINUTE_TO_SET));
                        // update the Variable that remebers last time setting for this FHT
                        SetValueInteger ($LAST_CLOCK_VARNAME,TIME());
                        $LOGMSG = 'Set Minute Command queued to be sent to ' . $MODULE_INSTANCE['instanceid'] . ' in ' . $MINUTE_TO_SET . ' seconds';
                        IPS_LogMessage ('Update FHT Clock', $LOGMSG);
                        // done
                        return;
                        }
                     }
                  }
               }
            }
         }
      }
   }
?>

Hallo wesseli,

so ist das Script für die V2 nicht zugebrauchen.

Da sind Befehle drinnen vorhanden, die es so nicht mehr gibt. Da bleibt Dir nur, umzubauen.

Hallo,

kann mir jemand helfen?

Bereits in der ersten Anfrage habe ich angefragt, ob es eine Lösung für die V2 gibt.

Die Hinweise von RWN helfen nicht weiter. Soweit war ich bereits vor der
Anfrage.

Viele Gruesse
wesseli

Sorry, dann hättest Du in deinem ersten Thread dazuschreiben sollen um was es geht.

Glaskugel ist leider defekt :smiley:

Hallo wesseli,

Rainer hat recht, das Script müßte mit größerem Aufwand auf die V2 portiert werden, da mußt Du schon selbst mit Eigeninitative beitragen.

Hallo,

warum so kompliziert? Ich lasse folgendes Script einmal pro Tag (irgendwann in der Nacht) durchlaufen. Damit werden die FHT einmal im Monat syncronisiert. Mir reicht das.

$day = (int) date("d");
$fht = array(12345,23456,34567,45678,56789);// hier die ID's der FHT's eintragen

if ($day <= count($fht))FHT_SetMinute($fht[$day-1],(int)date("i"));

Gruß


print_r(FHZ_GetFHTQueue($id));

Die neue Funktion :wink:

paresy

Vielen Dank für Eure sachliche Hilfe, Parsey und Attain. :slight_smile:

VG
wesseli