00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "l1394_dccregister.h"
00019
00020
00021 namespace L1394{
00022 DccRegister::DccRegister(const Node *parent)
00023 {
00024 this->parent = parent;
00025 balance = false;
00026 message = internal::SMessage::getInstance();
00027 data.fromInt(0);
00028 }
00029
00030
00031 bool DccRegister::onePush(bool one_push) const
00032 {
00033 if ( parent->read(DCC_BASE + reg_offset + 0x800, &data) == L1394_FAILED )
00034 message->errorStream() << "DccRegister > read transaction failed" << endl;
00035
00036 data.setBit(26, one_push);
00037
00038 if ( parent->write(DCC_BASE + reg_offset + 0x800,data) == L1394_FAILED )
00039 message->errorStream() << "DccRegister > write transaction failed" << endl;
00040
00041 if ( parent->read(DCC_BASE + reg_offset + 0x800, &data) == L1394_FAILED )
00042 message->errorStream() << "DccRegister > read transaction failed" << endl;
00043
00044 return data.getBit(26);
00045 }
00046
00047 bool DccRegister::on(bool on) const
00048 {
00049 if ( parent->read(DCC_BASE + reg_offset + 0x800, &data) == L1394_FAILED )
00050 message->errorStream() << "DccRegister > read transaction failed" << endl;
00051 if(on)
00052 data.setBit(25, 1);
00053 else
00054 data.setBit(25, 0);
00055
00056 if ( parent->write(DCC_BASE + reg_offset + 0x800, data) == L1394_FAILED )
00057 message->errorStream() << "DccRegister > write transaction failed" << endl;
00058
00059 if ( parent->read(DCC_BASE + reg_offset + 0x800, &data) == L1394_FAILED )
00060 message->errorStream() << "DccRegister > read transaction failed" << endl;
00061
00062 return data.getBit(25);
00063 }
00064
00065 bool DccRegister::automatic(bool on) const
00066 {
00067 if ( parent->read(DCC_BASE + reg_offset + 0x800, &data ) == L1394_FAILED )
00068 message->errorStream() << "DccRegister > read transaction failed" << endl;
00069
00070 if(on)
00071 data.setBit(24, 1);
00072 else
00073 data.setBit(24, 0);
00074
00075 if ( parent->write(DCC_BASE + reg_offset + 0x800, data ) == L1394_FAILED )
00076 message->errorStream() << "DccRegister > write transaction failed" << endl;
00077
00078 if ( parent->read (DCC_BASE + reg_offset + 0x800, &data) == L1394_FAILED )
00079 message->errorStream() << "DccRegister > read transaction failed" << endl;
00080
00081 return data.getBit(24);
00082 }
00083
00084 int DccRegister::setValue(int value) const
00085 {
00086 if ( parent->read(DCC_BASE + reg_offset + 0x800, &data) == L1394_FAILED )
00087 message->errorStream() << "DccRegister > read transaction failed" << endl;
00088
00089 if(balance)
00090 data.setBitRange(12,23,value);
00091 else
00092 data.setBitRange(0,11, value);
00093
00094 if ( parent->write(DCC_BASE + reg_offset + 0x800, data) == L1394_FAILED )
00095 message->errorStream() << "DccRegister > write transaction failed" << endl;
00096
00097 if (balance)
00098 {
00099 balance = false;
00100 if ( parent->read(DCC_BASE + reg_offset + 0x800, &data) == L1394_FAILED )
00101 message->errorStream() << "DccRegister > read transaction failed" << endl;
00102
00103 return data.getBitRange(12,23);
00104 }
00105 else
00106 {
00107 if ( parent->read(DCC_BASE + reg_offset + 0x800, &data) == L1394_FAILED )
00108 message->errorStream() << "DccRegister > read transaction failed" << endl;
00109
00110 return data.getBitRange(0,11);
00111 }
00112 }
00113
00114 int DccRegister::setTriggerMode(int value) const
00115 {
00116 if ( parent->read(DCC_BASE +reg_offset +0x800, &data) == L1394_FAILED )
00117 message->errorStream() << "DccRegister > read transaction failed" << endl;
00118
00119 data.setBitRange(16,19, value);
00120 if ( parent->write(DCC_BASE + reg_offset + 0x800,data) == L1394_FAILED )
00121 message->errorStream() << "DccRegister > write transaction failed" << endl;
00122
00123 if ( parent->read(DCC_BASE +reg_offset +0x800, &data) == L1394_FAILED )
00124 message->errorStream() << "DccRegister > read transaction failed" << endl;
00125
00126 return data.getBitRange(16,19);
00127 }
00128
00129 bool DccRegister::setTriggerPolarity(bool value) const
00130 {
00131 if ( parent->read(DCC_BASE +reg_offset +0x800, &data) == L1394_FAILED )
00132 message->errorStream() << "DccRegister > read transaction failed" << endl;
00133
00134 data.setBit(24, value);
00135
00136 if ( parent->write(DCC_BASE + reg_offset + 0x800,data) == L1394_FAILED )
00137 message->errorStream() << "DccRegister > write transaction failed" << endl;
00138
00139 if ( parent->read(DCC_BASE +reg_offset +0x800, &data) == L1394_FAILED )
00140 message->errorStream() << "DccRegister > read transaction failed" << endl;
00141
00142 return data.getBit(24);
00143 }
00144
00145
00146 int DccRegister::getValue() const
00147 {
00148 if (balance)
00149 {
00150 balance = false;
00151 if ( parent->read(DCC_BASE + reg_offset + 0x800, &data) == L1394_FAILED )
00152 message->errorStream() << "DccRegister > read transaction failed" << endl;
00153 return data.getBitRange(12,23);
00154 }
00155 if ( parent->read(DCC_BASE + reg_offset + 0x800, &data) == L1394_FAILED )
00156 message->errorStream() << "DccRegister > read transaction failed" << endl;
00157
00158 return data.getBitRange(0,11);
00159 }
00160
00161
00162 int DccRegister::getMinValue()const
00163 {
00164 if ( parent->read(DCC_BASE + reg_offset + 0x500, &data) == L1394_FAILED )
00165 message->errorStream() << "DccRegister > read transaction failed" << endl;
00166
00167 return data.getBitRange(12, 23);
00168 }
00169
00170
00171 int DccRegister::getMaxValue() const
00172 {
00173 if ( parent->read(DCC_BASE + reg_offset + 0x500, &data) == L1394_FAILED )
00174 message->errorStream() << "DccRegister > read transaction failed" << endl;
00175
00176 return data.getBitRange(0,11);
00177 }
00178
00179 bool DccRegister::hasFeature() const
00180 {
00181 if ( parent->read(DCC_BASE + reg_offset + 0x500, &data) == L1394_FAILED )
00182 message->errorStream() << "DccRegister > read transaction failed" << endl;
00183
00184 return (bool)data.getBit(31);
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209 }
00210
00211 bool DccRegister::hasOnePush() const
00212 {
00213 if ( parent->read(DCC_BASE + reg_offset + 0x500, &data) == L1394_FAILED )
00214 message->errorStream() << "DccRegister > read transaction failed" << endl;
00215 return data.getBit(3);
00216 }
00217
00218 bool DccRegister::hasReadout() const
00219 {
00220 if ( parent->read(DCC_BASE + reg_offset + 0x500, &data) == L1394_FAILED )
00221 message->errorStream() << "DccRegister > read transaction failed" << endl;
00222
00223 return data.getBit(4);
00224 }
00225
00226 bool DccRegister::hasOnOff() const
00227 {
00228 if ( parent->read(DCC_BASE + reg_offset + 0x500, &data) == L1394_FAILED )
00229 message->errorStream() << "DccRegister > read transaction failed" << endl;
00230
00231 return data.getBit(5);
00232 }
00233
00234 bool DccRegister::hasAuto() const
00235 {
00236 if ( parent->read(DCC_BASE + reg_offset + 0x500, &data) == L1394_FAILED )
00237 message->errorStream() << "DccRegister > read transaction failed" << endl;
00238
00239 return data.getBit(6);
00240 }
00241
00242 bool DccRegister::hasManual() const
00243 {
00244 if ( parent->read(DCC_BASE + reg_offset + 0x500, &data) == L1394_FAILED )
00245 message->errorStream() << "DccRegister > read transaction failed" << endl;
00246
00247 return data.getBit(7);
00248 }
00249
00250 }