/**
  * Returns the rpc handler for the given rig.
  * 
  * @param string $rig
  *   The rig name.
  * 
  * @return PHPMinerRPC
  *   The PHPMiner RPC client
  * 
  * @throws APIException
  */
 public function get_rpc($rig)
 {
     $rig_cfg = $this->config->get_rig($rig);
     $rpc = new PHPMinerRPC($rig_cfg['http_ip'], $rig_cfg['http_port'], $rig_cfg['rpc_key'], $this->config->socket_timout);
     $res = $rpc->ping();
     if ($res !== true) {
         throw new APIException("No connection to PHPMiner RCP on Rig <b>" . $rig . "</b>.\n\n<b>Error message</b>\n" . $res, APIException::CODE_SOCKET_CONNECT_ERROR);
     }
     return $rpc;
 }