void Start() { upSrc = localUp3DOFSrc.GetComponent <I3DOF>(); rightSrc = localRight3DOFSrc.GetComponent <I3DOF>(); forwardSrc = localForward3DOFSrc.GetComponent <I3DOF>(); isLocalSrc = isLocalBoolSrc.GetComponent <IBool>(); }
// Disables heartbeat on GEV cameras so debugging does not incur timeout errors static int DisableHeartbeat(IManagedCamera cam, INodeMap nodeMap, INodeMap nodeMapTLDevice) { Console.WriteLine("Checking device type to see if we need to disable the camera's heartbeat...\n\n"); // // Write to boolean node controlling the camera's heartbeat // // *** NOTES *** // This applies only to GEV cameras and only applies when in DEBUG mode. // GEV cameras have a heartbeat built in, but when debugging applications the // camera may time out due to its heartbeat. Disabling the heartbeat prevents // this timeout from occurring, enabling us to continue with any necessary debugging. // This procedure does not affect other types of cameras and will prematurely exit // if it determines the device in question is not a GEV camera. // // *** LATER *** // Since we only disable the heartbeat on GEV cameras during debug mode, it is better // to power cycle the camera after debugging. A power cycle will reset the camera // to its default settings. // IEnum iDeviceType = nodeMapTLDevice.GetNode <IEnum>("DeviceType"); IEnumEntry iDeviceTypeGEV = iDeviceType.GetEntryByName("GigEVision"); // We first need to confirm that we're working with a GEV camera if (iDeviceType != null && iDeviceType.IsReadable) { if (iDeviceType.Value == iDeviceTypeGEV.Value) { Console.WriteLine( "Working with a GigE camera. Attempting to disable heartbeat before continuing...\n\n"); IBool iGEVHeartbeatDisable = nodeMap.GetNode <IBool>("GevGVCPHeartbeatDisable"); if (iGEVHeartbeatDisable == null || !iGEVHeartbeatDisable.IsWritable) { Console.WriteLine( "Unable to disable heartbeat on camera. Continuing with execution as this may be non-fatal..."); } else { iGEVHeartbeatDisable.Value = true; Console.WriteLine("WARNING: Heartbeat on GigE camera disabled for the rest of Debug Mode."); Console.WriteLine( " Power cycle camera when done debugging to re-enable the heartbeat..."); } } else { Console.WriteLine("Camera does not use GigE interface. Resuming normal execution...\n\n"); } } else { Console.WriteLine("Unable to access TL device nodemap. Aborting..."); return(-1); } return(0); }
private void PrintBooleanNode(INode node, int level, StreamWriter sw) { try { // Cast as boolean node IBool iBooleanNode = (IBool)node; // Retrieve display name string displayName = iBooleanNode.DisplayName; // Retrieve value as a string representation string value = (iBooleanNode.Value ? "true" : "false"); sw.WriteLine(Indent(level) + displayName + ": " + value + " (Bool Node)"); } catch (SpinnakerException ex) { Console.WriteLine("Error: " + ex.ToString()); } }
public bool TriggerDelay(bool enable, double ms) { bool result = false; try { #region triggerdelayenable IBool iTriggerDelayEnabled = nodeMap.GetNode <IBool>("TriggerDelayEnabled"); iTriggerDelayEnabled.Value = enable; #endregion if (enable) { managedCamera.TriggerDelay.Value = (long)(1000 * ms);//microsecs } result = true; } catch (Exception ex) { } return(result); }
private void SetSetting(Util.SettingInfo item) { string settingName = item._SettingName.ToString(); Util.NodeType nodeType = item._NodeType; Util.NodeMap nodeMap = item._NodeMap; string value = item._Value; if (nodeType == Util.NodeType.String) { IString iNode = null; if (nodeMap == Util.NodeMap.GenICam) { iNode = cam.nodeMap.GetNode <IString>(settingName); } else if (nodeMap == Util.NodeMap.TLDevice) { iNode = cam.nodeMapTLDevice.GetNode <IString>(settingName); } else if (nodeMap == Util.NodeMap.TLStream) { iNode = cam.nodeMapTLStream.GetNode <IString>(settingName); } string currentValue = string.Copy(iNode.Value.ToString()); iNode.Value = value; string newValue = string.Copy(iNode.Value.ToString()); printSettingChangeInfo(currentValue, newValue); } else if (nodeType == Util.NodeType.Integer) { IInteger iNode = null; if (nodeMap == Util.NodeMap.GenICam) { iNode = cam.nodeMap.GetNode <IInteger>(settingName); } else if (nodeMap == Util.NodeMap.TLDevice) { iNode = cam.nodeMapTLDevice.GetNode <IInteger>(settingName); } else if (nodeMap == Util.NodeMap.TLStream) { iNode = cam.nodeMapTLStream.GetNode <IInteger>(settingName); } string currentValue = string.Copy(iNode.Value.ToString()); iNode.Value = int.Parse(value); string newValue = string.Copy(iNode.Value.ToString()); printSettingChangeInfo(currentValue, newValue); } else if (nodeType == Util.NodeType.Float) { IFloat iNode = null; if (nodeMap == Util.NodeMap.GenICam) { iNode = cam.nodeMap.GetNode <IFloat>(settingName); } else if (nodeMap == Util.NodeMap.TLDevice) { iNode = cam.nodeMapTLDevice.GetNode <IFloat>(settingName); } else if (nodeMap == Util.NodeMap.TLStream) { iNode = cam.nodeMapTLStream.GetNode <IFloat>(settingName); } string currentValue = string.Copy(iNode.Value.ToString()); iNode.Value = float.Parse(value, CultureInfo.InvariantCulture.NumberFormat); string newValue = string.Copy(iNode.Value.ToString()); printSettingChangeInfo(currentValue, newValue); } else if (nodeType == Util.NodeType.Bool) { IBool iNode = null; if (nodeMap == Util.NodeMap.GenICam) { iNode = cam.nodeMap.GetNode <IBool>(settingName); } else if (nodeMap == Util.NodeMap.TLDevice) { iNode = cam.nodeMapTLDevice.GetNode <IBool>(settingName); } else if (nodeMap == Util.NodeMap.TLStream) { iNode = cam.nodeMapTLStream.GetNode <IBool>(settingName); } string currentValue = string.Copy(iNode.Value.ToString()); iNode.Value = bool.Parse(value); string newValue = string.Copy(iNode.Value.ToString()); printSettingChangeInfo(currentValue, newValue); } else if (nodeType == Util.NodeType.Command) { ICommand iNode = null; if (nodeMap == Util.NodeMap.GenICam) { iNode = cam.nodeMap.GetNode <ICommand>(settingName); } else if (nodeMap == Util.NodeMap.TLDevice) { iNode = cam.nodeMapTLDevice.GetNode <ICommand>(settingName); } else if (nodeMap == Util.NodeMap.TLStream) { iNode = cam.nodeMapTLStream.GetNode <ICommand>(settingName); } Console.WriteLine("Command to be executed: {0}: ", settingName); iNode.Execute(); } else if (nodeType == Util.NodeType.Enumeration) { IEnum iNode = null; if (nodeMap == Util.NodeMap.GenICam) { iNode = cam.nodeMap.GetNode <IEnum>(settingName); } else if (nodeMap == Util.NodeMap.TLDevice) { iNode = cam.nodeMapTLDevice.GetNode <IEnum>(settingName); } else if (nodeMap == Util.NodeMap.TLStream) { iNode = cam.nodeMapTLStream.GetNode <IEnum>(settingName); } string currentValue = string.Copy(iNode.Value); IEnumEntry iEntry = iNode.GetEntryByName(value); iNode.Value = iEntry.Symbolic; string newValue = string.Copy(iEntry.Symbolic); printSettingChangeInfo(currentValue, newValue); } void printSettingChangeInfo(string _currentValue, string _newValue, bool suppress = true) { if (!suppress) { Console.WriteLine("{0} ({1}) changed from {2} to {3}", settingName, nodeType, _currentValue, _newValue); } } }
void Start() { origSrc = origSrcGO.GetComponent <IBool>(); }
public bool DefaultSettings() { bool result = false; try { StopVideo(); if (RestoreDefaultSettings()) { if (!SetStreamBufferCount(1)) { return(false); } //mode 0 and pixel format raw8/bayer rg 8 if (!SetVideoMode(0)) { return(false); } //managedCamera.PixelFormat.Value = PixelFormatEnums.BayerGB8.ToString(); managedCamera.PixelFormat.Value = PixelFormatEnums.RGB8.ToString(); //shutter, gain, wb and frame rate auto off #region exposure_auto_compensation_off IEnum iExposure = nodeMap.GetNode <IEnum>("pgrExposureCompensationAuto"); if (iExposure == null || !iExposure.IsWritable) { return(false); } IEnumEntry iExposureOff = iExposure.GetEntryByName("Off"); if (iExposureOff == null || !iExposureOff.IsReadable) { return(false); } iExposure.Value = iExposureOff.Symbolic; #endregion managedCamera.ExposureAuto.Value = ExposureAutoEnums.Off.ToString(); managedCamera.ExposureMode.Value = ExposureModeEnums.Timed.ToString(); managedCamera.GainAuto.Value = GainAutoEnums.Off.ToString(); #region frame_rate_off IEnum iFrameRate = nodeMap.GetNode <IEnum>("AcquisitionFrameRateAuto"); if (iFrameRate == null || !iFrameRate.IsWritable) { return(false); } IEnumEntry iFrameRateOff = iFrameRate.GetEntryByName("Off"); if (iFrameRateOff == null || !iFrameRateOff.IsReadable) { return(false); } iFrameRate.Value = iFrameRateOff.Symbolic; IBool iFrameRateEnabled = nodeMap.GetNode <IBool>("AcquisitionFrameRateEnabled"); if (iFrameRateEnabled == null || !iFrameRateEnabled.IsWritable) { return(false); } iFrameRateEnabled.Value = false; #endregion // saturation enable off { IBool iSaturationEnabled = nodeMap.GetNode <IBool>("SaturationEnabled"); if (iSaturationEnabled == null || !iSaturationEnabled.IsWritable) { return(false); } iSaturationEnabled.Value = false; } managedCamera.BalanceWhiteAuto.Value = BalanceWhiteAutoEnums.Off.ToString(); result = true; } //result = EnableChunkData(); } catch (Exception ex) { result = false; } return(result); }
bool EnableChunkData() { bool result = true; try { IBool iChunkModeActive = nodeMap.GetNode <IBool>("ChunkModeActive"); if (iChunkModeActive == null || !iChunkModeActive.IsWritable) { Console.WriteLine("Cannot active chunk mode. Aborting..."); return(false); } iChunkModeActive.Value = true; IEnum iChunkSelector = nodeMap.GetNode <IEnum>("ChunkSelector"); if (iChunkSelector == null || !iChunkSelector.IsReadable) { Console.WriteLine("Chunk selector not available. Aborting..."); return(false); } IEnumEntry frameIDEntry = iChunkSelector.GetEntryByName("FrameCounter");//iChunkSelector.Entries[2]; if (!frameIDEntry.IsAvailable || !frameIDEntry.IsReadable) { } else { iChunkSelector.Value = frameIDEntry.Value; IBool iChunkEnable = nodeMap.GetNode <IBool>("ChunkEnable"); if (iChunkEnable?.IsWritable == true) { iChunkEnable.Value = true; } } IEnumEntry timeStampEntry = iChunkSelector.GetEntryByName("Timestamp"); if (!timeStampEntry.IsAvailable || !timeStampEntry.IsReadable) { } else { iChunkSelector.Value = timeStampEntry.Value; IBool iChunkEnable = nodeMap.GetNode <IBool>("ChunkEnable"); if (iChunkEnable?.IsWritable == true) { iChunkEnable.Value = true; } } IEnumEntry exposureTimeEntry = iChunkSelector.GetEntryByName("ExposureTime"); if (!exposureTimeEntry.IsAvailable || !exposureTimeEntry.IsReadable) { } else { iChunkSelector.Value = exposureTimeEntry.Value; IBool iChunkEnable = nodeMap.GetNode <IBool>("ChunkEnable"); if (iChunkEnable?.IsWritable == true) { iChunkEnable.Value = true; } } } catch (SpinnakerException ex) { Debug.WriteLine("Error: " + ex.Message); result = false; } return(result); }
static void Main(string[] args) { try { using (CStApiAutoInit api = new CStApiAutoInit()) using (CStSystem system = new CStSystem(eStSystemVendor.Sentech)) using (CStDevice device = system.CreateFirstStDevice()) using (CStImageDisplayWnd wnd = new CStImageDisplayWnd()) using (CStDataStream dataStream = device.CreateStDataStream(0)) { Console.WriteLine("Device=" + device.GetIStDeviceInfo().DisplayName); // ============================================================================================================== // Demostration of switching on Reverse Y of camera. // Create NodeMap pointer for accessing parameters INodeMap nodeMap = device.GetRemoteIStPort().GetINodeMap(); // Switch on Reverse Y. IBool boolReverY = nodeMap.GetNode <IBool>("ReverseY"); boolReverY.Value = true; // ============================================================================================================== dataStream.StartAcquisition(nCountOfImagesToGrab); device.AcquisitionStart(); while (dataStream.IsGrabbing) { using (CStStreamBuffer streamBuffer = dataStream.RetrieveBuffer(5000)) { if (streamBuffer.GetIStStreamBufferInfo().IsImagePresent) { IStImage stImage = streamBuffer.GetIStImage(); string strText = device.GetIStDeviceInfo().DisplayName + " "; strText += stImage.ImageWidth + " x " + stImage.ImageHeight + " "; strText += string.Format("{0:F2}[fps]", dataStream.CurrentFPS); wnd.SetUserStatusBarText(strText); if (!wnd.IsVisible) { wnd.SetPosition(0, 0, (int)stImage.ImageWidth, (int)stImage.ImageHeight); wnd.Show(eStWindowMode.ModalessOnNewThread); } wnd.RegisterIStImage(stImage); } else { Console.WriteLine("Image data does not exist."); } } } device.AcquisitionStop(); dataStream.StopAcquisition(); } } catch (Exception e) { Console.Error.WriteLine("An exception occurred. \r\n" + e.Message); } finally { Console.WriteLine("\r\nPress Enter to exit."); Console.ReadLine(); } }