/*@!Encoding:1252*/
includes
{
  
}

variables
{
  
}

on sysvar sysvar::ADAS::SubscribeService
{
  char  eventGroup[20] = "sif_2001::evg_1";
  char  text[200];
  long  result;
  dword ceg;
  
  ceg = AREthGetConsumedObjectHandle( eventGroup );
  
  if (ceg == 0)
  {
    AREthGetLastErrorText( elcount(text), text );
    writeLineEx( 0, 3, "<%NODE_NAME%> AREthGetConsumedObjectHandle(%s) failed: %s", eventGroup, text );
    return;
  }
  
  if (@this == 1)
  {
    result = AREthSDSubscribeEventGroup( ceg , 0 );

    if (result != 0)
    {
      AREthGetLastErrorText( elcount(text), text );
      writeLineEx( 0, 3, "<%NODE_NAME%> AREthSDSubscribeEventGroup( %s, 0) failed: %s", eventGroup, text );
      return;
    }
  }
  else
  {
    result = AREthSDDesubscribeEventGroup( ceg  );

    if (result != 0)
    {
      AREthGetLastErrorText( elcount(text), text );
      writeLineEx( 0, 3, "<%NODE_NAME%> AREthSDDesubscribeEventGroup( %s ) failed: %s", eventGroup, text );
      return;
    }
  }
}

