00001 #ifndef _ots_OtsUDPFirmwareCore_h_
00002 #define _ots_OtsUDPFirmwareCore_h_
00003
00004
00005 #include "otsdaq-components/DAQHardware/FrontEndFirmwareBase.h"
00006
00007
00008 #include <string>
00009 #include <vector>
00010
00011
00012 namespace ots
00013 {
00014
00015 class OtsUDPFirmwareCore : public FrontEndFirmwareBase
00016 {
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 public:
00029
00030 OtsUDPFirmwareCore (unsigned int version);
00031 virtual ~OtsUDPFirmwareCore (void);
00032 virtual void init (void);
00033
00034
00036
00037
00038
00039 virtual std::string write (char* address, char* data);
00040 virtual void write (std::string& buffer, char* address, char* data, bool clearBuffer=true);
00041 virtual void write (std::string& buffer, uint32_t address, uint32_t data, bool clearBuffer=true);
00042 virtual void write (std::string& buffer, uint64_t address, uint64_t data, bool clearBuffer=true);
00043 virtual void waitClear (std::string& buffer, uint32_t address, uint32_t data, uint32_t timeout = 255, bool clearBuffer=true){}
00044
00045 virtual std::string read (char* address);
00046 virtual void read (std::string& buffer, char* address, bool clearBuffer=true);
00047 virtual void read (std::string& buffer, uint64_t address, bool clearBuffer=true);
00048 virtual void read (std::string& buffer, uint32_t address, bool clearBuffer=true);
00049
00050
00051 virtual void setDataDestination (std::string& buffer, const std::string& ip, const uint16_t port, bool clearBuffer=true);
00052
00053 virtual uint32_t createRegisterFromValue (std::string& readBuffer, std::string& receivedValue);
00055
00056 void writeAdvanced (std::string& buffer, const char* address, const char* data, uint8_t size = 1, uint8_t commandTypeOptions = 0, bool clearBuffer=true);
00057 void writeAdvanced (std::string& buffer, const uint64_t& address, const char* data, uint8_t size, uint8_t commandTypeOptions = 0, bool clearBuffer=true);
00058 void writeAdvanced (std::string& buffer, const uint64_t& address, const uint64_t& data, uint8_t commandTypeOptions = 0, bool clearBuffer=true);
00059 void writeAdvanced (std::string& buffer, const uint64_t& address, const std::vector<uint64_t>& data, uint8_t commandTypeOptions = 0, bool clearBuffer=true);
00060 void readAdvanced (std::string& buffer, char* address, uint8_t size = 1, uint8_t commandTypeOptions = 0, bool clearBuffer=true);
00061 void readAdvanced (std::string& buffer, const uint64_t& address, uint8_t size = 1, uint8_t commandTypeOptions = 0, bool clearBuffer=true);
00062
00064
00065
00066
00067 void writeDataDestinationIP (std::string& buffer, const uint64_t value, bool clearBuffer=true);
00068 void writeDataDestinationMAC (std::string& buffer, const uint64_t value, bool clearBuffer=true);
00069 void writeDataDestinationPort (std::string& buffer, const uint64_t value, bool clearBuffer=true);
00070
00071 void readDataDestinationIP (std::string& buffer);
00072 void readDataDestinationMAC (std::string& buffer);
00073 void readDataDestinationPort (std::string& buffer);
00074
00075 void setDataDestinationAsSelf (std::string& buffer) { buffer.resize(0); buffer += (char)2; }
00076
00077
00078
00079 virtual void setControlDestination (std::string& buffer, const std::string& ip, const uint16_t port);
00080
00081 void writeControlDestinationIP (std::string& buffer, const uint64_t value);
00082 void writeControlDestinationMAC (std::string& buffer, const uint64_t value);
00083 void writeControlDestinationPort (std::string& buffer, const uint64_t value);
00084
00085 void readControlDestinationIP (std::string& buffer);
00086 void readControlDestinationMAC (std::string& buffer);
00087 void readControlDestinationPort (std::string& buffer);
00088
00089 void setControlDestinationAsSelf (std::string& buffer) { buffer.resize(0); buffer += (char)1; }
00090
00091
00092 void UDPFirmwareSpecialPing (std::string& buffer) { buffer.resize(0); buffer += (char)0; }
00093 void UDPFirmwareSpecialNoOp (std::string& buffer) { buffer.resize(0); buffer += (char)3; }
00094
00095 void readUDPFirmwareVersion (std::string& buffer);
00096 void softEthernetReset (std::string& buffer);
00097 void hardEthernetReset (std::string& buffer);
00098 void clearEthernetReset (std::string& buffer);
00099
00100 void startBurst (std::string& buffer);
00101 void stopBurst (std::string& buffer);
00102
00103
00104 static const uint8_t FIFO_ADDRESS_CMD_TYPE;
00105 };
00106
00107 }
00108
00109 #endif