FACT++  1.0
bool ConnectionFTM::SetThreshold ( int32_t  patch,
int32_t  value 
)
inline

Definition at line 667 of file ftmctrl.cc.

References data, fDAC, i, FTM::kCmdConfigFTU, FTM::kCmdRegister, FTM::kCmdWrite, FTM::StaticData::kMaxDAC, and FTM::StaticData::kMaxPatchIdx.

668  {
670  return false;
671 
672  if (value<0 || value>FTM::StaticData::kMaxDAC)
673  return false;
674 
675  if (patch<0)
676  {
678 
679  bool ident = true;
680  for (int i=0; i<=FTM::StaticData::kMaxPatchIdx; i++)
681  if (data[i/4].fDAC[i%4] != value)
682  {
683  ident = false;
684  break;
685  }
686 
687  if (ident)
688  return true;
689 
690  for (int i=0; i<=FTM::StaticData::kMaxPatchIdx; i++)
691  data[i/4].fDAC[i%4] = value;
692 
693  // Maybe move to a "COMMIT" command?
695 
696  return true;
697  }
698 
699  /*
700  if (data[patch/4].fDAC[patch%4] == value)
701  return true;
702  */
703 
704  // Calculate offset in static data block
705  const uint16_t addr = (uintptr_t(&fStaticData[patch/4].fDAC[patch%4])-uintptr_t(&fStaticData))/2;
706 
707  // From CmdSetRegister
708  const array<uint16_t, 2> data = {{ addr, uint16_t(value) }};
710 
711  reinterpret_cast<uint16_t*>(&fBufStaticData)[addr] = value;
712 
713  // Now execute change before the static data is requested back
714  PostCmd(FTM::kCmdConfigFTU, (patch/40) | (((patch/4)%10)<<8));
715 
716  //CmdGetRegister(addr);
717  CmdReqStatDat();
718 
719  return true;
720  }
int i
Definition: db_dim_client.c:21
FTM::StaticData fBufStaticData
Definition: ftmctrl.cc:57
void CmdReqStatDat()
Definition: ftmctrl.cc:505
void PostCmd(array< uint16_t, N > dat, uint16_t u1=0, uint16_t u2=0, uint16_t u3=0, uint16_t u4=0)
Definition: ftmctrl.cc:425
Specifies that a register is read/written.
Definition: HeadersFTM.h:71
FTM::StaticData fStaticData
Definition: ftmctrl.cc:53
float data[4 *1440]
Send data.
Definition: HeadersFTM.h:59
Configure single FTU board.
Definition: HeadersFTM.h:65
void CmdSendStatDat(const FTM::StaticData &data)
Definition: ftmctrl.cc:510
uint16_t fDAC[5]
enable of 4x9 pixels coded as 4x9bits
Definition: HeadersFTM.h:187