public BiasChannel() { Biases[0] = new BiasSignal(); Biases[1] = new BiasSignal(); }
public void BuildHDMIsignalDB() { TrimSignal newTrim; BiasSignal newBias; LEDsignal newLED; int connector = 11; int myHDMI = 0; int myAFE = 0; ushort myFPGA = 0; int vcount = 0; //TcpClient client = FEBclient.client; List <Mu2e_Register> arrReg = FEBclient.arrReg; //Main for loop builds the arrays for HDMIs, Trims, Biases, LEDs, and Voltages for (int chan = 0; chan < 16; chan++) { // load this channel's references myHDMI = chan; myAFE = chan / 2; myFPGA = (ushort)(chan / 4); HDMIs[chan] = new HDMIchan(); HDMIs[chan].J = connector++; // load the trims for (int idx = 0; idx < 4; idx++) { newTrim = new TrimSignal(); // DMMchan.get auto increments to the correct DMM channel signal newTrim.myMeasurements.myDmm.myDMMchannel = TekScope.DMMchan; newTrim.voltageSignal_ID = chan + idx; newTrim.signalType = SignalType.Trim; newTrim.myHDMI_ID = myHDMI; newTrim.myAFE_ID = myAFE; newTrim.myFPGA_ID = myFPGA; newTrim.signalIndex = (ushort)((chan * 4 + idx) % 16); //newTrim.myClient = client; newTrim.regList = arrReg; newTrim.SetRegister(); newTrim.name = "Trim." + newTrim.myFPGA_ID.ToString() + "." + newTrim.signalIndex.ToString("00"); HDMIs[chan].Trims[idx] = newTrim; //build the HDMIs entry Trims.Add(HDMIs[chan].Trims[idx]); //Add it to the trims while its here Voltages[vcount++] = HDMIs[chan].Trims[idx]; //Add it to the voltages while its here } //load the Bias newBias = new BiasSignal(); newBias.myMeasurements.myDmm.myDMMchannel = TekScope.DMMchan; newBias.voltageSignal_ID = chan + 5; newBias.signalType = SignalType.Bias; newBias.myHDMI_ID = myHDMI; newBias.myHDMI = HDMIs[myHDMI]; newBias.myAFE_ID = myAFE; newBias.myFPGA_ID = myFPGA; newBias.signalIndex = (ushort)((chan % 4) / 2); //newBias.myClient = client; newBias.regList = arrReg; newBias.SetRegister(); newBias.name = "Bias[" + (chan % 2).ToString() + "]." + newBias.myFPGA_ID.ToString() + "." + newBias.signalIndex.ToString("00"); //Cant add it to the Biases because this is generating BiasSignals and Biases is for BiasChannel i.e each BiasChannel Biases has 2 BiasSignals HDMIs[chan].Bias = newBias; // build the HDMIs entry Voltages[vcount++] = HDMIs[chan].Bias; //Add it to the voltages while its here //load the LED newLED = new LEDsignal(); newLED.myMeasurements.myDmm.myDMMchannel = TekScope.DMMchan; newLED.voltageSignal_ID = chan + 6; newLED.signalType = SignalType.Bias; newLED.myHDMI_ID = myHDMI; newLED.myHDMI = HDMIs[myHDMI]; newLED.myAFE_ID = myAFE; newLED.myFPGA_ID = myFPGA; newLED.signalIndex = (ushort)(chan % 4); //newLED.myClient = client; newLED.regList = arrReg; newLED.SetRegister(); newLED.name = "LED." + newLED.myFPGA_ID.ToString() + "." + newLED.signalIndex.ToString("00"); HDMIs[chan].LED = newLED; // build the HDMIs entry LEDs.Add(HDMIs[chan].LED); //Add it to the LEDs while its here Voltages[vcount++] = HDMIs[chan].LED; //Add it to the voltages while its here } //build the biasChannels and the AFEs BiasChannel newBiasChan; AFE newAFE; for (int afe = 0; afe < 8; afe++) { // load the Biases. 8 biases per FEB newBiasChan = new BiasChannel(); newAFE = new AFE(); newBiasChan.myAFE_ID = (int)(afe); newBiasChan.Biases[0] = HDMIs[2 * afe].Bias; // newAFE.HDMIs[0] = HDMIs[chan++]; // load the HDMIs into the AFEs newBiasChan.Biases[1] = HDMIs[2 * afe + 1].Bias; // newAFE.HDMIs[1] = HDMIs[chan]; Biases.Add(newBiasChan); newAFE.Bias = newBiasChan; AFEs.Add(newAFE); } // load the trims into the AFEs for (int afe = 0; afe < 8; afe++) { AFEs[afe].AFE_ID = afe; //set the ID number for this AFE AFEs[afe].Bias = Biases[afe]; //match the ADE to its bias //load the Trim signals for (int t = 0; t < 8; t++) { AFEs[afe].Trims[t] = Trims[afe * t]; } // load the HDMIs and LED signals AFEs[afe].HDMIs[0] = HDMIs[afe * 2]; AFEs[afe].LEDs[0] = LEDs[afe * 2]; AFEs[afe].HDMIs[1] = HDMIs[1 + (afe * 2)]; AFEs[afe].LEDs[1] = LEDs[1 + (afe * 2)]; } // load the FPGAs for (int fpga = 0; fpga < 4; fpga++) { FPGA newFPGA = new FPGA(); newFPGA.FPGA_ID = fpga; //load the 2 AFEs newFPGA.AFEs[0] = AFEs[0 + fpga * 2]; newFPGA.AFEs[1] = AFEs[1 + (fpga * 2)]; //load the 2 Biases newFPGA.Biases[0] = Biases[0 + fpga * 2]; newFPGA.Biases[1] = Biases[1 + (fpga * 2)]; //TODO: FIX BIAS BUG //load the 4 LEDs newFPGA.LEDs[0] = LEDs[0 + fpga * 4]; newFPGA.LEDs[1] = LEDs[1 + (fpga * 4)]; newFPGA.LEDs[2] = LEDs[2 + (fpga * 4)]; newFPGA.LEDs[3] = LEDs[3 + (fpga * 4)]; //load the 4 HDMIs newFPGA.HDMIs[0] = HDMIs[0 + fpga * 4]; newFPGA.HDMIs[1] = HDMIs[1 + (fpga * 4)]; newFPGA.HDMIs[2] = HDMIs[2 + (fpga * 4)]; newFPGA.HDMIs[3] = HDMIs[3 + (fpga * 4)]; //load the 16 Trims for (int t = 0; t < 16; t++) { newFPGA.Trims[t] = Trims[fpga * t]; } // add it to the list FPGAs.Add(newFPGA); } // now that all lists are built, link the FPGA, AFE, and BiasChannel objects foreach (AFE afe in AFEs) { afe.myFPGA = FPGAs[afe.myFPGA_ID]; } foreach (BiasChannel bc in Biases) { bc.myAFE = AFEs[bc.myAFE_ID]; } foreach (VoltageSignal v in Voltages) { v.myAFE = AFEs[v.myAFE_ID]; } }