/*
 *
 * $Id: syncwritepacket.h 2 2008-07-30 09:28:03Z mschneider $
 * $URL: svn://localhost/Bioloid/trunk/syncwritepacket.h $
 
 * \version   $Rev: 2 $
 * \author    Markus Schneider
 * \date      17.07.08
 *
 */

#ifndef SYNCWRITEPACKET_H
#define SYNCWRITEPACKET_H

#include "packet.h"

/*
 Used for controlling many Dynamixel actuators at the same time. The communication 
 time decreases by the Synch Write instruction since many instructions can be 
 transmitted by a single instruction. However, you can use this instruction only when the 
 lengths and addresses of the control table to be written to are the same. Also, the 
 broadcasting ID needs to be used for transmitting. 
*/ 

class SyncWritePacket : public Packet
{
public:
  /**
   * @param address Starting address of the location where the data is to be written 
   * @param nbytes The length of the data to be written in bytes
   */
  SyncWritePacket(byte address, byte nbytes);
  
 /**
  * Adds a new Dynamixel actuator to the list for the SyncWrite Command
  * @param id The ID of the Dynamixel actuator
  * @param param Data for the Dynamixel actuator
  */
  virtual int add(const byte id, const byte param[]);
  
 /**
  * Adds a new Dynamixel actuator to the list for the SyncWrite Command
  * Here words can be used instead of bytes. It will be automatically converted
  * NOTE: param[] must have the size nbytes/2
  * @param id The ID of the Dynamixel actuator
  * @param param Data for the Dynamixel actuator
  */  
  virtual int add(const byte id, const word param[]);
  
    
protected:
  byte address;
  byte nbytes;
};

#endif
