public bool WriteChipDAC(NameOfChipDAC enumName, object writeDAC) { lock (syncRoot) { for (int i = 0; i < GlobalParaByPN.TotalChCount; i++) { if (!this.WriteChipDAC(enumName, i + 1, writeDAC)) { return(false); } } return(true); } }
public override bool ReadChipDAC(NameOfChipDAC enumName, int channel, out int readDAC) { lock (syncRoot) { readDAC = 0; string filter = "ItemName = " + "'" + enumName.ToString() + "'"; DataRow[] foundRows = this.dataTable_ChipControlByPN.Select(filter); for (int row = 0; row < foundRows.Length; row++) { if (Convert.ToInt32(foundRows[row]["ModuleLine"]) == channel) { byte chipLine = Convert.ToByte(foundRows[row]["ChipLine"]); byte driveType = Convert.ToByte(foundRows[row]["DriveType"]); int regAddress = Convert.ToInt32(foundRows[row]["RegisterAddress"]); byte length = Convert.ToByte(foundRows[row]["Length"]); bool endianness = Convert.ToBoolean(foundRows[row]["Endianness"]); byte startBit = Convert.ToByte(foundRows[row]["StartBit"]); byte endBit = Convert.ToByte(foundRows[row]["EndBit"]); byte chipset = 0x01; switch (driveType) { case 0: chipset = 0x01; break; case 1: chipset = 0x02; break; case 2: chipset = 0x04; break; case 3: chipset = 0x08; break; default: chipset = 0x01; break; } readDAC = (int)Write_Store_Read_ChipReg(null, length, endianness, regAddress, chipLine, chipset, ChipOperation.Read); Log.SaveLogToTxt("Read " + enumName.ToString() + " failed"); return(true); } } return(false); } }
public bool ReadChipDAC(NameOfChipDAC enumName, out int readDAC) { lock (syncRoot) { readDAC = 0; for (int i = 0; i < GlobalParaByPN.TotalChCount; i++) { if (!this.ReadChipDAC(enumName, i + 1, out readDAC)) { return(false); } } return(true); } }
public override bool WriteChipDAC(NameOfChipDAC enumName, int channel, object writeDAC) { lock (syncRoot) { string filter = "ItemName = " + "'" + enumName.ToString() + "'"; DataRow[] foundRows = this.dataTable_ChipControlByPN.Select(filter); for (int row = 0; row < foundRows.Length; row++) { if (Convert.ToInt32(foundRows[row]["ModuleLine"]) == channel) { byte chipLine = Convert.ToByte(foundRows[row]["ChipLine"]); byte driveType = Convert.ToByte(foundRows[row]["DriveType"]); int regAddress = Convert.ToInt32(foundRows[row]["RegisterAddress"]); byte length = Convert.ToByte(foundRows[row]["Length"]); bool endianness = Convert.ToBoolean(foundRows[row]["Endianness"]); byte startBit = Convert.ToByte(foundRows[row]["StartBit"]); byte endBit = Convert.ToByte(foundRows[row]["EndBit"]); byte chipset = 0x01; switch (driveType) { case 0: chipset = 0x01; break; case 1: chipset = 0x02; break; case 2: chipset = 0x04; break; case 3: chipset = 0x08; break; default: chipset = 0x01; break; } bool isFull = Algorithm.BitNeedManage(length, startBit, endBit); if (!isFull)//寄存器全位,不需要做任何处理 { for (int k = 0; k < 3; k++) { if (!(bool)Write_Store_Read_ChipReg(writeDAC, length, endianness, regAddress, chipLine, chipset, ChipOperation.Write)) { return(false);//写DAC值 } int readDAC = (int)Write_Store_Read_ChipReg(writeDAC, length, endianness, regAddress, chipLine, chipset, ChipOperation.Read); if (readDAC == Convert.ToInt16(writeDAC)) { return(true); } } } else//寄存器位缺,需要做任何处理 { for (int k = 0; k < 3; k++) { int readDAC = (int)Write_Store_Read_ChipReg(writeDAC, length, endianness, regAddress, chipLine, chipset, ChipOperation.Read); int joinValue = Algorithm.WriteJointBitValue((int)writeDAC, readDAC, length, startBit, endBit); if (!(bool)Write_Store_Read_ChipReg(joinValue, length, endianness, regAddress, chipLine, chipset, ChipOperation.Write)) { return(false);//写入寄存器的全位DAC值 } readDAC = (int)Write_Store_Read_ChipReg(writeDAC, length, endianness, regAddress, chipLine, chipset, ChipOperation.Read); int readJoinValue = Algorithm.ReadJointBitValue(readDAC, length, startBit, endBit); if (readJoinValue == Convert.ToInt16(writeDAC)) { return(true); } } } Log.SaveLogToTxt("Writer " + enumName.ToString() + " failed"); return(false); } } return(false); } }
public virtual bool ReadChipDAC(NameOfChipDAC enumName, int channel, out int readDAC) { readDAC = 0; return(false); }
public virtual bool WriteChipDAC(NameOfChipDAC enumName, int channel, object writeDAC) { return(false); }