#include "TempControl.h"

TempControl::TempControl(const char *name)
  :  TaskInterface(name, TempControlServerName)
{
}

TempControl::~TempControl()
{
}

short TempControl::setpoint()
{
  // Copy any input args to appropriate message fields
  
  // Set message code and send message
  _setpointMsg.code = SetpointMsgCode;

  send(&_setpointMsg, sizeof(SetpointMsg),
       &_setpointMsg, sizeof(SetpointMsg));

  // Copy any output fields of msg to appropriate output args
  
  return _setpointMsg.returnVal;
}


short TempControl::foo(float junk)
{
  // Copy any input args to appropriate message fields
  _fooMsg.junk = junk;
  
  // Set message code and send message
  _fooMsg.code = FooMsgCode;

  send(&_fooMsg, sizeof(FooMsg),
       &_fooMsg, sizeof(FooMsg));

  // Copy any output fields of msg to appropriate output args
  
  return _fooMsg.returnVal;
}


long TempControl::actual(unsigned long index, TempControl::MData *mdata, TempControl::TempData *tdata)
{
  // Copy any input args to appropriate message fields
  _actualMsg.index = index;
  memcpy(&_actualMsg.mdata, mdata, sizeof(MData));
  
  // Set message code and send message
  _actualMsg.code = ActualMsgCode;

  send(&_actualMsg, sizeof(ActualMsg),
       &_actualMsg, sizeof(ActualMsg));

  // Copy any output fields of msg to appropriate output args
  memcpy(tdata, &_actualMsg.tdata, sizeof(TempData));
  
  return _actualMsg.returnVal;
}


void TempControl::func2(float value, short *flag)
{
  // Copy any input args to appropriate message fields
  _func2Msg.value = value;
  _func2Msg.flag = *flag;
  
  // Set message code and send message
  _func2Msg.code = Func2MsgCode;

  send(&_func2Msg, sizeof(Func2Msg),
       &_func2Msg, sizeof(Func2Msg));

  // Copy any output fields of msg to appropriate output args
  *flag = _func2Msg.flag;
  
  return;
}


