/// <summary> /// The main entry point for the application. /// </summary> /// <param name="args">The command line arguments</param> /// static void Main(string[] args) { string fileName = string.Empty; // The FileName to store the image bool printHelp = false; // Output help? string cameraID = null; // The camera ID int tellerNaam = 0; while (true) { var clientLaminator = new S7Client(); int connectionResult = clientLaminator.ConnectTo("10.0.0.151", 0, 1); if (connectionResult == 0) { Console.WriteLine("con ok"); } else { Console.WriteLine("err"); } //PARAMETERS // var Parameterbuffer = new byte[8]; // int readRest = clientLaminator.DBRead(2, 0, Parameterbuffer.Length, Parameterbuffer); // if (readRest == 0) // { // Console.WriteLine("dB2 ok"); // } // double Temperatuur = S7.GetRealAt(Parameterbuffer, 0); // Console.WriteLine(Temperatuur.ToString()); // int Druk = S7.GetIntAt(Parameterbuffer, 4); // Console.WriteLine(Druk.ToString()); // int LamiSucces = S7.GetIntAt(Parameterbuffer, 6); // Console.WriteLine(LamiSucces.ToString()); //FOTO var FotoBuffer = new byte[1]; int readReste = clientLaminator.DBRead(2000, 0, FotoBuffer.Length, FotoBuffer); if (readReste == 0) { Console.WriteLine("dB3 ok"); } //S7.SetBitAt(ref FotoBuffer, Pos: 0, Bit: 0, Value: false); bool FotoNemen = S7.GetBitAt(FotoBuffer, 0, 0); Console.WriteLine(FotoNemen.ToString()); if (FotoNemen == true) { // neem foto //CHARS var CharSerienummerbuffer = new byte[10]; int readRes = clientLaminator.DBRead(1, 0, CharSerienummerbuffer.Length, CharSerienummerbuffer); string Letter1; Letter1 = S7.GetCharsAt(CharSerienummerbuffer, 0, 1); //Console.WriteLine(Letter1); string Letter2; Letter2 = S7.GetCharsAt(CharSerienummerbuffer, 1, 1); //Console.WriteLine(Letter2); string Letter3; Letter3 = S7.GetCharsAt(CharSerienummerbuffer, 2, 1); //Console.WriteLine(Letter3); string Letter4; Letter4 = S7.GetCharsAt(CharSerienummerbuffer, 3, 1); //Console.WriteLine(Letter4); string Letter5; Letter5 = S7.GetCharsAt(CharSerienummerbuffer, 4, 1); //Console.WriteLine(Letter5); string Letter6; Letter6 = S7.GetCharsAt(CharSerienummerbuffer, 5, 1); //Console.WriteLine(Letter6); string Letter7; Letter7 = S7.GetCharsAt(CharSerienummerbuffer, 6, 1); //Console.WriteLine(Letter7); string Letter8; Letter8 = S7.GetCharsAt(CharSerienummerbuffer, 7, 1); //Console.WriteLine(Letter8); string Letter9; Letter9 = S7.GetCharsAt(CharSerienummerbuffer, 8, 1); //Console.WriteLine(Letter9); string Letter10; Letter10 = S7.GetCharsAt(CharSerienummerbuffer, 9, 1); //Console.WriteLine(Letter10); string Serienummer = Letter1 + Letter2 + Letter3 + Letter4 + Letter5 + Letter6 + Letter7 + Letter8 + Letter9 + Letter10; //Console.WriteLine(Serienummer); try { ParseCommandLine(args, ref fileName, ref printHelp, ref cameraID); if (fileName == string.Empty) { fileName = "SynchronousGrab.bmp"; } // Print out help and end program if (printHelp) { // Console.WriteLine("Usage: AsynchronousGrab [CameraID] [/i] [/h]"); // Console.WriteLine("Parameters: CameraID ID of the camera to use (using first camera if not specified)"); // Console.WriteLine(" /f FileName to save the image"); // Console.WriteLine(" /h Print out help"); } else { // Create a new Vimba entry object VimbaHelper vimbaHelper = new VimbaHelper(); vimbaHelper.Startup(); // Startup API // Open camera try { Console.WriteLine("Vimba .NET API Version {0}", vimbaHelper.GetVersion()); if (null == cameraID) { // Open first available camera // Fetch all cameras known to Vimba List <Camera> cameras = vimbaHelper.CameraList; if (cameras.Count < 0) { throw new Exception("No camera available."); } foreach (Camera currentCamera in cameras) { // Check if we can open the camera in full mode VmbAccessModeType accessMode = currentCamera.PermittedAccess; if (VmbAccessModeType.VmbAccessModeFull == (VmbAccessModeType.VmbAccessModeFull & accessMode)) { // Now get the camera ID cameraID = currentCamera.Id; } } if (null == cameraID) { throw new Exception("Could not open any camera."); } } Console.WriteLine("Opening camera with ID: " + cameraID); System.Drawing.Image img = vimbaHelper.AcquireSingleImage(cameraID); string lastDatetime = DateTime.Now.ToLongDateString(); if (File.Exists("C:\\Fotologs\\" + tellerNaam + lastDatetime + "voor laminatie" + ".bmp")) { img.Save("C:\\Fotologs\\" + tellerNaam + lastDatetime + "na laminatie" + ".bmp"); tellerNaam++; } else { img.Save("C:\\Fotologs\\" + tellerNaam + lastDatetime + "voor laminatie" + ".bmp"); } Console.WriteLine("Image is saved as: " + Serienummer); } finally { // shutdown the vimba API vimbaHelper.Shutdown(); } } } catch (VimbaException ve) { // Output in case of a vimba Exception Console.WriteLine(ve.Message); Console.Write("Return Code: " + ve.ReturnCode.ToString() + " (" + ve.MapReturnCodeToString() + ")"); } catch (Exception e) { // Output in case of a System.Exception Console.WriteLine(e.Message); } Console.WriteLine("foto genomen"); S7.GetBitAt(FotoBuffer, 0, 0); Console.WriteLine("External: " + FotoBuffer[0]); S7.SetBitAt(ref FotoBuffer, Pos: 0, Bit: 0, Value: false); Console.WriteLine("Internal: " + FotoBuffer[0]); clientLaminator.DBWrite(2000, 0, FotoBuffer.Length, FotoBuffer); } clientLaminator.Disconnect(); } }
/// <summary> /// The main entry point for the application. /// </summary> /// <param name="args">The command line arguments</param> private static void Main(string[] args) { //VimbaHelper.FrameInfos showFrameInfos = VimbaHelper.FrameInfos.Off; // Show frame info's // Joe: force to show information of each frame VimbaHelper.FrameInfos showFrameInfos = VimbaHelper.FrameInfos.Show; // Show frame info's bool printhelp = false; // Output help? string cameraID = null; // The camera ID Console.WriteLine(); Console.WriteLine("/////////////////////////////////////////////////////////////"); Console.WriteLine("/// ///"); Console.WriteLine("/// Vimba NET API Asynchronous Console Grab Example ///"); Console.WriteLine("/// with missing/incomplete frames statistics functions ///"); Console.WriteLine("/// ///"); Console.WriteLine("/// For Truking, statistics of 16 multiframes test ver2 ///"); Console.WriteLine("/// Use FreeRun mode! ///"); Console.WriteLine("/// ///"); Console.WriteLine("/// ///"); Console.WriteLine("/////////////////////////////////////////////////////////////"); Console.WriteLine(); try { ParseCommandLine(args, ref showFrameInfos, ref printhelp, ref cameraID); // Print out help and end program if (printhelp) { Console.WriteLine("Usage: AsynchronousGrab [CameraID] [/i] [/h]"); Console.WriteLine("Parameters: CameraID ID of the camera to use (using first camera if not specified)"); Console.WriteLine(" /i Show frame info's"); Console.WriteLine(" /a Automatically only show frame info's of corrupt frames\n"); Console.WriteLine(" /h Print out help"); } else { // Create a new Vimba entry object VimbaHelper vimbaHelper = new VimbaHelper(); vimbaHelper.Startup(); // Startup API Console.WriteLine("Vimba .NET API Version {0}", vimbaHelper.GetVersion()); // Open camera try { if (null == cameraID) { // Open first available camera // Fetch all cameras known to Vimba List <Camera> cameras = vimbaHelper.CameraList; if (cameras.Count < 0) { throw new Exception("No camera available."); } foreach (Camera currentCamera in cameras) { // Check if we can open the camera in full mode VmbAccessModeType accessMode = currentCamera.PermittedAccess; if (VmbAccessModeType.VmbAccessModeFull == (VmbAccessModeType.VmbAccessModeFull & accessMode)) { // Now get the camera ID cameraID = currentCamera.Id; Console.WriteLine("Finding camera with ID: " + cameraID); //break; } } if (null == cameraID) { throw new Exception("Could not open any camera."); } } // Joe: appoint the special camera's ID or use the last one found before. // cameraID = "DEV_1AB2280009CC"; Console.WriteLine("Opening camera with ID: " + cameraID + "\n"); // Start the continuous image acquisition //vimbaHelper.StartContinuousImageAcquisition(cameraID, showFrameInfos); vimbaHelper.OpenCamera(cameraID, showFrameInfos); Console.WriteLine("Press <ctrl+c> to stop acquisition ..."); Console.WriteLine("Frame receiving ...\n\n"); #if false // Joe: case 1 - only 'q' keystroke will stop the loop char c = ' '; while ((c = Console.ReadKey().KeyChar) != 'q') { if (c == 'c') { Console.WriteLine("\nStart capturing 16 photos ..."); vimbaHelper.StopCapture(); // stop the last round vimbaHelper.StartCapture(); } else { Console.WriteLine("\nPress <q> to stop acquisition..., The current date and time: {0:MM/dd/yyyy HH:mm:ss.fff}\n", DateTime.Now); } } #else // Joe: Case 2 - shot 16 frames periodly with multiframe feature enabled. vimbaHelper.StartCapture(); long i = 0; while (i < 1000000000000) { //while (i < 1) { i++; double temp = vimbaHelper.GetCameraTemprature(); Console.WriteLine("\nStart capturing 16 photos ..., i = {0:0000000000}, Temp = {1:00.0000}", i, temp); vimbaHelper.Start16FramesCapturing(temp); // Wait for 500 ms and continue the next round Thread.Sleep(500); vimbaHelper.Waiting16Frames(1000); } vimbaHelper.StopCapture(); // stop the last round #endif Console.ReadKey(); // Stop the image acquisition vimbaHelper.StopContinuousImageAcquisition(); Console.WriteLine("\nAcquisition stopped. The current date and time: {0:MM/dd/yyyy HH:mm:ss.fff}", DateTime.Now); } finally { // shutdown the vimba Api vimbaHelper.Shutdown(); } } } catch (VimbaException ve) { // Output in case of a vimba Exception Console.WriteLine(ve.Message); Console.WriteLine("Return Code: " + ve.ReturnCode.ToString() + " (" + ve.MapReturnCodeToString() + ")"); } catch (Exception e) { // Output in case of a System.Exception Console.WriteLine(e.Message); } Console.WriteLine("Press any Key to exit!"); Console.ReadKey(); }
/// <summary> /// The main entry point for the application. /// </summary> /// <param name="cameraID">Camera ID to open - leave blank for first available</param> /// <param name="path">Image save folder path</param> /// <param name="shotSize">Number of pictures in a shot</param> /// <param name="GainAmt">Gain setting, default=0</param> private static void Main(string cameraID = null, string path = ".\\", int shotSize = 3, float GainAmt = 0) { VimbaHelper.FrameInfos showFrameInfos = VimbaHelper.FrameInfos.Show; // Show frame info's Console.WriteLine("\n//////////////////////////////////////////////////////"); Console.WriteLine("Vimba API Camera Trigger Saver (+ higher corrections)"); Console.WriteLine("//////////////////////////////////////////////////////\n"); try { // Create a new Vimba entry object VimbaHelper vimbaHelper = new VimbaHelper(path, shotSize, GainAmt); vimbaHelper.Startup(); // Startup API Console.WriteLine("Vimba .NET API Version {0}", vimbaHelper.GetVersion()); // Open camera try { if (null == cameraID) { // Open first available camera // Fetch all cameras known to Vimba List <Camera> cameras = vimbaHelper.CameraList; if (cameras.Count < 0) { throw new Exception("No camera available."); } foreach (Camera currentCamera in cameras) { // Check if we can open the camera in full mode VmbAccessModeType accessMode = currentCamera.PermittedAccess; if (VmbAccessModeType.VmbAccessModeFull == (VmbAccessModeType.VmbAccessModeFull & accessMode)) { // Now get the camera ID cameraID = currentCamera.Id; break; } } if (null == cameraID) { throw new Exception("Could not open any camera."); } } Console.WriteLine("Opening camera with ID: " + cameraID); // Start the continuous image acquisition vimbaHelper.StartContinuousImageAcquisition(cameraID, showFrameInfos); Console.WriteLine("Press <enter> to stop acquisition..."); Console.ReadKey(); // Stop the image acquisition vimbaHelper.StopContinuousImageAcquisition(); Console.WriteLine("\nAcquisition stopped."); } finally { // shutdown the vimba Api vimbaHelper.Shutdown(); } } catch (VimbaException ve) { // Output in case of a vimba Exception Console.WriteLine(ve.Message); Console.WriteLine("Return Code: " + ve.ReturnCode.ToString() + " (" + ve.MapReturnCodeToString() + ")"); } catch (Exception e) { // Output in case of a System.Exception Console.WriteLine(e.Message); } Console.WriteLine("Press any Key to exit!"); Console.ReadKey(); }