/// <summary> /// 抓取相机的图像,输出Halcon格式 /// </summary> public override ImageAll GrabImageHal() { g_MtGrabImage.WaitOne(); ImageAll imageAll = new ImageAll(); try { if (!BlOpen)//如果相机打开失败 { return(null); } #if (SDK) try { SetTrriggerMode();//设置软触发 g_ManagedCameraBase.RetrieveBuffer(g_RawImage); } catch (Exception ex) { Log.L_I.WriteError(NameClass, ex); try { if (g_BaseParCamera.BlUsingTrigger) //使用软触发 { g_ManagedCameraBase.WriteRegister(0x62C, 0x80000000); //发送软触发指令 } g_ManagedCameraBase.RetrieveBuffer(g_RawImage); } catch { if (g_BaseParCamera.BlUsingTrigger) //使用软触发 { g_ManagedCameraBase.WriteRegister(0x62C, 0x80000000); //发送软触发指令 } g_ManagedCameraBase.RetrieveBuffer(g_RawImage); } } //将图像转换为Halcon格式 imageAll.Ho_Image = ConvertHobject(); imageAll.BitmapSource = null; PathDirectory p = new PathDirectory(); imageAll.Time = p.GetShortTimeName(); #endif return(imageAll); } catch (Exception ex) { Log.L_I.WriteError(NameClass, ex); return(null); } finally { g_MtGrabImage.ReleaseMutex(); } }
public void ConstructPathDirectoryWithNullFileSystem() { // Execute var directory = new PathDirectory<string>(a_pathTree: null, a_path: "\\"); // Assert Assert.AreEqual("\\", directory.Path); Assert.IsNotNull(directory.FileSystem); }
public void GetChildFilesWithNullSearchPattern() { // Setup var fileSystem = new PathTree <string>(); var directory = new PathDirectory <string>(fileSystem, @"x:\mydirectory"); // Execute directory.Files(a_pattern: null); }
public void ConstructPathDirectoryWithNullFileSystem() { // Execute var directory = new PathDirectory <string>(a_pathTree: null, a_path: "\\"); // Assert Assert.AreEqual("\\", directory.Path); Assert.IsNotNull(directory.FileSystem); }
public void GetDirectoryByNameWithNull() { // Setup var fileSystem = new PathTree <string>(); var directory = new PathDirectory <string>(fileSystem, @"x:\mydirectory"); // Execute directory.File(a_name: null); }
public void DeleteNotExistingDirectory() { // Setup var fileSystem = new PathTree <string>(); var directory = new PathDirectory <string>(fileSystem, "\\this\\is\\a\\directory"); // Execute directory.Delete(); }
/// <summary> /// 抓取相机的图像,输出所有的格式 /// </summary> public override ImageAll GrabImageAll() { ImageAll imageAll = new ImageAll(); try { if (!BlOpen || g_BaseParCamera.BlUsingTrigger) //外触发模式不进行All抓取 { return(null); } #if (SDK) if (g_Camera != null && g_Camera.IsOpen) { if (g_BaseParCamera.BlUsingTrigger && g_Camera.StreamGrabber.IsGrabbing) { g_Camera.ExecuteSoftwareTrigger(); g_AutoResetEvent.WaitOne(500); } else { try { g_Camera.StreamGrabber.Start(); g_GrabResult = g_Camera.StreamGrabber.RetrieveResult(5000, TimeoutHandling.ThrowException); } catch (Exception ex) { Log.L_I.WriteError(NameClass, ex); //The stream grabber is already grabbing.说明取图太快,或者两个线程取图冲突 } } } using (g_GrabResult) { if (g_GrabResult != null && g_GrabResult.GrabSucceeded) { imageAll.Ho_Image = ConvertHobject(g_GrabResult); imageAll.BitmapSource = ConvertImageBitmap(g_GrabResult); PathDirectory p = new PathDirectory(); imageAll.TimeShort = p.GetShortTimeName();//图像抓取短时间 imageAll.Time = p.GetTimeName(); } } g_Camera.StreamGrabber.Stop(); #endif return(imageAll); } catch (Exception ex) { Log.L_I.WriteError(NameClass, ex); return(null); } }
public void CopyInOnNotExistingDirectory() { // Setup var fileSystem = new PathTree <string>(); var directory = new PathDirectory <string>(@"\directory"); var file = fileSystem.CreateFile(@"\file1.dat", "Value"); // Execute directory.CopyIn(file); }
public void CopyInOnNotExistingDirectory() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(@"\directory"); var file = fileSystem.CreateFile(@"\file1.dat", "Value"); // Execute directory.CopyIn(file); }
public void ConstructPathDirectory() { // Setup var fileSystem = new PathTree<string>(); // Execute var directory = new PathDirectory<string>(fileSystem, "\\"); // Assert Assert.AreEqual("\\", directory.Path); Assert.AreSame(fileSystem, directory.FileSystem); }
public void GetExistsWithNonexistingFile() { // Setup var fileSystem = new PathTree <string>(); var directory = new PathDirectory <string>(fileSystem, "\\directory\\does\\not\\exist"); // Execute var result = directory.Exists; // Assert Assert.IsFalse(result); }
public void GetName() { // Setup var fileSystem = new PathTree <string>(); var directory = new PathDirectory <string>(fileSystem, "\\this\\is\\a\\directory"); // Execute var result = directory.Name; // Assert Assert.AreEqual("directory", result); }
public void GetDirectoryPathForNotExistingChild() { // Setup var fileSystem = new PathTree <string>(); var directory = new PathDirectory <string>(fileSystem, @"x:\mydirectory"); // Execute var result = directory.DirectoryPath("Directory4"); // Assert Assert.AreEqual(@"x:\mydirectory\Directory4", result); }
public void GetIsEmptyOnNotExistingDirectory() { // Setup var fileSystem = new PathTree <string>(); var directory = new PathDirectory <string>(fileSystem, "\\directory\\does\\not\\exist"); // Execute var result = directory.IsEmpty; // Assert Assert.IsFalse(result); }
public void CreateDirectory() { // Setup var fileSystem = new PathTree <string>(); var directory = new PathDirectory <string>(fileSystem, "\\this\\is\\a\\directory"); // Execute directory.Create(); // Assert Assert.IsTrue(directory.Exists); }
public void ConstructPathDirectory() { // Setup var fileSystem = new PathTree <string>(); // Execute var directory = new PathDirectory <string>(fileSystem, "\\"); // Assert Assert.AreEqual("\\", directory.Path); Assert.AreSame(fileSystem, directory.FileSystem); }
public void GetParent() { // Setup var fileSystem = new PathTree <string>(); var directory = new PathDirectory <string>(fileSystem, "\\this\\is\\a\\directory"); // Execute var result = directory.Parent; // Assert Assert.IsNotNull(result); Assert.AreEqual("a", result.Name); }
public void GetExistsOnExistingFile() { // Setup var path = "\\directory\\does\\exist"; var fileSystem = new PathTree <string>(); fileSystem.CreateDirectory(path); var directory = new PathDirectory <string>(fileSystem, path); // Execute var result = directory.Exists; // Assert Assert.IsTrue(result); }
public void GetChildDirectories() { // Setup var fileSystem = new PathTree <string>(); fileSystem.CreateDirectory(@"x:\mydirectory\directory1"); fileSystem.CreateDirectory(@"x:\mydirectory\directory2\child"); fileSystem.CreateFile(@"x:\mydirectory\directory3\file.rgb", "Value"); var directory = new PathDirectory <string>(fileSystem, @"x:\mydirectory"); // Execute var result = directory.Directories(); // Assert Assert.AreEqual(3, result.Count()); }
public void GetChildFilesBySearchPattern() { // Setup var fileSystem = new PathTree <string>(); fileSystem.CreateFile(@"x:\mydirectory\file1.dat", "Value"); fileSystem.CreateFile(@"x:\mydirectory\file2.dat", "Value"); fileSystem.CreateFile(@"x:\mydirectory\file3.css", "Value"); fileSystem.CreateFile(@"x:\mydirectory\otherdirectory\file4.dat", "Value"); var directory = new PathDirectory <string>(fileSystem, @"x:\mydirectory"); // Execute var filePaths = directory.Files("*.css"); // Assert Assert.AreEqual(1, filePaths.Count()); }
public void GetNotExistingChildDirectoryByName() { // Setup var fileSystem = new PathTree <string>(); fileSystem.CreateDirectory(@"x:\mydirectory\directory1"); fileSystem.CreateDirectory(@"x:\mydirectory\directory2\child"); fileSystem.CreateFile(@"x:\mydirectory\directory3\file.rgb", "Value"); var directory = new PathDirectory <string>(fileSystem, @"x:\mydirectory"); // Execute var result = directory.Directory("Directory4"); // Assert Assert.AreEqual("Directory4", result.Name); Assert.IsFalse(result.Exists); }
public void CustomTest_I() { var fileSystem = new PathTree <string>(); fileSystem.CreateDirectory(@"\Root\Directory"); fileSystem.CreateDirectory(@"\Root\Directory\Sub1"); fileSystem.CreateDirectory(@"\Root\Directory\Sub2"); fileSystem.CreateDirectory(@"\Root\Directory\Sub3"); fileSystem.CreateFile(@"\Root\Directory\File1.hsf", "Value"); fileSystem.CreateFile(@"\Root\Directory\File2.hsf", "Value"); fileSystem.CreateFile(@"\Root\Directory\File3.hsf", "Value"); var directory = new PathDirectory <string>(fileSystem, @"\"); var result = directory.Directory(@"Root\Directory\Sub1").Exists; Assert.IsTrue(result); }
public void GetFilePathByName() { // Setup var created = DateTime.UtcNow; var lastModified = DateTime.UtcNow; var fileSystem = new PathTree <string>(); fileSystem.CreateFile(@"x:\mydirectory\file1.dat", "Value1"); fileSystem.CreateFile(@"x:\mydirectory\file2.dat", "Value2"); fileSystem.CreateFile(@"x:\mydirectory\file3.dat", "Value3"); fileSystem.CreateFile(@"x:\mydirectory\otherdirectory\file4.dat", "Value4"); var directory = new PathDirectory <string>(fileSystem, @"x:\mydirectory"); // Execute var result = directory.FilePath("File1.dat"); // Assert Assert.AreEqual(@"x:\mydirectory\File1.dat", result); }
public void GetChildDirectories() { // Setup var fileSystem = new PathTree<string>(); fileSystem.CreateDirectory(@"x:\mydirectory\directory1"); fileSystem.CreateDirectory(@"x:\mydirectory\directory2\child"); fileSystem.CreateFile(@"x:\mydirectory\directory3\file.rgb", "Value"); var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory"); // Execute var result = directory.Directories(); // Assert Assert.AreEqual(3, result.Count()); }
public void GetChildDirectoryByNameWithNull() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory"); // Execute var result = directory.Directory(a_name: null); }
public void GetFilePathByName() { // Setup var created = DateTime.UtcNow; var lastModified = DateTime.UtcNow; var fileSystem = new PathTree<string>(); fileSystem.CreateFile(@"x:\mydirectory\file1.dat", "Value1"); fileSystem.CreateFile(@"x:\mydirectory\file2.dat", "Value2"); fileSystem.CreateFile(@"x:\mydirectory\file3.dat", "Value3"); fileSystem.CreateFile(@"x:\mydirectory\otherdirectory\file4.dat", "Value4"); var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory"); // Execute var result = directory.FilePath("File1.dat"); // Assert Assert.AreEqual(@"x:\mydirectory\File1.dat", result); }
public void GetChildFilesBySearchPattern() { // Setup var fileSystem = new PathTree<string>(); fileSystem.CreateFile(@"x:\mydirectory\file1.dat", "Value"); fileSystem.CreateFile(@"x:\mydirectory\file2.dat", "Value"); fileSystem.CreateFile(@"x:\mydirectory\file3.css", "Value"); fileSystem.CreateFile(@"x:\mydirectory\otherdirectory\file4.dat", "Value"); var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory"); // Execute var filePaths = directory.Files("*.css"); // Assert Assert.AreEqual(1, filePaths.Count()); }
public void GetIsEmptyOnNotExistingDirectory() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, "\\directory\\does\\not\\exist"); // Execute var result = directory.IsEmpty; // Assert Assert.IsFalse(result); }
public void GetChildFilesWithNullSearchPattern() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory"); // Execute directory.Files(a_pattern: null); }
public void GetExistsOnExistingFile() { // Setup var path = "\\directory\\does\\exist"; var fileSystem = new PathTree<string>(); fileSystem.CreateDirectory(path); var directory = new PathDirectory<string>(fileSystem, path); // Execute var result = directory.Exists; // Assert Assert.IsTrue(result); }
public void GetDirectoryPathForNotExistingChild() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory"); // Execute var result = directory.DirectoryPath("Directory4"); // Assert Assert.AreEqual(@"x:\mydirectory\Directory4", result); }
public void GetFileByNameWithNull() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory"); // Execute directory.File(a_name: null); }
public void GetName() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, "\\this\\is\\a\\directory"); // Execute var result = directory.Name; // Assert Assert.AreEqual("directory", result); }
public void GetNotExistingChildDirectoryByName() { // Setup var fileSystem = new PathTree<string>(); fileSystem.CreateDirectory(@"x:\mydirectory\directory1"); fileSystem.CreateDirectory(@"x:\mydirectory\directory2\child"); fileSystem.CreateFile(@"x:\mydirectory\directory3\file.rgb", "Value"); var directory = new PathDirectory<string>(fileSystem, @"x:\mydirectory"); // Execute var result = directory.Directory("Directory4"); // Assert Assert.AreEqual("Directory4", result.Name); Assert.IsFalse(result.Exists); }
/// <summary> /// 抓取相机的图像,输出Halcon格式 /// </summary> public override ImageAll GrabImageHal() { ImageAll imageAll = new ImageAll(); try { if (!BlOpen) { return(null); } #if (SDK) //★★★ 确保相机当前是采集状态 && 确保相机可以接收软件触发指令 if (g_Camera != null && g_Camera.IsOpen) { if (g_BaseParCamera.BlUsingTrigger)//使用软触发 { if (ImageAll_Q.Count > 0) { ImageAll im = ImageAll_Q.Peek(); ImageAll_Q.Dequeue(); //出站 if (ImageAll_Q.Count > 20) //认为溢出 { ImageAll_Q.Clear(); Log.L_I.WriteError(NameClass, "图像外触发溢出"); } return(im); } else { return(null); } } else { try { g_Camera.StreamGrabber.Start(); g_GrabResult = g_Camera.StreamGrabber.RetrieveResult(5000, TimeoutHandling.ThrowException); } catch (Exception ex) { Log.L_I.WriteError(NameClass, ex); } } } using (g_GrabResult) { if (g_GrabResult != null && g_GrabResult.GrabSucceeded) { imageAll.Ho_Image = ConvertHobject(g_GrabResult); imageAll.BitmapSource = null; PathDirectory p = new PathDirectory(); imageAll.Time = p.GetTimeName(); imageAll.TimeShort = p.GetShortTimeName(); } } g_Camera.StreamGrabber.Stop(); #endif return(imageAll); } catch (Exception ex) { Log.L_I.WriteError(NameClass, ex); return(null); } }
public void DeleteDirectory() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, "\\this\\is\\a\\directory"); directory.Create(); // Execute directory.Delete(); // Assert Assert.IsFalse(directory.Exists); }
public void DeleteNotExistingDirectory() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, "\\this\\is\\a\\directory"); // Execute directory.Delete(); }
public void GetParent() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, "\\this\\is\\a\\directory"); // Execute var result = directory.Parent; // Assert Assert.IsNotNull(result); Assert.AreEqual("a", result.Name); }
public void CustomTest_I() { var fileSystem = new PathTree<string>(); fileSystem.CreateDirectory(@"\Root\Directory"); fileSystem.CreateDirectory(@"\Root\Directory\Sub1"); fileSystem.CreateDirectory(@"\Root\Directory\Sub2"); fileSystem.CreateDirectory(@"\Root\Directory\Sub3"); fileSystem.CreateFile(@"\Root\Directory\File1.hsf", "Value"); fileSystem.CreateFile(@"\Root\Directory\File2.hsf", "Value"); fileSystem.CreateFile(@"\Root\Directory\File3.hsf", "Value"); var directory = new PathDirectory<string>(fileSystem, @"\"); var result = directory.Directory(@"Root\Directory\Sub1").Exists; Assert.IsTrue(result); }
public void GetExistsWithNonexistingFile() { // Setup var fileSystem = new PathTree<string>(); var directory = new PathDirectory<string>(fileSystem, "\\directory\\does\\not\\exist"); // Execute var result = directory.Exists; // Assert Assert.IsFalse(result); }