How to check active/passive state...


global bool G_ACTIVE = true;

/**************************************************************************************************
Name : 
***************************************************************************************************
Author : 
Desc   : 
Params : -
Returns: -
History: -
***************************************************************************************************/
void main()
{
  int iAnswer;

  if ( !G_VISION ) // not for vision, a vision/client is always ACTIVE
  {
    string dp;
    initHosts(); // Std.PVSS Funktion: erzeugt globale Variablen hostname, host1, host2

    if (host1 != "" && host2 != "")
    {
      if (hostname == host1)
        dp = "_ReduManager.Status.Active:_online.._value";
      else 
      if (hostname == host2)
        dp = "_ReduManager_2.Status.Active:_online.._value";
    }

    if ( dp != "" ) // redundantes System
      dpConnect("setActive",dp);
  }
}

/**************************************************************************************************
Name : 
***************************************************************************************************
Author : -
Desc   : -
Params : -
Returns: -
History: -
***************************************************************************************************/
void setActive(string dp, bool active)
{
  G_ACTIVE = active;
  DebugTN("G_ACTIVE", active);
  if ( G_ACTIVE ) 
    Debug("now i am the active server :-)!");  
  else 
    DebugTN("now i am the passive server :-(!");
}
Last update:
2015-01-21 10:27
Author:
Andreas Vogler
Revision:
1.0
Average rating:0 (0 Votes)

You can comment this FAQ

Chuck Norris has counted to infinity. Twice.

Comment of Todd Malone:
I don't understand why this main() sets to active, the title hints that it will TELL ... show moreyou if it is active or passive?
Added at: 2015-02-13 00:10

Comment of Andreas Vogler:
It tells you which servers is active. There is a dpConnect and a callback function.
Added at: 2015-02-28 18:20