FSM Utilities


Functions

int fwHw_getServerState (string domain, string device)
int fwHw_connectServerState (string domain, string device, string callback="")
string fwHw_makeRecipeName (string domain, string device, string command)

Detailed Description

Functions that can be used in order to build an FSM Device Unit from your HW device.

Function Documentation

int fwHw_connectServerState ( string  domain,
string  device,
string  callback = "" 
)

Connect to the running state of the SpecsServer/CcpcServer. Will automatically set the DU in state "UNKNOWN" when the server is not running, and to "NOT_READY" when the server reconnects. If a callback function is given instead of setting the state the callback function is called in the format: <yourCallback>(string domain, string device, int serverState), where serverState is 1 when server running and 0 when server not running

Parameters:
[in] domain The FSM domain received from <YourDUType>_initialize(...).
[in] device The device received from <YourDUType>_initialize(...).
[in] callback [optional] A callback to be executed when the Server state changes.
Returns:
1 no error found.

0 error found.

Example:

  HwTypeXXXXMyBoard_initialize(string domain, string device)
  {
    fwHw_connectServerState(domain, device, "setServerStateCallback");
  }

  // use the callback to set the dpe that the FSM State depends on
  setServerStateCallback(string domain, string device, int state)
  {
    int oldState;
    
    // If the Server is not running set the DU state to, for example, "UNKNOWN" (0).
    if(state == 0)
      dpSet(device+".status", 0);
    else
    {
      // If the DU state was "UNKNOWN" (0), set it to, for example, "NOT_READY" (1).
      // Otherwise leave it as it was.
      dpGet(device+".status", oldState);
      if(oldState == 0)
        dpSet(device+".status", 1);
    }
  }



int fwHw_getServerState ( string  domain,
string  device 
)

Check if the SpecsServer/CcpcServer is running. Can be used to set the DU in state UNKNOWN if the server is not running.

Parameters:
[in] domain The FSM domain received from <YourDUType>_valueChanged(...).
[in] device The device received from <YourDUType>_valueChanged(...).
Returns:
1 the server is running.

0 the server is not running.

Example:

  HwTypeXXXXMyBoard_valueChanged( string domain, string device,
        int status, string &fwState)
  {
    int serverState;
    
    serverState = fwHw_getServerState(domain, device);
    if(!serverState)
    {
       fwState = "UNKNOWN";
    }
    else
    {
        if(status == 0)
          {
                fwState = "NOT_READY";
        }
        (...)
    }
  }



string fwHw_makeRecipeName ( string  domain,
string  device,
string  command 
)

Prepare the standard recipe name based on RUN_TYPE and received command.

Parameters:
[in] domain The FSM domain received from <YourDUType>_doCommand(...).
[in] device The device received from <YourDUType>_doCommand(...).
[in] command The command received from <YourDUType>_doCommand(...).
Returns:
the recipe name.
Example:

  HwTypeXXXXMyBoard_doCommand(string domain, string device, string command)
  {
     (...)
     if (command == "Configure")    
     {
         string recipe;
         recipe = fwHw_makeRecipeName(domain, device, command);         
         fwHw_getApplyRecipe(device, recipe, 0, domain);
     }
     (...)
  }




Generated on Mon Jan 28 10:40:20 2008 for FwHw by  doxygen 1.4.7