public bool VerifySpt(string SptNamePath, ref string FileFullPath) { SL_IO_Util IoUtil = new SL_IO_Util(); string rootName = Path.GetDirectoryName(SptNamePath); string fileName = Path.GetFileName(SptNamePath); if (String.IsNullOrEmpty(rootName)) { string FullPath = Path.Combine(Setting.ExeImgDirPath, fileName); if (IoUtil.isFileExist(FullPath)) { FileFullPath = FullPath; return(true); } FullPath = Path.Combine(Setting.ExeSysDirPath, fileName); if (IoUtil.isFileExist(FullPath)) { FileFullPath = FullPath; return(true); } } else { if (IoUtil.isFileExist(SptNamePath)) { FileFullPath = SptNamePath; return(true); } } return(false); }
public bool isFileExist(string ImagePath) { SL_IO_Util imgUtil = new SL_IO_Util(); string fullPath = System.IO.Directory.GetCurrentDirectory() + "\\" + ImagePath; if (imgUtil.isFileExist(ImagePath)) { this.ImgPath = ImagePath; return(true); } if (imgUtil.isFileExist(fullPath)) { this.ImgPath = fullPath; return(true); } return(false); }
public bool isFileExist(string ImagePath) { SL_IO_Util imgUtil = new SL_IO_Util(); string fullPath = Setting.ExeImgDirPath + "\\" + ImagePath; if (imgUtil.isFileExist(ImagePath)) { this.ImgPath = ImagePath; return(true); } if (imgUtil.isFileExist(fullPath)) { this.ImgPath = fullPath; return(true); } return(false); }
private bool InstrScopeImage(int Count, string instruCmd, ref string RdStr) { bool ret = true; string strPath = null, FileName = null; SL_IO_Util IOUtil = new SL_IO_Util(); byte[] ScopeScreenResultsArray; // Screen Results array. int g_ScreenLength; VisaInstrument visaScope = new VisaInstrument(EquipUtil[Count].getInstrName()); //ScopeList.SimpleScopeGraph(devices[1], ":DISPLAY:DATA? PNG, SCREEN, COLOR\r\n"); // Download the screen image. // ----------------------------------------------------------- visaScope.SetTimeoutSeconds(30000); visaScope.DoCommand(":STOP"); visaScope.DoCommand(":HARDcopy:INKSaver OFF"); // Get the screen data. g_ScreenLength = visaScope.DoQueryIEEEBlock(":DISPlay:DATA? PNG, COLor", out ScopeScreenResultsArray); if (instruCmd.CompareTo("auto") == 0) { FileName = "Scope_" + DateTime.Now.ToLocalTime().ToString("yyyyMMdd-HHmmss") + ".png"; } else { FileName = instruCmd; } strPath = Setting.ExeScopeDirPath + "\\" + FileName; if (IOUtil.isFileExist(strPath)) { IOUtil.FileDelete(strPath); } if (IOUtil.GetExtName(strPath).CompareTo("png") != 0) { strPath += ".png"; } FileStream fStream = File.Open(strPath, FileMode.Create); fStream.Write(ScopeScreenResultsArray, 0, g_ScreenLength); fStream.Close(); visaScope.DoCommand(":RUN"); visaScope.Close(); return(ret); }
public int CompareGrpah(string CmpGraphFile, ref string SysMsg, ref List <string> lCmpInfo) { int ret = SystemInfo.ERROR_RESULT_OK; string AddrTmp = null; SL_IO_Util FileVerfiy = new SL_IO_Util(); if (!FileVerfiy.isFileExist(ImgPath)) { return(SystemInfo.ERROR_CMP_FILENOTEXIST); } if (!FileVerfiy.isFileExist(CmpGraphFile)) { return(SystemInfo.ERROR_CMP_FILENOTEXIST); } Bitmap DefaultBmp = new Bitmap(ImgPath); Bitmap CmpBmp = new Bitmap(CmpGraphFile); Rectangle DefaultRect = new Rectangle(0, 0, DefaultBmp.Width, DefaultBmp.Height); Rectangle CmpRect = new Rectangle(0, 0, CmpBmp.Width, CmpBmp.Height); System.Drawing.Imaging.BitmapData DefaultBmpData = DefaultBmp.LockBits(DefaultRect, System.Drawing.Imaging.ImageLockMode.ReadWrite, DefaultBmp.PixelFormat); System.Drawing.Imaging.BitmapData CmpBmpData = CmpBmp.LockBits(CmpRect, System.Drawing.Imaging.ImageLockMode.ReadWrite, CmpBmp.PixelFormat); // Get the address of the first line. IntPtr DefualtPtr = DefaultBmpData.Scan0; IntPtr CmpPtr = CmpBmpData.Scan0; // Declare an array to hold the bytes of the bitmap. int DefaultBytes = Math.Abs(DefaultBmpData.Stride) * DefaultBmp.Height; int CmpBytes = Math.Abs(CmpBmpData.Stride) * CmpBmpData.Height; int ResultBytes = Math.Abs(DefaultBmpData.Stride) * DefaultBmpData.Height; byte[] DrgbValues = new byte[DefaultBytes]; byte[] CrgbValues = new byte[CmpBytes]; byte[] RrgbValues = new byte[ResultBytes]; // Copy the RGB values into the array. System.Runtime.InteropServices.Marshal.Copy(DefualtPtr, DrgbValues, 0, DefaultBytes); System.Runtime.InteropServices.Marshal.Copy(CmpPtr, CrgbValues, 0, CmpBytes); // Set every third value to 255. A 24bpp bitmap will look red. for (int Counter = 0; Counter < DrgbValues.Length; Counter += 3) { if (DrgbValues[Counter] == CrgbValues[Counter] && DrgbValues[Counter + 1] == CrgbValues[Counter + 1] && DrgbValues[Counter + 2] == CrgbValues[Counter + 2]) { RrgbValues[Counter] = RrgbValues[Counter + 1] = RrgbValues[Counter + 2] = 255; } else { RrgbValues[Counter + 2] = 255; RrgbValues[Counter + 1] = RrgbValues[Counter] = 0; AddrTmp = CountLocation(DefaultBmp.Width, DefaultBmp.Height, Counter); ShowCmpMsg(ref lCmpInfo, AddrTmp, DrgbValues[Counter + 2], DrgbValues[Counter + 1], DrgbValues[Counter], CrgbValues[Counter + 2], CrgbValues[Counter + 1], CrgbValues[Counter]); ret = SystemInfo.ERROR_CMP_ERROR; } } // Copy the RGB values back to the bitmap System.Runtime.InteropServices.Marshal.Copy(DrgbValues, 0, DefualtPtr, DefaultBytes); System.Runtime.InteropServices.Marshal.Copy(CrgbValues, 0, CmpPtr, CmpBytes); // Unlock the bits. DefaultBmp.UnlockBits(DefaultBmpData); CmpBmp.UnlockBits(CmpBmpData); ResultBmp = CreateBmp(RrgbValues, DefaultBmp.Width, DefaultBmp.Height); return(ret); }