public JsonResult EntranceListDateAll() { JsonResult m_json = new JsonResult(); try { int iClassID = Pv.Pint(Request["ClassID"]); DateTime dtmDate = Pv.PDate(Request["Tarih"]); RetCode oRet = Util.DB.RunTable("EntranceListDateAll", iClassID, dtmDate); DataTable dtRooms = oRet.ToTable; m_json.Data = new { recordCount = dtRooms.Rows.Count, success = true, failure = false, error = "", data = Util.GetJsonData(dtRooms) }; m_json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; } catch (Exception eX) { Util.WriteLog(eX); } return(m_json); }
public string ReadBarkod() { string strReturn = ""; try { int iClassID = Pv.Pint(Request["ClassID"]); string strCardNumber = Pv.Pstr(Request["CardNumber"]); if (iClassID == 0) { return("-4"); } RetCode oRet = Util.DB.RunTable("ReadBarcode", iClassID, strCardNumber); if (oRet.iRet == Back.Ok) { strReturn = oRet.ToRow["Done"].ToString(); } } catch (Exception eX) { Util.WriteLog(eX); } return(strReturn); }
// Close the camera. static void CameraClose(ref tCamera Camera) { // Reset the trigger mode. Pv.AttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "Freerun"); // Close the camera. Pv.CameraClose(Camera.Handle); }
public string DeleteStudent() { //bir odaya bağlımı kontrol et öyle sil string strReturn = ""; try { //schedule varsa silme int iStudentID = Pv.Pint(Request["StudentID"]); RetCode oRet = Util.DB.RunTable("StudentDelete", iStudentID); if (oRet.iRet == Back.Ok) { strReturn = "1"; } } catch (Exception eX) { Util.WriteLog(eX); } return(strReturn); }
public CameraSerial(uint camera) { uint[] regAddresses = new uint[4]; uint[] regValues = new uint[4]; regAddresses[0] = REG_SIO_MODE; regValues[0] = 0x00000C09; // 9600, N, 8, 1 regAddresses[1] = REG_SIO_TX_CONTROL; regValues[1] = 3; // Reset & enable transmitter regAddresses[2] = REG_SIO_RX_CONTROL; regValues[2] = 3; // Reset & enable receiver regAddresses[3] = REG_SIO_RX_STATUS; regValues[3] = 0xFFFFFFFF; // Clear status bits uint written = 0; tErr error = (tErr)Pv.RegisterWrite(camera, 4, regAddresses, regValues, ref written); if (error != tErr.eErrSuccess) { throw new PvException(error); } }
static void Main(string[] args) { tErr err = 0; // Initialize the API. if ((err = Pv.Initialize()) == 0) { tLinkCallback lLinkCB = new tLinkCallback(LinkCB); // Register callbacks. Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkAdd, IntPtr.Zero); Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkRemove, IntPtr.Zero); // Wait for the user to terminate or to unplug the camera. WaitForEver(); // Unregister the callbacks. Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkAdd); Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkRemove); // Uninitialize the API. Pv.UnInitialize(); } else { Console.Write("Failed to initialize the API : "); Console.WriteLine(err); } }
static void Main(string[] args) { tErr err = 0; // Initialize the API. if ((err = Pv.InitializeNoDiscovery()) == 0) { System.Net.IPAddress IP = System.Net.IPAddress.Parse(args[0]); tCamera Camera = new tCamera(); Camera.S_addr = (uint)IP.Address; // Open the camera. if (CameraOpen(ref Camera)) { // List some infomation. DisplayInfo(ref Camera); // Unsetup the camera. CameraClose(ref Camera); } else { Console.WriteLine("Failed to open camera."); } // Uninitialize the API. Pv.UnInitialize(); } else { Console.WriteLine("Failed to initalize."); } }
/// <summary> /// 资讯的浏览量 /// </summary> private void UpdateViews() { int typeId = CRequest.GetInt("typeId", 0); string pageName = CRequest.GetString("pageName"); string pageValue = CRequest.GetString("pageValue"); //Pv统计 #region Pv pv = new Pv(); pv.pageName = pageName; pv.pageValue = pageValue; pv.viewsCount = 1; string sUserAgent = Request.UserAgent.ToLower(); bool bIsIpad = Regex.IsMatch(sUserAgent, "ipad"); bool bIsIphoneOs = Regex.IsMatch(sUserAgent, "iphone"); bool bIsAndroid = Regex.IsMatch(sUserAgent, "android"); bool bIsWP = Regex.IsMatch(sUserAgent, "windows phone"); if (bIsAndroid || bIsIphoneOs || bIsIpad || bIsWP) { pv.viewsCount = 2; } pv.addTime = DateTime.Now; pv.ip = IpSearch.GetIp(); pv.status = 0; pv.remark = ""; pv.infoType = typeId; UserInfo user = Session["user"] as UserInfo; if (user != null) { pv.status = user.id; pv.remark = user.mobile; } PvService.Add(pv); #endregion }
// Setup the camera for capture. static bool CameraSetup(ref tCamera Camera) { UInt32 FrameSize = 0; if (Pv.CameraOpen(Camera.UID, tAccessFlags.eAccessMaster, out Camera.Handle) == 0) { // Get the bytes size of the buffer. if (Pv.AttrUint32Get(Camera.Handle, "TotalBytesPerFrame", ref FrameSize) == 0) { Camera.Buffer = new byte[FrameSize]; Camera.GC = GCHandle.Alloc(Camera.Buffer, GCHandleType.Pinned); // Address of the pinned buffer. Camera.Frame.ImageBuffer = Camera.GC.AddrOfPinnedObject(); // Buffer size. Camera.Frame.ImageBufferSize = FrameSize; return(true); } else { return(false); } } else { Pv.CameraClose(Camera.Handle); Camera.Handle = 0; return(false); } }
public tErr InitCamera() { tErr err = 0; if (Inited) { return(0); } // Initialize the API. if ((err = Pv.Initialize()) == 0) { lLinkCB = new tLinkCallback(LinkCB); // Register callbacks. Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkAdd, IntPtr.Zero); Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkRemove, IntPtr.Zero); Inited = true; } else { Console.Write("无法加载相机API,错误代码: "); Console.WriteLine(err); err_string = "无法加载相机API,错误代码: " + err.ToString(); } return(err); }
private void TransmitSerialCommand() { ICommand command; tErr error; while (true) { if (commandQueue.TryDequeue(out command)) { if (!WriteBytesToSerial(command.Command)) { Connected = false; } } if (!Connected) { lock (serial) { do { error = Pv.AttrExists(camera.Value, "WhiteBalance"); if (error != tErr.eErrUnavailable && error != tErr.eErrUnplugged && error != tErr.eErrTimeout) { Connected = true; } } while (!Connected); } } Thread.Yield(); } }
public bool WriteBytesToSerialIo(uint camera, byte[] buffer, uint length) { uint[] value = new uint[2]; uint[] addressData = new uint[] { REG_SIO_TX_STATUS }; uint read = 0; tErr error; // Wait for transmitter ready. do { error = (tErr)Pv.RegisterRead(camera, 1, addressData, value, ref read); //if (error != tErr.eErrSuccess) // throw new PvException(error); } while (value[0] == 0U); // Waiting for transmitter-ready bit // Write the buffer. if (!FWriteMem(camera, REG_SIO_TX_BUFFER, buffer, length)) { return(false); } // Write the buffer length. This triggers transmission. value = new[] { length }; addressData = new uint[] { REG_SIO_TX_LENGTH }; uint written = 0; error = (tErr)Pv.RegisterWrite(camera, 1, addressData, value, ref written); if (error != tErr.eErrSuccess) { throw new PvException(error); } return(true); }
// Stop the camera from streaming. static void CameraStop() { Console.WriteLine("The streaming is now being stopped."); Pv.CommandRun(GCamera.Handle, "AcquisitionStop"); Pv.CaptureEnd(GCamera.Handle); // Clear the queue. Pv.CaptureQueueClear(GCamera.Handle); }
// Get the first camera found. static bool CameraGrab() { UInt32 connected = 0; tCameraInfo[] list = new tCameraInfo[1]; return(Pv.CameraList(list, 1, ref connected) >= 1); }
// Close the camera. static void CameraClose() { // Clear the queue. Console.WriteLine("Clearing the queue..."); Pv.CaptureQueueClear(GCamera.Handle); // close the camera Console.WriteLine("The camera is now closed."); Pv.CameraClose(GCamera.Handle); }
// Unsetup the camera. static void CameraUnsetup(ref tCamera Camera) { Console.WriteLine("Closing the camera now..."); // Close the camera. Pv.CameraClose(Camera.Handle); Console.WriteLine("Closed."); // Reset the handle. Camera.Handle = 0; }
static void Main(string[] args) { tErr err = 0; // Initialize the API. if ((err = Pv.Initialize()) == 0) { tLinkCallback lLinkCB = new tLinkCallback(LinkCB); // Register callbacks. Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkAdd, IntPtr.Zero); Pv.LinkCallbackRegister(lLinkCB, tLinkEvent.eLinkRemove, IntPtr.Zero); WaitForCamera(); if (CameraGrab()) { if (CameraSetup()) { if (CameraStart()) { Console.WriteLine("The camera will be streaming for the next 10 seconds."); Thread.Sleep(10000); CameraStop(); } else { Console.WriteLine("The camera failed to start streaming."); } CameraClose(); } else { Console.WriteLine("The camera could not be setup."); } } else { Console.WriteLine("The was no camera grabbed."); } // Unregister the callbacks. Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkAdd); Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkRemove); // Uninitialize the API. Pv.UnInitialize(); } else { Console.Write("Failed to initialize the API : "); Console.WriteLine(err); } }
// Wait for a camera to be detected. static void WaitForCamera() { Console.WriteLine("Waiting for a camera "); while (Pv.CameraCount() == 0) { Console.Write("."); Thread.Sleep(250); } Console.WriteLine(""); }
// Keeps track of data being streamed from the camera. static void ThreadFunc() { tErr Err; UInt32 Dropped, Done, Completed; UInt32 Total, Missed, Errs; int Before, Now, Elapsed; double Fps; float Rate; Dropped = 0; Missed = 0; Completed = 0; Errs = 0; Rate = 0; Fps = 0; Elapsed = 0; Total = 0; Done = 0; // Start timing. Before = GetTickCount(); // Get some infomation about the streaming process. while (Close == false && ((Err = Pv.AttrUint32Get(GCamera.Handle, "StatFramesCompleted", ref Completed)) == 0) && ((Err = Pv.AttrUint32Get(GCamera.Handle, "StatFramesDropped", ref Dropped)) == 0) && ((Err = Pv.AttrUint32Get(GCamera.Handle, "StatPacketsMissed", ref Missed)) == 0) && ((Err = Pv.AttrUint32Get(GCamera.Handle, "StatPacketsErroneous", ref Errs)) == 0) && ((Err = Pv.AttrFloat32Get(GCamera.Handle, "StatFrameRate", ref Rate)) == 0)) { // Store the elapsed time. Now = GetTickCount(); // Keep track of the total amount of frames completed. Total += (Completed - Done); // Keep track of the total time that has elapsed. Elapsed += (Now - Before); // Updates the Fps rate every 500 milliseconds. if (Elapsed >= 500) { Fps = (double)(Total * 1000.0) / (double)Elapsed; Elapsed = 0; Total = 0; } // Display the current infomation. //Console.WriteLine("Completed : {0} Dropped : {1} Missed : {2} Err {3} Rate: {4:.00} <{5:.00}>", Completed, Dropped, Missed, Errs, Rate, Fps); Before = GetTickCount(); Done = Completed; Thread.Sleep(20); } Console.WriteLine(); }
// Close the camera. static void CameraClose() { // Reset the trigger mode. Pv.AttrEnumSet(GCamera.Handle, "FrameStartTriggerMode", "Freerun"); // Close the camera. Pv.CameraClose(GCamera.Handle); // Reset the handle. GCamera.Handle = 0; Console.WriteLine("The Camera is now closed."); }
// Close the camera. static void CameraClose(ref tCamera Camera) { // Reset the trigger mode. Pv.AttrEnumSet(Camera.Handle, "FrameStartTriggerMode", "Freerun"); // Close the camera. Pv.CameraClose(Camera.Handle); // Delete the allocated buffer. Camera.GC.Free(); // Reset the handle. Camera.Handle = 0; }
public void dispose() { Started = false; // Unregister the callbacks. Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkAdd); Pv.LinkCallbackUnregister(lLinkCB, tLinkEvent.eLinkRemove); CameraClose(); // Uninitialize the API. Pv.UnInitialize(); Inited = false; }
public void PvShouldCalculatedWithoutError(double rate, short numberPeriods, double payment, double futureValue, DueDate due) { //Arrange var pv = new Pv(); //Act var exception = Record.Exception(() => pv.PresentValue(rate, numberPeriods, payment, futureValue, due)); //Assert exception.Should().BeNull(); }
// Callback called when a frame is done. static void FrameDoneCB(ref tFrame pFrame, ref tCamera Camera) { GCHandle pFrame1 = GCHandle.Alloc(Camera.Frame, GCHandleType.Pinned); tFrameCallback FrameCB = new tFrameCallback(FrameDummyCB); // If the frame was completed, re-enqueue it. if (pFrame.Status != tErr.eErrUnplugged && pFrame.Status != tErr.eErrCancelled) { Pv.CaptureQueueFrame(Camera.Handle, pFrame1.AddrOfPinnedObject(), FrameCB); } }
// Open the Camera by IP. static bool CameraOpen(ref tCamera Camera) { // Open by the address of camera. if ((Pv.CameraOpenByAddr(Camera.S_addr, tAccessFlags.eAccessMaster, out Camera.Handle) == tErr.eErrSuccess)) { Pv.CameraInfoByAddr(Camera.S_addr, ref Camera.Info, ref Camera.Conf); return(true); } else { return(false); } }
public void AdjustPacketSize() { if (!camera.HasValue) { throw new PvException(tErr.eErrUnavailable); } tErr err = Pv.CaptureAdjustPacketSize(camera.Value, MAX_PACKET_SIZE); if (err != tErr.eErrSuccess) { throw new PvException(err); } }
// Callback for when the frame is completed. static void FrameDoneCB(IntPtr pFrame) { // Marshal the pointer into a frame structure. tFrame Frame = (tFrame)Marshal.PtrToStructure(pFrame, typeof(tFrame)); // If the frame was completed (or if data were missing/lost), re-enqueue it. if (Frame.Status == tErr.eErrSuccess || Frame.Status == tErr.eErrDataLost || Frame.Status == tErr.eErrDataMissing) { Pv.CaptureQueueFrame(GCamera.Handle, pFrame, FrameCB); } }
// Setup the camera for capture. static bool CameraSetup() { UInt32 FrameSize = 0; // Get the byte size of the buffer. if (Pv.AttrUint32Get(GCamera.Handle, "TotalBytesPerFrame", ref FrameSize) == 0) { GCamera.Buffer = new byte[FrameSize]; GCamera.GC = GCHandle.Alloc(GCamera.Buffer, GCHandleType.Pinned); // Address of pinned buffer. GCamera.Frame.ImageBuffer = GCamera.GC.AddrOfPinnedObject(); // Buffer size. GCamera.Frame.ImageBufferSize = FrameSize; // Start the capture mode. if (Pv.CaptureStart(GCamera.Handle) == 0) { // Set the acquisition mode into continuous and hardware trigger mode, using SyncIn2 (non-isolated). if (Pv.AttrEnumSet(GCamera.Handle, "FrameStartTriggerMode", "SyncIn2") == 0) // Set the acquisition mode into continuous and hardware trigger mode, using SyncIn1 (isolated). // if (Pv.AttrEnumSet(GCamera.Handle, "FrameStartTriggerMode", "SyncIn1") == 0) { // Set the acquisition mode into continuous. if (Pv.CommandRun(GCamera.Handle, "AcquisitionStart") != 0) { // if that fails, reset the camera to non capture mode. Pv.CaptureEnd(GCamera.Handle); return(false); } else { return(true); } } else { return(false); } } else { return(true); } } else { return(false); } }
// Callback for when the frame is completed. static void FrameDoneCB(IntPtr pFrame) { // Marshal the pointer into a frame structure. tFrame Frame = (tFrame)Marshal.PtrToStructure(pFrame, typeof(tFrame)); Console.WriteLine("Frame recieved {0}.", (uint)Frame.Status); // If the frame was completed (or if data were missing/lost), re-enqueue it. if (Frame.Status != tErr.eErrUnplugged && Frame.Status != tErr.eErrCancelled) { Pv.CaptureQueueFrame(GCamera.Handle, pFrame, FrameDoneCB); } }
// Close the camera. static void CameraClose() { Thread.Sleep(1000); // Unsetup event channel. Pv.AttrUint32Set(GCamera.Handle, "EventsEnable1", 0); Pv.CameraEventCallbackUnRegister(GCamera.Handle, EventDone); // Clear the queue. Console.WriteLine("Clearing the queue..."); Pv.CaptureQueueClear(GCamera.Handle); // close the camera Console.WriteLine("The camera is now closed."); Pv.CameraClose(GCamera.Handle); }