00001
00002
00003
00004
00005
00006
00007 #ifndef DSM_HH
00008 #define DSM_HH
00009
00010 #include <string>
00011 #include <sstream>
00012 #include <iomanip>
00013 #include <stdio.h>
00014 using namespace std;
00015
00016 struct DSM {
00017 enum { NREGISTERS = 32, NCHANNELS = 16, LUT_SIZE = 16, INFO_SIZE = 64 };
00018
00019 string name;
00020 int registers[NREGISTERS];
00021 short channels[NCHANNELS];
00022 char lut[LUT_SIZE];
00023 int info[INFO_SIZE];
00024 int output;
00025
00026 DSM(const string& name = "") : name(name) { clear(); }
00027 void clear();
00028 void setName(const string& basename, int layer, int dsm);
00029 void dump();
00030 };
00031
00032 inline void DSM::clear()
00033 {
00034 fill(registers,registers+NREGISTERS,0);
00035 fill(channels,channels+NCHANNELS,0);
00036 fill(lut,lut+LUT_SIZE,0);
00037 fill(info,info+INFO_SIZE,0);
00038 output = 0;
00039 }
00040
00041 inline void DSM::setName(const string& basename, int layer, int dsm)
00042 {
00043 ostringstream ss;
00044 ss << basename << layer << setw(2) << setfill('0') << dsm+1;
00045 name = ss.str();
00046 }
00047
00048 inline void DSM::dump()
00049 {
00050 printf("%s: ", name.c_str());
00051 for (int ch = 0; ch < 8; ++ch)
00052 printf("%04x ", (unsigned short)channels[ch]);
00053 printf("\n");
00054 }
00055
00056 #endif // DSM_HH