public Dispers(Dispers disp, bool read_only) { ReadOnly = read_only; Functions = new Function[disp.Functions.Length]; SSizes = (int[])disp.SSizes.Clone(); for (int i = 0; i < Functions.Length; i++) { Functions[i] = new Function(disp.Functions[i]); } InitBasePixels(); }
public void AddRange(float[] data, int sn, Dispers disp) { SpAtlasPixel[] data_hi = new SpAtlasPixel[data.Length * 10]; for (int pixel = 0; pixel < data.Length - 1; pixel++) { float ly_from = (float)disp.GetLyByLocalPixel(sn, 0); float val_from = data[0]; float ly_to = (float)disp.GetLyByLocalPixel(sn, data.Length - 1); float val_to = data[data.Length - 1]; int from = pixel * 10; //for(data_hi) } int insert_into = 0; if (PixelList.Count > 0) { float ly_from = (float)disp.GetLyByLocalPixel(sn, 0); float ly_to = (float)disp.GetLyByLocalPixel(sn, data.Length - 1); if (ly_from > PixelList[PixelList.Count - 1].Ly || ly_to < PixelList[0].Ly) { Load(); throw new Exception("Нельзя создать атлаc с разрывами..."); } if (ly_from < PixelList[0].Ly) { while (PixelList.Count > 0 && PixelList[0].Ly < ly_to) { PixelList.RemoveAt(0); } } else { for (; insert_into < PixelList.Count && PixelList[insert_into].Ly < ly_from; insert_into++) { ; } if (ly_to > PixelList[PixelList.Count - 1].Ly) { PixelList.RemoveRange(insert_into, PixelList.Count - insert_into); } else { } } return; } for (int pixel = 0; pixel < data.Length; pixel++) { PixelList.Insert(insert_into, new SpAtlasPixel((float)disp.GetLyByLocalPixel(sn, pixel), data[pixel])); } }
public LDbQuery() { InitializeComponent(); Common.Reg(this, "LDbQu"); ESelector.SelectorListener += new ElementSelectorAction(ElSelListener); DialogResult = DialogResult.Cancel; Common.SetupFont(this);//Font = Common.GetDefaultFont(Font); IntensTypeCbx.SelectedIndex = Common.Env.DefaultLineDb; Spectr sp = SpectroWizard.gui.tasks.TaskCheckDev.getLinkingMatrixSpectr(); Dispers disp = sp.GetDispers(); LyFromFld.Value = (decimal)disp.GetLyByLocalPixel(0, 0); int[] ss = disp.GetSensorSizes(); LyToFld.Value = (decimal)disp.GetLyByLocalPixel(ss.Length - 1, ss[ss.Length - 1]); }
public override bool Run(out string log) { log = ""; try { #region testing... Dispers disp = new Dispers(); int test = 1; string tmps; int tmpi; int[] ss = Common.Dev.Reg.GetSensorSizes(); bool result; log += "Test#" + test + " Comments and empty strings..."; disp.Compile("#comment", false, out result); if (disp.Errors != null) { log += Common.MLS.Get(MLSConst, "Comment error:") + disp.Errors + serv.Endl; return(false); } log += "Ok" + serv.Endl; test++; log += "Test#" + test + " Empty strings..."; disp.Compile("", false, out result); if (disp.Errors != null) { log += Common.MLS.Get(MLSConst, "Empty string error:") + disp.Errors + serv.Endl; return(false); } log += "Ok" + serv.Endl; test++; for (int i = 0; i < 8; i++) { log += "Test#" + test + " Comments and empty strings..."; tmps = ""; tmpi = i; for (int j = 0; j < 3; j++, tmpi >>= 1) { if ((tmpi & 1) == 0) { tmps += serv.Endl; } else { tmps += "#comments" + serv.Endl; } } disp.Compile(tmps, false, out result); if (disp.Errors != null) { log += Common.MLS.Get(MLSConst, "Comment and empty string error:") + disp.Errors + serv.Endl; return(false); } log += "Ok" + serv.Endl; test++; } log += "Test#" + test + " Simple setup 1 sensor"; tmps = "#comment" + serv.Endl + "s1:1" + serv.Endl + "10-100" + serv.Endl + " 20 - 200 " + serv.Endl; disp.Compile(tmps, false, out result); if (disp.Errors != null) { log += Common.MLS.Get(MLSConst, "Parsing erros") + disp.Errors + serv.Endl; return(false); } log += "Ok" + serv.Endl; test++; log += "Test#" + test + " Simple setup 2 sensor"; tmps = "#comment" + serv.Endl + "s1:1" + serv.Endl + "10-10" + serv.Endl + " 20 - 20 " + serv.Endl + serv.Endl + "s2:2" + serv.Endl + " " + (ss[0] + 2) + "-" + (ss[0] + 2) + serv.Endl + " " + (ss[0] + 200) + "-" + (ss[0] + 200) + serv.Endl; disp.Compile(tmps, false, out result); if (disp.Errors != null) { log += Common.MLS.Get(MLSConst, "Parsing erros") + disp.Errors + serv.Endl; return(false); } log += "Ok" + serv.Endl; test++; log += "Test#" + test + " Simple setup 3 sensor"; tmps = "#comment" + serv.Endl + "s1:1" + serv.Endl + "10-10" + serv.Endl + " 20 - 20 " + serv.Endl + serv.Endl + "s2:2" + serv.Endl + " " + (ss[0] + 2) + "-" + (ss[0] + 2) + serv.Endl + " " + (ss[0] + 200) + "-" + (ss[0] + 200) + serv.Endl + "s3:3" + serv.Endl + " " + (ss[1] + ss[0] + 3) + "-" + (ss[1] + ss[0] + 3) + serv.Endl + " " + (ss[1] + ss[0] + 300) + "-" + (ss[1] + ss[0] + 300) + serv.Endl; disp.Compile(tmps, false, out result); if (disp.Errors != null) { log += Common.MLS.Get(MLSConst, "Parsing erros:") + disp.Errors + serv.Endl; return(false); } log += "Ok" + serv.Endl; test++; log += "Test#" + test + " Wrong interpolation type"; tmps = "#comment" + serv.Endl + "s1:4" + serv.Endl + "10-10" + serv.Endl + " 20 - 20 " + serv.Endl + serv.Endl + "s2:2" + serv.Endl + " " + (ss[0] + 2) + "-" + (ss[0] + 2) + serv.Endl + " " + (ss[0] + 200) + "-" + (ss[0] + 200) + serv.Endl + "s3:3" + serv.Endl + " " + (ss[1] + ss[0] + 3) + "-" + (ss[1] + ss[0] + 3) + serv.Endl + " " + (ss[1] + ss[0] + 300) + "-" + (ss[1] + ss[0] + 300) + serv.Endl; disp.Compile(tmps, false, out result); if (disp.Errors == null) { log += Common.MLS.Get(MLSConst, "No error found.") + serv.Endl; return(false); } log += " Found problem: '" + disp.Errors + "' - Ok" + serv.Endl; test++; log += "Test#" + test + " Wrong pixel interval"; tmps = "#comment" + serv.Endl + "s1:1" + serv.Endl + "10-10" + serv.Endl + " 20 - 20 " + serv.Endl + serv.Endl + "s2:2" + serv.Endl + " " + (ss[0] - 2) + "-" + (ss[0] - 2) + serv.Endl + " " + (ss[0] + 200) + "-" + (ss[0] + 200) + serv.Endl + "s3:3" + serv.Endl + " " + (ss[1] + ss[0] + 3) + "-" + (ss[1] + ss[0] + 3) + serv.Endl + " " + (ss[1] + ss[0] + 300) + "-" + (ss[1] + ss[0] + 300) + serv.Endl; disp.Compile(tmps, false, out result); if (disp.Errors == null) { log += Common.MLS.Get(MLSConst, "No error found.") + serv.Endl; return(false); } log += " Found problem: '" + disp.Errors + "' - Ok" + serv.Endl; test++; log += "Test#" + test + " Links is to close"; tmps = "#comment" + serv.Endl + "s1:1" + serv.Endl + "10-10" + serv.Endl + " 20 - 20 " + serv.Endl + serv.Endl + "s2:2" + serv.Endl + " " + (ss[0] + 2) + "-" + (ss[0] + 2) + serv.Endl + " " + (ss[0] + 3) + "-" + (ss[0] + 3) + serv.Endl + "s3:3" + serv.Endl + " " + (ss[1] + ss[0] + 3) + "-" + (ss[1] + ss[0] + 3) + serv.Endl + " " + (ss[1] + ss[0] + 300) + "-" + (ss[1] + ss[0] + 300) + serv.Endl; disp.Compile(tmps, false, out result); if (disp.Errors == null) { log += Common.MLS.Get(MLSConst, "No error found.") + serv.Endl; return(false); } log += " Found problem: '" + disp.Errors + "' - Ok" + serv.Endl; test++; log += "Test#" + test + " Wrong sensor number"; tmps = "#comment" + serv.Endl + "s1:1" + serv.Endl + "10-10" + serv.Endl + " 20 - 20 " + serv.Endl + serv.Endl + "s2:2" + serv.Endl + " " + (ss[0] + 2) + "-" + (ss[0] + 2) + serv.Endl + " " + (ss[0] + 200) + "-" + (ss[0] + 200) + serv.Endl + "s3:3" + serv.Endl + " " + (ss[1] + ss[0] + 3) + "-" + (ss[1] + ss[0] + 3) + serv.Endl + " " + (ss[1] + ss[0] + 300) + "-" + (ss[1] + ss[0] + 300) + serv.Endl + "s100000:3" + serv.Endl + " " + (ss[1] + ss[0] + 3) + "-" + (ss[1] + ss[0] + 3) + serv.Endl + " " + (ss[1] + ss[0] + 300) + "-" + (ss[1] + ss[0] + 300) + serv.Endl; disp.Compile(tmps, false, out result); if (disp.Errors == null) { log += Common.MLS.Get(MLSConst, "No error found.") + serv.Endl; return(false); } log += " Found problem: '" + disp.Errors + "' - Ok" + serv.Endl; test++; string tt = "#c" + serv.Endl + "s1:1" + serv.Endl + "10-20"; bool[] ttf = { true, true, true, true, true, false, false, false, true, true,true, false, false, false, true, true,true, true }; tmps = ""; for (int i = 0; i < tt.Length; i++) { log += "Test#" + test + " Typing test..."; disp.Compile(tmps, false, out result); if (ttf[i]) { if (disp.Errors != null) { log += Common.MLS.Get(MLSConst, "Error found:") + disp.Errors + serv.Endl; return(false); } log += " - Ok" + serv.Endl; } else { if (disp.Errors == null) { log += Common.MLS.Get(MLSConst, "No error found.") + serv.Endl; return(false); } log += " Found problem: '" + disp.Errors + "' - Ok" + serv.Endl; } test++; tmps += tt[i]; } #endregion return(true); } catch (Exception ex) { log += "Fatal Error: " + ex + serv.Endl; return(false); } }