Changeset 10049
- Timestamp:
- 11/09/10 08:36:18 (14 years ago)
- Location:
- fact/BIASctrl
- Files:
-
- 2 added
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/BIASctrl
-
Property svn:ignore
set to
BIASctrl
Dep.d
-
Property svn:ignore
set to
-
fact/BIASctrl/BIASctrl.cc
r9917 r10049 11 11 #include <stdio.h> 12 12 13 #include " ProcessIO.h"13 #include "User.h" 14 14 15 15 #include <readline/readline.h> … … 84 84 85 85 // Construct main instance 86 static ProcessIOM;86 static User M; 87 87 88 88 // These signals were set during construction of EvidenceServer -
fact/BIASctrl/Crate.cc
r9917 r10049 6 6 7 7 #include "Crate.h" 8 #include " ProcessIO.h" // Must be not in HV.h to avoid problem with declaring class ProcessIO8 #include "User.h" // Must not be in header file to avoid problem with declaring class User 9 9 10 10 using namespace std; … … 13 13 // Constructor 14 14 // 15 Crate::Crate(string CrateName, int Number, class ProcessIO*PIO) {15 Crate::Crate(string CrateName, int Number, class User *PIO) { 16 16 17 17 struct termios tio; … … 78 78 if(fDescriptor != -1) { 79 79 SystemReset(); 80 close(fDescriptor);80 if (close(fDescriptor) == -1) m->PrintMessage("Error closing device %s (%s)\n", Name, strerror(errno));; 81 81 } 82 82 … … 92 92 int Crate::Communicate(unsigned char* wbuf, int Bytes) { 93 93 94 unsigned char rbuf[3];95 94 int N, Ret = 0; 96 95 fd_set SelectDescriptor; … … 117 116 goto ExitCommunicate; 118 117 } 118 119 119 // Time-out expired? 120 120 if (!FD_ISSET(fDescriptor, &SelectDescriptor)) { … … 124 124 125 125 // Read data 126 if ((N = read(fDescriptor, &rbuf, 1)) == -1) {126 if ((N = read(fDescriptor, ReadBuffer, sizeof(ReadBuffer))) == -1) { 127 127 m->Message(m->ERROR, "Read error (%s)", strerror(errno)); 128 128 ErrorCount++; … … 130 130 } 131 131 132 // === Update status informationif three bytes were returned ===132 // === Check wrap counter if three bytes were returned === 133 133 if (N == 3) { 134 // This data only valid for channel set or channel read135 LastCurrent = rbuf[1] + (rbuf[0]&15)*256;136 LastOC = rbuf[0] & 128;137 ResetHit = rbuf[2] & 128;138 139 // Check wrap counter140 134 if (WrapCount != -1) { 141 if ((WrapCount+1)%8 == (( rbuf[0]>>4) & 7)) WrapOK = true;135 if ((WrapCount+1)%8 == ((ReadBuffer[0]>>4) & 7)) WrapOK = true; 142 136 else WrapOK = false; 143 137 } 144 WrapCount = ( rbuf[0]>>4) & 7;138 WrapCount = (ReadBuffer[0]>>4) & 7; 145 139 Ret = 1; 146 140 } … … 148 142 // === UnLock file descriptor === 149 143 ExitCommunicate: 150 if (lockf(fDescriptor, F_ LOCK, 0) == -1) {151 m->Message(m->ERROR, "Failed to lock file descriptor (%s)", strerror(errno));144 if (lockf(fDescriptor, F_ULOCK, 0) == -1) { 145 m->Message(m->ERROR, "Failed to unlock file descriptor (%s)", strerror(errno)); 152 146 return 0; 153 147 } … … 191 185 192 186 if ((ret = Communicate(wbuf, 3)) == 1) { 193 Current[Board][Channel] = LastCurrent; 194 OC[Board][Channel] = LastOC; 187 Current[Board][Channel] = ReadBuffer[1] + (ReadBuffer[0]&15)*256; 188 OC[Board][Channel] = ReadBuffer[0] & 128; 189 ResetHit = ReadBuffer[2] & 128; 195 190 } 196 191 return ret; … … 213 208 if ((ret = Communicate(wbuf, 3)) == 1) { 214 209 for (int i=0; i<MAX_NUM_BOARDS; i++) { 215 for (int j=0; j<NUM_CHANNELS; j++) DAC[i][j] = SetPoint; 210 for (int j=0; j<NUM_CHANNELS; j++) { 211 DAC[i][j] = SetPoint; 212 Volt[i][j] = (double) SetPoint / 0xfff * 90; 213 } 216 214 } 217 215 } … … 243 241 if ((ret = Communicate(wbuf, 3)) == 1) { 244 242 DAC[Board][Channel] = SetPoint; 245 Current[Board][Channel] = LastCurrent; 246 OC[Board][Channel] = LastOC; 243 Volt[Board][Channel] = (double) SetPoint / 0xfff * 90; 247 244 } 248 245 return ret; … … 270 267 for (int j=0; j<NUM_CHANNELS; j++){ 271 268 DAC[i][j] = 0; 272 //Volt[i][j] = 0.0;269 Volt[i][j] = 0.0; 273 270 } 274 271 } -
fact/BIASctrl/Crate.h
r9917 r10049 16 16 #define BAUDRATE B115200 17 17 18 class ProcessIO;18 class User; 19 19 20 20 class Crate { 21 21 22 class ProcessIO*m;22 class User *m; 23 23 int CrateNumber; 24 24 int fDescriptor; 25 25 DimService *NameService; 26 bool LastOC; 27 int LastCurrent; 26 char ReadBuffer[3]; 28 27 29 28 int Communicate(unsigned char*, int); … … 31 30 32 31 public: 33 Crate(std::string, int, class ProcessIO*);32 Crate(std::string, int, class User *); 34 33 ~Crate(); 35 34 -
fact/BIASctrl/Makefile
r9917 r10049 1 1 # Makefile for BIASctrl 2 2 3 SOURCES = BIASctrl.cc Crate.cc ProcessIO.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc ../Evidence/Evidence.cc3 SOURCES = BIASctrl.cc Crate.cc User.cc ../pixelmap/Pixel.cc ../pixelmap/PixelMap.cc ../Evidence/Evidence.cc 4 4 OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) 5 5 INCDIRS = -I. -I../Evidence -I./src -I$(DIMDIR)/dim
Note:
See TracChangeset
for help on using the changeset viewer.