public string GetCoeff(Coeff coeff, int channel) { lock (syncRoot) { string coeffName = coeff.ToString(); try { DUTCoeffControlByPN.CoeffInfo coeffInfo = dataTable_DUTCoeffControlByPN.GetOneInfoFromTable(coeffName, channel); EnterEngMode(coeffInfo.Page); string value = EEPROM_SNOEC.ReadCoef(DUT_USB_Port, 0xA0, coeffInfo.StartAddress, coeffInfo.Format); //Log.SaveLogToTxt("Get " + coeffName + " is " + value); return(value); } catch { //Log.SaveLogToTxt("Failed to get value of " + coeffName); return(Algorithm.MyNaN.ToString()); } } }
public override bool SetCoeff(Coeff coeff, int channel, string value) { lock (syncRoot) { try { string coeffName = coeff.ToString(); DUTCoeffControlByPN.CoeffInfo coeffInfo = dataTable_DUTCoeffControlByPN.GetOneInfoFromTable(coeffName, channel); EnterEngMode(coeffInfo.Page); bool result = EEPROM.SetCoef(TestPlanParaByPN.DUT_USB_Port, 0xA0, coeffInfo.StartAddress, value, coeffInfo.Format); Log.SaveLogToTxt("Set " + coeffName + " to " + value); return(result); } catch (Exception ex) { Log.SaveLogToTxt(ex.ToString()); return(false); } } }
public override string ToString() { if (Type == 1) { return(Part.ToString()); } List <string> polys = new List <string>(); if (Type == 2) { foreach (Polynomial poly in Polynomials) { polys.Add(poly.ToString()); } string str = "(" + string.Join("+", polys) + ")"; if (Power != 1) { str = str + "^" + Power; } if (Coeff == -1) { str = "-" + str; } else if (Coeff != 1) { str = Coeff + "" + str; } return(str.Replace("+-", " - ")); } else { List <string> polysDown = new List <string>(); if (Coeff != 1 && Coeff != -1) { polys.Add(Coeff.ToString()); } foreach (Polynomial poly in Polynomials) { if (poly.Power > 0) { polys.Add(poly.ToString()); } else if (poly.Power < 0) { polysDown.Add((poly ^ -1).ToString()); } } string str; if (polys.Count > 0) { if (Coeff != -1) { if (polys.Count == 1 && polys[0].StartsWith("(") && polys[0].EndsWith(")")) { str = polys[0].Substring(1, polys[0].Length - 2); } else { str = string.Join("", polys); } } else { str = '-' + string.Join("", polys); } } else { str = Coeff.ToString(); } if (polysDown.Count == 1 && polysDown[0].StartsWith("(") && polysDown[0].EndsWith(")")) { polysDown[0] = polysDown[0].Substring(1, polysDown[0].Length - 2); } if (polysDown.Count > 0) { str = @"\frac{" + str + "}{" + string.Join("", polysDown) + "}"; } if (Power != 1) { str = "(" + str + ")^" + Power; } return(str); } }