/// <summary> /// OldestFirst = 0, /// OldestFirstOverwrite = 1, /// NewestFirst = 2, /// NewestFirstOverwrite = 3, /// NUMSTREAMBUFFERHANDLINGMODE = 4 /// </summary> /// <param name="strMode"></param> public override bool SetStreamBufferHandlingMode(string strMode) { bool ret = false; try { INodeMap sNodeMap = m_Camera.GetTLStreamNodeMap(); IEnum iStreamBufferHandlingMode = sNodeMap.GetNode <IEnum>("StreamBufferHandlingMode"); if (iStreamBufferHandlingMode == null || !iStreamBufferHandlingMode.IsWritable) { return(false); } IEnumEntry iMode = iStreamBufferHandlingMode.GetEntryByName(strMode); if (iMode == null || !iMode.IsReadable) { return(false); } iStreamBufferHandlingMode.Value = iMode.Symbolic; ret = true; } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } return(ret); }
public bool SetStreamBufferCount(long count) { try { // set to manual INodeMap sNodeMap = managedCamera.GetTLStreamNodeMap(); IEnum sBufferCountSelector = sNodeMap.GetNode <IEnum>("StreamBufferCountMode"); if (sBufferCountSelector == null || !sBufferCountSelector.IsWritable) { return(false); } IEnumEntry iBufferCountManual = sBufferCountSelector.GetEntryByName("Manual"); if (iBufferCountManual == null || !iBufferCountManual.IsReadable) { return(false); } sBufferCountSelector.Value = iBufferCountManual.Symbolic; // set the value IInteger streamNode = sNodeMap.GetNode <IInteger>("StreamDefaultBufferCount"); if (streamNode == null || !streamNode.IsWritable) { return(false); } streamNode.Value = count; } catch { return(false); } return(true); }
/// <summary>save all the snapshot diff to fsimage</summary> /// <exception cref="System.IO.IOException"/> public void SerializeSnapshotDiffSection(OutputStream @out) { INodeMap inodesMap = fsn.GetFSDirectory().GetINodeMap(); IList <INodeReference> refList = parent.GetSaverContext().GetRefList(); int i = 0; IEnumerator <INodeWithAdditionalFields> iter = inodesMap.GetMapIterator(); while (iter.HasNext()) { INodeWithAdditionalFields inode = iter.Next(); if (inode.IsFile()) { SerializeFileDiffList(inode.AsFile(), @out); } else { if (inode.IsDirectory()) { SerializeDirDiffList(inode.AsDirectory(), refList, @out); } } ++i; if (i % FSImageFormatProtobuf.Saver.CheckCancelInterval == 0) { context.CheckCancelled(); } } parent.CommitSection(headers, FSImageFormatProtobuf.SectionName.SnapshotDiff); }
// This function acts as the body of the example; please see // NodeMapInfo_CSharp example for more in-depth comments on setting up // cameras. public int RunSingleCamera(IManagedCamera cam) { int result = 0; try { // Retrieve TL device nodemap and print device information INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap(); result = PrintDeviceInfo(nodeMapTLDevice); // Initialize camera cam.Init(); // Retrieve GenICam nodemap INodeMap nodeMap = cam.GetNodeMap(); // Acquire images result = result | AcquireImages(cam, nodeMap, nodeMapTLDevice); // Deinitialize camera cam.DeInit(); } catch (SpinnakerException ex) { writeLog(String.Format("Error: {0}\n", ex.Message)); result = -1; } return(result); }
public static void CloseOryxCamera(IManagedCamera managedCamera, INodeMap nodeMap, int camNumber, CloseCameraMethod closeMethod) { if (!managedCamera.IsInitialized()) { Console.WriteLine("Camera number {0} not initialized. Cannot execute DeviceReset or FactoryReset command", camNumber.ToString()); return; } if (managedCamera.IsStreaming()) { managedCamera.EndAcquisition(); Console.WriteLine("EndAcquisition executed from CloseOryxCamera block on camera {0}", camNumber.ToString()); } if (closeMethod == CloseCameraMethod.DeInit) { managedCamera.DeInit(); Console.WriteLine("Camera number {0} deinitialized.", camNumber.ToString()); } else if (closeMethod == CloseCameraMethod.DeInitAndDeviceReset) { nodeMap.GetNode <ICommand>("DeviceReset").Execute(); Console.WriteLine("DeviceReset command executed on camera number {0}.", camNumber.ToString()); } else if (closeMethod == CloseCameraMethod.DeInitAndFactoryReset) { nodeMap.GetNode <ICommand>("FactoryReset").Execute(); Console.WriteLine("FactoryReset command executed on camera number {0}.", camNumber.ToString()); } }
private void GetNodeMapsAndInitialize() { nodeMapTLDevice = managedCamera.GetTLDeviceNodeMap(); nodeMapTLStream = managedCamera.GetTLStreamNodeMap(); managedCamera.Init(); nodeMap = managedCamera.GetNodeMap(); Console.WriteLine("Camera number {0} opened and initialized on thread {1}", camNumber, Thread.CurrentThread.ManagedThreadId); }
// 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); }
public INodeMap[] AddNodeData(INetworkAdjList network, LayerDataType[] dataTypes) { INodeMap[] maps = new INodeMap[dataTypes.Length]; for (int i = 0; i < dataTypes.Length; i++) { maps[i] = SetValues(dataTypes[i], network, i); } return maps; }
public override bool Connect() { bool result = false; try { system = new ManagedSystem(); IList <IManagedCamera> camList = system.GetCameras(); if (camList.Count != 1) { int count = camList.Count; foreach (IManagedCamera mc in camList) { mc.Dispose(); } // Clear camera list before releasing system camList.Clear(); // Release system system.Dispose(); throw new Exception("Only one camera should be connected, but found " + count); } camera = camList[0]; // Initialize camera camera.Init(); SerialNumber = Convert.ToUInt32(camera.DeviceSerialNumber); FirmwareVersion = camera.DeviceFirmwareVersion; // Retrieve GenICam nodemap nodeMap = camera.GetNodeMap(); //initialise settings DefaultSettings(); ImageWidth = camera.Width; ImageHeight = camera.Height; result = true; } catch (Exception /*ex*/) { //App.LogEntry.AddEntry("Failed to Connect to Point Grey Camera : " + ex.Message); result = false; } return(result); }
bool RestoreDefaultSettings() { bool result = false; try { for (int i = 0; i < 3; i++) { try { managedCamera.UserSetSelector.Value = UserSetSelectorEnums.Default.ToString(); managedCamera.UserSetLoad.Execute(); result = true; break; } catch (SpinnakerException s) { managedCamera.AcquisitionMode.Value = AcquisitionModeEnums.Continuous.ToString(); managedCamera.BeginAcquisition(); System.Threading.Thread.Sleep(500); managedCamera.EndAcquisition(); } } //TODO: stream buffer default count mode to manual // Set stream buffer Count Mode to manual // Retrieve Stream Parameters device nodemap INodeMap sNodeMap = managedCamera.GetTLStreamNodeMap(); IEnum streamBufferCountMode = sNodeMap.GetNode <IEnum>("StreamBufferCountMode"); if (streamBufferCountMode == null || !streamBufferCountMode.IsWritable) { return(false); } IEnumEntry streamBufferCountModeManual = streamBufferCountMode.GetEntryByName("Manual"); if (streamBufferCountModeManual == null || !streamBufferCountModeManual.IsReadable) { return(false); } streamBufferCountMode.Value = streamBufferCountModeManual.Value; } catch (Exception ex) { result = false; } return(result); }
///<inheritdoc/> protected override void PerformPostLayout() { CurrentLayoutGraph.RemoveDataProvider(OrganicLayout.AffectedNodesDpKey); if (preStage != null) { organic.RemoveStage(preStage); preStage = null; } if (groupNodeContentDP != null) { CurrentLayoutGraph.RemoveDataProvider(OrganicLayout.GroupNodeModeDpKey); groupNodeContentDP = null; } base.PerformPostLayout(); }
public override bool Init(int index = 0) { bool ret = false; try { // Retrieve singleton reference to system object ManagedSystem system = new ManagedSystem(); // Retrieve list of cameras from the system IList <IManagedCamera> camList = system.GetCameras(); LogHelper.AppLoger.DebugFormat("Number of cameras detected: {0}", camList.Count); if (camList.Count == 0) { LogHelper.AppLoger.Error("没有发现相机!"); return(ret); } m_Camera = camList[index]; // Retrieve TL device nodemap and print device information INodeMap nodeMapTLDevice = m_Camera.GetTLDeviceNodeMap(); // Initialize camera m_Camera.Init(); // Retrieve GenICam nodemap m_NodeMap = m_Camera.GetNodeMap(); //if (!m_camera.DeviceConnectionStatus.IsRegister) //{ // Dialogs.Show("连接相机失败!"); // return ret; //} //CameraInfo camInfo = m_camera.GetCameraInfo(); IString iDeviceSerialNumber = nodeMapTLDevice.GetNode <IString>("DeviceSerialNumber"); LogHelper.AppLoger.DebugFormat("camera serial number:{0}", iDeviceSerialNumber); //Set embedded timestamp to on //EmbeddedImageInfo embeddedInfo = m_camera.GetEmbeddedImageInfo(); //embeddedInfo.timestamp.onOff = true; //m_camera.SetEmbeddedImageInfo(embeddedInfo); SetAcquisitionMode("Continuous"); ret = true; } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } return(ret); }
private void ConfigureGrouping() { IOptionItem groupingItem = Handler.GetItemByName("GROUPING.GROUP_LAYOUT_POLICY"); switch ((string)groupingItem.Value) { case IGNORE_GROUPS: preStage = new HideGroupsStage(); organic.PrependStage(preStage); break; case LAYOUT_GROUPS: //do nothing... break; case FIX_GROUP_BOUNDS: IDataProvider groupDP = CurrentLayoutGraph.GetDataProvider(GroupingKeys.GroupDpKey); if (groupDP != null) { groupNodeContentDP = Maps.CreateHashedNodeMap(); foreach (Node node in CurrentLayoutGraph.Nodes) { if (groupDP.GetBool(node)) { groupNodeContentDP.Set(node, GroupNodeMode.FixBounds); } } CurrentLayoutGraph.AddDataProvider(OrganicLayout.GroupNodeModeDpKey, groupNodeContentDP); } break; case FIX_GROUP_CONTENTS: groupDP = CurrentLayoutGraph.GetDataProvider(GroupingKeys.GroupDpKey); if (groupDP != null) { groupNodeContentDP = Maps.CreateHashedNodeMap(); foreach (Node node in CurrentLayoutGraph.Nodes) { if (groupDP.GetBool(node)) { groupNodeContentDP.Set(node, GroupNodeMode.FixContents); } } CurrentLayoutGraph.AddDataProvider(OrganicLayout.GroupNodeModeDpKey, groupNodeContentDP); } break; } }
public override bool SetStreamBufferCount(int bufCount) { bool ret = false; try { INodeMap sNodeMap = m_Camera.GetTLStreamNodeMap(); IInteger streamNode = sNodeMap.GetNode <IInteger>("StreamDefaultBufferCount"); streamNode.Value = bufCount; ret = true; } catch (Exception ex) { LogHelper.AppLoger.Error(ex); } return(ret); }
public static bool SetEnumValue(this INodeMap nodeMap, string nodeName, string value) { var node = nodeMap.GetNode <IEnum>(nodeName); if (node == null || !node.IsWritable) { return(false); } var entry = node.GetEntryNode(value); if (entry == null) { return(false); } node.IntValue = entry.Value; return(true); }
public bool SetStreamBufferCount(long count) { try { //StreamDefaultBufferCount is the number of images to buffer on PC //default is 10 INodeMap sNodeMap = managedCamera.GetTLStreamNodeMap(); IInteger streamNode = sNodeMap.GetNode <IInteger>("StreamDefaultBufferCount"); if (streamNode == null || !streamNode.IsWritable) { return(false); } streamNode.Value = count; } catch { return(false); } return(true); }
// This function acts as the body of the example; please see // NodeMapInfo_CSharp example for more in-depth comments on setting up // cameras. int RunSingleCamera(IManagedCamera cam) { int result = 0; int err = 0; try { // Retrieve TL device nodemap and print device information INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap(); result = PrintDeviceInfo(nodeMapTLDevice); // Initialize camera cam.Init(); // Retrieve GenICam nodemap INodeMap nodeMap = cam.GetNodeMap(); // Acquire images List <IManagedImage> images = new List <IManagedImage>(); err = result | AcquireImages(cam, nodeMap, ref images); if (err < 0) { return(err); } // Create video result = result | SaveListToVideo(nodeMap, nodeMapTLDevice, ref images); // Deinitialize camera cam.DeInit(); } catch (SpinnakerException ex) { Console.WriteLine("Error: {0}", ex.Message); result = -1; } return(result); }
private int SetNodeMapItem(INodeMap nodeMap, String nodeName, String entryName) { try { // Retrieve enumeration node from nodemap IEnum iAcquisitionMode = nodeMap.GetNode <IEnum>(nodeName); if (iAcquisitionMode == null || !iAcquisitionMode.IsWritable) { writeLog(String.Format( "Unable to set {0} to {1} (node retrieval). Aborting...\n\n", nodeName, entryName)); return(-1); } // Retrieve entry node from enumeration node IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName(entryName); if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable) { writeLog(String.Format( "Unable to set {0} to {1} (enum entry retrieval). Aborting...\n\n", nodeName, entryName)); return(-1); } // Set symbolic from entry node as new value for enumeration node iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic; } catch (SpinnakerException ex) { writeLog(String.Format("Error: {0}\n", ex.Message)); return(-1); } writeLog(String.Format("{0} set to {1}...\n", nodeName, entryName)); return(0); }
void PrintDeviceInfo(INodeMap nodeMap) { try { Console.WriteLine("\n*** DEVICE INFORMATION ***\n"); ICategory category = nodeMap.GetNode <ICategory>("DeviceInformation"); if (category != null && category.IsReadable) { for (int i = 0; i < category.Children.Length; i++) { Console.WriteLine("{0}: {1}", category.Children[i].Name, (category.Children[i].IsReadable ? category.Children[i].ToString() : "Node not available")); } Console.WriteLine(); } else { Console.WriteLine("设备控制信息无法获取"); } } catch (SpinnakerException ex) { Console.WriteLine("Error: {0}", ex.Message); } }
/// <summary> /// Creates a new istance of <see cref="PathFinder{T}"/>. /// </summary> /// <param name="nodeMap">Node map where to find a path.</param> public PathFinder(INodeMap <T> nodeMap) { this._threadDictionary = new Dictionary <Guid, Thread>(); this._nodeMap = nodeMap; }
public void CopyToMap(object source, int srcColIndex, INetworkAdjList network, INodeMap map, IList<int> rowIndices) { if (map is INodeIntMap) CopyColumnToMap((DataTable)source, srcColIndex, network, (INodeIntMap)map, rowIndices); else if (map is INodeDoubleMap) CopyColumnToMap((DataTable)source, srcColIndex, network, (INodeDoubleMap)map, rowIndices); else if (map is INodeBoolMap) CopyColumnToMap((DataTable)source, srcColIndex, network, (INodeBoolMap)map, rowIndices); else if (map is INodeStringMap) CopyColumnToMap((DataTable)source, srcColIndex, network, (INodeStringMap)map, rowIndices); else DoError(source, srcColIndex, network, map); }
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 Setting Auto Gain Control with dedicated range. // Create NodeMap pointer for accessing parameters INodeMap nodeMap = device.GetRemoteIStPort().GetINodeMap(); // Switch on Gain Auto(IEnumeration). IEnum enumGainAuto = nodeMap.GetNode <IEnum>("GainAuto"); enumGainAuto.FromString("Continuous"); // Get Node for Auto Luminance Target(IInteger) IInteger intAutoLuminTgt = nodeMap.GetNode <IInteger>("AutoLuminanceTarget"); // Set Auto Luminance Target to 128 intAutoLuminTgt.Value = 128; // For setting analog gain, gain selector need to be set to AnalogAll to access analog gain. IEnum enumGainSelector = nodeMap.GetNode <IEnum>("GainSelector"); enumGainSelector.FromString("AnalogAll"); // Get Node for GainAutoLimitMin(IFloat). IFloat floatGainAutoMin = nodeMap.GetNode <IFloat>("GainAutoLimitMin"); // Set Auto Gain Min to 0 dB (0). floatGainAutoMin.Value = 20; // Get Node for GainAutoLimitMax(IFloat). IFloat floatGainAutoMax = nodeMap.GetNode <IFloat>("GainAutoLimitMax"); // Set Auto Gain Max to 10 dB (100). floatGainAutoMax.Value = 100; // ============================================================================================================== 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(); } }
// This function queries an interface for its cameras and then prints // out device information. int QueryInterface(IManagedInterface managedInterface) { int result = 0; try { // // Retrieve TL nodemap from interface // // *** NOTES *** // Each interface has a nodemap that can be retrieved in order // to access information about the interface itself, any devices // connected, or addressing information if applicable. // INodeMap nodeMapInterface = managedInterface.GetTLNodeMap(); // // Print interface display name // // *** NOTES *** // Grabbing node information requires first retrieving the node // and then retrieving its information. There are two things to // keep in mind. First, a node is distinguished by type, which // is related to its value's data type. Second, nodes should be // checked for availability and readability/writability prior to // making an attempt to read from or write to them. // IString iInterfaceDisplayName = nodeMapInterface.GetNode <IString>("InterfaceDisplayName"); if (iInterfaceDisplayName != null && iInterfaceDisplayName.IsReadable) { string interfaceDisplayName = iInterfaceDisplayName.Value; Console.WriteLine("{0}", interfaceDisplayName); } else { Console.WriteLine("Interface display name not readable"); } // // Update list of cameras on the interface // // *** NOTES *** // Updating the cameras on each interface is especially important // if there has been any device arrivals or removals since the // last time UpdateCameras() was called. // managedInterface.UpdateCameras(); // // Retrieve list of cameras from the interface // // *** NOTES *** // Camera lists can be retrieved from an interface or the system // object. Camera lists retrieved from an interface, such as this // one, only return cameras attached on that specific interface // while camera lists retrieved from system returns all cameras // on all interfaces. // // *** LATER *** // Camera lists must be cleared manually. This must be done // prior to releasing the system and while the camera list is // still in scope. // List <IManagedCamera> camList = managedInterface.GetCameras(); // Return if no cameras detected if (camList.Count == 0) { Console.WriteLine("\tNo devices detected.\n"); return(0); } // Print device vendor and model name for each camera on the // interface for (int i = 0; i < camList.Count; i++) { // // Select camera // // *** NOTES *** // Each camera is retrieved from a camera list with an index. // If the index is out of range, an exception is thrown. // IManagedCamera cam = camList[i]; // Retrieve TL device nodemap; please see NodeMapInfo_CSharp // example for additional information on TL device nodemaps INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap(); Console.Write("\tDevice {0} ", i); // Print device vendor name and device model name IString iDeviceVendorName = nodeMapTLDevice.GetNode <IString>("DeviceVendorName"); if (iDeviceVendorName != null && iDeviceVendorName.IsReadable) { String deviceVendorName = iDeviceVendorName.Value; Console.Write("{0} ", deviceVendorName); } IString iDeviceModelName = nodeMapTLDevice.GetNode <IString>("DeviceModelName"); if (iDeviceModelName != null && iDeviceModelName.IsReadable) { String deviceModelName = iDeviceModelName.Value; Console.WriteLine("{0}\n", deviceModelName); } // Dispose of managed camera cam.Dispose(); // // Clear camera list before losing scope // // *** NOTES *** // If a camera list (or an interface list) is not cleaned up // manually, the system will do so when the system is // released. // camList.Clear(); } } catch (SpinnakerException ex) { Console.WriteLine("Error " + ex.Message); result = -1; } return(result); }
public void CopyToMap(object source, string srcColName, INetworkAdjList network, INodeMap map, IList<int> rowIndices) { CheckParameters(source); int srcColIndex = ((DataTable)source).Columns[srcColName].Ordinal; _CopyToMap((DataTable)source, srcColIndex, network, map, rowIndices); }
public void CopyToMap(object source, int srcColIndex, INetworkAdjList network, INodeMap map, IList<int> rowIndices) { CheckParameters(source); _CopyToMap((DataTable)source, srcColIndex, network, map, rowIndices); }
public void CopyToFrame(INetworkAdjList network, INodeMap map, IFrame frame) { if (map is INodeIntMap) CopyMapToFrame(network, (INodeIntMap)map, frame); else if (map is INodeDoubleMap) CopyMapToFrame(network, (INodeDoubleMap)map, frame); else if (map is INodeBoolMap) CopyMapToFrame(network, (INodeBoolMap)map, frame); else if (map is INodeStringMap) CopyMapToFrame(network, (INodeStringMap)map, frame); else { if (map!=null) { throw new InvalidOperationException(string.Format( "The node map to copy is of an unsupported type: {0}", LayerDataTypeConverter.ToType(map.DataType).Name)); } } }
public void DeleteNodeMap(INodeMap layer) { throw new NotImplementedException(); }
//void SetCameraVideoModeAndFrameRate(VideoMode newVideoMode, FrameRate newFrameRate) //{ // bool restartCapture = true; // try // { // camera.StopCapture(); // } // catch (FC2Exception ex) // { // if (ex.Type != ErrorType.IsochNotStarted) // { // throw; // } // else // restartCapture = false; // } // try // { // camera.SetVideoModeAndFrameRate(newVideoMode, newFrameRate); // } // catch (FC2Exception /*ex*/) // { // throw; // } // if (restartCapture) // { // camera.StartCapture(); // } //} //void SetAbsolutePropertyValue(PropertyType property, float newValue) //{ // CameraProperty camProp = camera.GetProperty(property); // CameraPropertyInfo propInfo = camera.GetPropertyInfo(property); // if (!camProp.autoManualMode && propInfo.manualSupported && propInfo.absValSupported) // { // float difference = camProp.absValue - newValue; // if (difference != 0) // { // // The brightness abs register sometimes starts drifting // // due to a rounding error between the camera and the // // actual value being held by the adjustment. To prevent // // this, only apply the change to the camera if the // // difference is greater than a specified amount. // // Check if the difference is greater than 0.005f. // if (property != PropertyType.Brightness || // Math.Abs(difference) > 0.005f) // { // camProp.absControl = true; // camProp.absValue = newValue; // camera.SetProperty(camProp); // } // } // } // else // { // throw new ApplicationException("Trying to set a property that cannot be adjusted"); // } //} public void SetAbsolutePropertyValue(string property, string newValue) { try { if (property == "Hue") { IFloat hue = nodeMap.GetNode <IFloat>("Hue"); hue.Value = Convert.ToDouble(newValue); } else if (property == "Gamma") { IFloat gamma = nodeMap.GetNode <IFloat>("Gamma"); gamma.Value = Convert.ToDouble(newValue); } else if (property == "Width") { IInteger width = nodeMap.GetNode <IInteger>("Width"); width.Value = Convert.ToInt32(newValue); } else if (property == "Height") { IInteger height = nodeMap.GetNode <IInteger>("Height"); height.Value = Convert.ToInt32(newValue); } else if (property == "Gain") { IEnum gainAuto = nodeMap.GetNode <IEnum>("GainAuto"); gainAuto.Value = "Off"; IFloat gainValue = nodeMap.GetNode <IFloat>("Gain"); gainValue.Value = Convert.ToDouble(newValue); } else if (property == "Saturation") { IEnum saturationAuto = nodeMap.GetNode <IEnum>("SaturationAuto"); saturationAuto.Value = "Off"; IFloat saturationValue = nodeMap.GetNode <IFloat>("Saturation"); saturationValue.Value = Convert.ToDouble(newValue); } else if (property == "Binning") { IInteger binningValue = nodeMap.GetNode <IInteger>("BinningVertical"); binningValue.Value = Convert.ToInt32(newValue); } else if (property == "FrameRate") { IEnum frameRateAuto = nodeMap.GetNode <IEnum>("AcquisitionFrameRateAuto"); frameRateAuto.Value = "Off"; IFloat frameRateValue = nodeMap.GetNode <IFloat>("AcquisitionFrameRate"); frameRateValue.Value = Convert.ToDouble(newValue); } else if (property == "PixelFormat") { IEnum pixelFormat = nodeMap.GetNode <IEnum>("PixelFormat"); IEnumEntry pixelFormatItem = pixelFormat.GetEntryByName(newValue); if (pixelFormatItem?.IsReadable == true) { pixelFormat.Value = pixelFormatItem.Symbolic; } } else if (property == "VideoMode") { IEnum acquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode"); if (acquisitionMode?.IsWritable == true) { IEnumEntry acquisitionModeItem = acquisitionMode.GetEntryByName(newValue); if (acquisitionModeItem?.IsReadable == true) { acquisitionMode.Value = acquisitionModeItem.Symbolic; } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property); } } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property); } } else if (property == "ShutterMode") { IEnum exposureMode = nodeMap.GetNode <IEnum>("ExposureMode"); if (exposureMode?.IsWritable == true) { IEnumEntry exposureModeItem = exposureMode.GetEntryByName(newValue); if (exposureModeItem?.IsReadable == true) { exposureMode.Value = exposureModeItem.Symbolic; } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property); } } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property); } } else if (property == "StreamBufferMode") { INodeMap nodeMapStream = camera.GetTLStreamNodeMap(); IEnum bufferMode = nodeMapStream.GetNode <IEnum>("StreamBufferHandlingMode"); if (bufferMode?.IsWritable == true) { IEnumEntry bufferModeItem = bufferMode.GetEntryByName(newValue); if (bufferModeItem?.IsReadable == true) { bufferMode.Value = bufferModeItem.Symbolic; } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property); } } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property); } } else if (property == "ExposureCompensation") { IFloat expoCompensation = nodeMap.GetNode <IFloat>("pgrExposureCompensation"); expoCompensation.Value = Convert.ToDouble(newValue); } else { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property + " not implemented."); } } catch (SpinnakerException e) { Debug.WriteLine("Error: SetAbsolutePropertyValue for " + property + " exceptoin: " + e.Message); } }
// Code below is directly copied from example_acquisition // This function acquires and saves 10 images from a device. public int AcquireImages(IManagedCamera cam, INodeMap nodeMap, INodeMap nodeMapTLDevice) { int result = 0; writeLog(String.Format("\n*** IMAGE ACQUISITION ***\n\n")); try { // // Set acquisition mode to continuous // // *** NOTES *** // Because the example acquires and saves 10 images, setting // acquisition mode to continuous lets the example finish. If // set to single frame or multiframe (at a lower number of // images), the example would just hang. This is because the // example has been written to acquire 10 images while the // camera would have been programmed to retrieve less than that. // // Setting the value of an enumeration node is slightly more // complicated than other node types. Two nodes are required: // first, the enumeration node is retrieved from the nodemap and // second, the entry node is retrieved from the enumeration node. // The symbolic of the entry node is then set as the new value // of the enumeration node. // // Notice that both the enumeration and entry nodes are checked // for availability and readability/writability. Enumeration // nodes are generally readable and writable whereas entry // nodes are only ever readable. // // Retrieve enumeration node from nodemap IEnum iAcquisitionMode = nodeMap.GetNode <IEnum>("AcquisitionMode"); if (iAcquisitionMode == null || !iAcquisitionMode.IsWritable) { writeLog(String.Format( "Unable to set acquisition mode to continuous (node retrieval). Aborting...\n\n")); return(-1); } // Retrieve entry node from enumeration node IEnumEntry iAcquisitionModeContinuous = iAcquisitionMode.GetEntryByName("Continuous"); if (iAcquisitionModeContinuous == null || !iAcquisitionMode.IsReadable) { writeLog(String.Format( "Unable to set acquisition mode to continuous (enum entry retrieval). Aborting...\n\n")); return(-1); } // Set symbolic from entry node as new value for enumeration node iAcquisitionMode.Value = iAcquisitionModeContinuous.Symbolic; writeLog(String.Format("Acquisition mode set to continuous...\n")); // // Begin acquiring images // // *** NOTES *** // What happens when the camera begins acquiring images depends // on which acquisition mode has been set. Single frame captures // only a single image, multi frame catures a set number of // images, and continuous captures a continuous stream of images. // Because the example calls for the retrieval of 10 images, // continuous mode has been set for the example. // // *** LATER *** // Image acquisition must be ended when no more images are needed. // cam.BeginAcquisition(); writeLog(String.Format("Acquiring images...\n")); // // Retrieve device serial number for filename // // *** NOTES *** // The device serial number is retrieved in order to keep // different cameras from overwriting each other's images. // Grabbing image IDs and frame IDs make good alternatives for // this purpose. // String deviceSerialNumber = ""; IString iDeviceSerialNumber = nodeMapTLDevice.GetNode <IString>("DeviceSerialNumber"); if (iDeviceSerialNumber != null && iDeviceSerialNumber.IsReadable) { deviceSerialNumber = iDeviceSerialNumber.Value; writeLog(String.Format( "Device serial number retrieved as {0}...\n", deviceSerialNumber)); } writeLog(String.Format("\n")); // Retrieve, convert, and save images const int NumImages = 10; for (int imageCnt = 0; imageCnt < NumImages; imageCnt++) { try { // // Retrieve next received image // // *** NOTES *** // Capturing an image houses images on the camera buffer. // Trying to capture an image that does not exist will // hang the camera. // // Using-statements help ensure that images are released. // If too many images remain unreleased, the buffer will // fill, causing the camera to hang. Images can also be // released manually by calling Release(). // using (IManagedImage rawImage = cam.GetNextImage()) { // // Ensure image completion // // *** NOTES *** // Images can easily be checked for completion. This // should be done whenever a complete image is // expected or required. Alternatively, check image // status for a little more insight into what // happened. // if (rawImage.IsIncomplete) { writeLog(String.Format( "Image incomplete with image status {0}...\n", rawImage.ImageStatus)); } else { // // Print image information; width and height // recorded in pixels // // *** NOTES *** // Images have quite a bit of available metadata // including CRC, image status, and offset // values to name a few. // uint width = rawImage.Width; uint height = rawImage.Height; writeLog(String.Format( "Grabbed image {0}, width = {1}, height = {1}\n", imageCnt, width, height)); writeLog(String.Format( "Pixel format is {0}\n", rawImage.PixelFormatName)); // // Convert image to mono 8 // // *** NOTES *** // Images can be converted between pixel formats // by using the appropriate enumeration value. // Unlike the original image, the converted one // does not need to be released as it does not // affect the camera buffer. // // Using statements are a great way to ensure code // stays clean and avoids memory leaks. // leaks. // using (IManagedImage convertedImage = rawImage.Convert(PixelFormatEnums.Mono8)) { // Create a unique filename String filename = "Acquisition-CSharp-"; if (deviceSerialNumber != "") { filename = filename + deviceSerialNumber + "-"; } filename = filename + imageCnt + ".jpg"; // // Save image // // *** NOTES *** // The standard practice of the examples is // to use device serial numbers to keep // images of one device from overwriting // those of another. // convertedImage.Save(filename); writeLog(String.Format("Image saved at {0}\n\n", filename)); } } } } catch (SpinnakerException ex) { writeLog(String.Format("Error: {0}\n", ex.Message)); result = -1; } } // // End acquisition // // *** NOTES *** // Ending acquisition appropriately helps ensure that devices // clean up properly and do not need to be power-cycled to // maintain integrity. // cam.EndAcquisition(); } catch (SpinnakerException ex) { writeLog(String.Format("Error: {0}\n", ex.Message)); result = -1; } return(result); }
public void CopyToMap(DataTable table, int srcColIndex, INetworkAdjList network, INodeMap map) { if (map is INodeIntMap) CopyColumnToMap(table, srcColIndex, network, (INodeIntMap)map); else if (map is INodeDoubleMap) CopyColumnToMap(table, srcColIndex, network, (INodeDoubleMap)map); else if (map is INodeBoolMap) CopyColumnToMap(table, srcColIndex, network, (INodeBoolMap)map); else if (map is INodeStringMap) CopyColumnToMap(table, srcColIndex, network, (INodeStringMap)map); else DoError(table, srcColIndex, network, map); }
internal void _CopyToMap(DataTable source, int srcColIndex, INetworkAdjList network, INodeMap map, IList<int> rowIndices) { if (map is INodeIntMap) { if (source.Columns[srcColIndex].DataType == typeof(int)) CopyColumnToMap(source, srcColIndex, network, (INodeIntMap)map); else ConvertColumnToMap(source, srcColIndex, network, (INodeIntMap)map); } else if (map is INodeDoubleMap) { if (source.Columns[srcColIndex].DataType == typeof(double)) CopyColumnToMap(source, srcColIndex, network, (INodeDoubleMap)map); else ConvertColumnToMap(source, srcColIndex, network, (INodeDoubleMap)map); } else if (map is INodeBoolMap) CopyColumnToMap(source, srcColIndex, network, (INodeBoolMap)map); else if (map is INodeStringMap) CopyColumnToMap(source, srcColIndex, network, (INodeStringMap)map); else DoError(source, srcColIndex, network, map); }
public void CopyToMap(DataTable table, string srcColName, INetworkAdjList network, INodeMap map) { int index = table.Columns[srcColName].Ordinal; CopyToMap(table, index, network, map); }
public override bool Connect() { bool result = false; //try //{ // CameraSelectionDialog m_selDlg = new CameraSelectionDialog(); // if (m_selDlg.ShowModal()) // { // ManagedPGRGuid[] guids = m_selDlg.GetSelectedCameraGuids(); // if (guids.Length == 0) // { // //MessageBox.Show("Please select a camera", "No camera selected"); // return false; // } // camera = new ManagedCamera(); // m_ctldlg = new CameraControlDialog(); // camera.Connect(guids[0]); // //initialise settings // InitializeSettings(); // InitializeSettingsWB(); // CameraInfo ci = camera.GetCameraInfo(); // SerialNumber = ci.serialNumber; // result = true; // } //} //catch (Exception /*ex*/) //{ // //App.LogEntry.AddEntry("Failed to Connect to Point Grey Camera : " + ex.Message); // result = false; //} system = new ManagedSystem(); IList <IManagedCamera> camList = system.GetCameras(); if (camList.Count != 1) { int count = camList.Count; foreach (IManagedCamera mc in camList) { mc.Dispose(); } // Clear camera list before releasing system camList.Clear(); // Release system system.Dispose(); throw new Exception("Only one camera should be connected, but found " + count); } camera = camList[0]; // Initialize camera camera.Init(); // Retrieve GenICam nodemap nodeMap = camera.GetNodeMap(); SerialNumber = Convert.ToUInt32(camera.DeviceSerialNumber); //initialise settings try { InitializeSettings(); InitializeSettingsWB(); result = true; } catch (SpinnakerException ex) { result = false; Debug.WriteLine("PtGrey connect failed: " + ex.Message); } return(result); }
public void CopyToMap(object source, string srcColName, INetworkAdjList network, INodeMap map, IList<int> rowIndices) { int index = ((DataTable)source).Columns[srcColName].Ordinal; CopyToMap((DataTable)source, index, network, map, rowIndices); }
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 Setting Software Trigger ON // Create NodeMap pointer for accessing parameters INodeMap nodeMap = device.GetRemoteIStPort().GetINodeMap(); // Switch on Trigger Mode(IEnumeration). IEnum enumTriggerMode = nodeMap.GetNode <IEnum>("TriggerMode"); enumTriggerMode.FromString("On"); // Set Trigger Source to Software IEnum enumTriggerSource = nodeMap.GetNode <IEnum>("TriggerSource"); enumTriggerSource.FromString("Software"); // Prepear Software Trigger Command for later calling ICommand cmdTriggerSoftware = nodeMap.GetNode <ICommand>("TriggerSoftware"); // ============================================================================================================== dataStream.StartAcquisition(nCountOfImagesToGrab); device.AcquisitionStart(); while (dataStream.IsGrabbing) { // =============================================================================== // Demostration sending software trigger cmdTriggerSoftware.Execute(); Console.WriteLine("Software Trigger Sent."); // =============================================================================== 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(); // ============================================================================================================== // Set Software Trigger OFF after using // Switch off Trigger Mode(IEnumeration) after acquiring. enumTriggerMode.FromString("Off"); // ============================================================================================================== } } catch (Exception e) { Console.Error.WriteLine("An exception occurred. \r\n" + e.Message); } finally { Console.WriteLine("\r\nPress Enter to exit."); Console.ReadLine(); } }
private void DoError(object source, int srcColIndex, INetworkAdjList network, INodeMap map) { DataTable table = source as DataTable; if (table != null) { if (srcColIndex >= 0 && srcColIndex < table.Columns.Count) { Type type = table.Columns[srcColIndex].DataType; throw new InvalidOperationException(string.Format( "The column at index {0} with data type {1} cannot be copied to a node map as this type is not currently supported as a node attribute.", srcColIndex, type.Name)); } else { throw new InvalidOperationException(string.Format( "The index of the column to copy must be in the range [0,n) where n is the number of columns in the table; {0} is not a valid column index.", srcColIndex)); } } else { throw new InvalidOperationException(string.Format("The data source object is expected to be an DataTable.")); } }
protected override void OptimizeAfterSequencing(IComparer <object> inEdgeOrder, IComparer <object> outEdgeOrder, LayoutGraph graph, ILayers layers, ILayoutDataProvider ldp, IItemFactory itemFactory) { edge2LaneCrossing = Maps.CreateHashedEdgeMap(); node2LaneAlignment = Maps.CreateHashedNodeMap(); var criticalEdges = Maps.CreateHashedEdgeMap(); // determine whether an edge crosses a swim lane border and if so in which direction foreach (var edge in graph.Edges) { var originalEdge = GetOriginalEdge(edge, ldp); // now we have a 'real' edge with valid valid source and target nodes var originalSourceId = GetLaneId(originalEdge.Source, ldp); var originalTargetId = GetLaneId(originalEdge.Target, ldp); LaneCrossing crossing = LaneCrossing.None; if (originalSourceId != originalTargetId) { // check if we need to flip the sides because edge and original edge have different directions var flipSides = edge.Source != originalEdge.Source; var sourceId = flipSides ? originalTargetId : originalSourceId; var targetId = flipSides ? originalSourceId : originalTargetId; crossing = sourceId > targetId ? LaneCrossing.ToWest : LaneCrossing.ToEast; } edge2LaneCrossing.Set(edge, crossing); } // determine basic node alignment foreach (var n in graph.Nodes) { LaneAlignment alignment = CalculateLaneAlignment(n); node2LaneAlignment.Set(n, alignment); } foreach (var n in graph.Nodes) { // sort the edges with the provided comparer n.SortInEdges(inEdgeOrder); n.SortOutEdges(outEdgeOrder); // calculate 'critical' in and out-edges whose nodes should be aligned in flow var bestInEdge = n.InDegree > 0 ? GetBestFlowEdge(n.InEdges, ldp, graph) : null; var bestOutEdge = n.OutDegree > 0 ? GetBestFlowEdge(n.OutEdges, ldp, graph) : null; if (bestInEdge != null) { criticalEdges.SetDouble(bestInEdge, criticalEdges.GetDouble(bestInEdge) + 0.5); } if (bestOutEdge != null) { criticalEdges.SetDouble(bestOutEdge, criticalEdges.GetDouble(bestOutEdge) + 0.5); } if (n.Degree <= 4) { // should usually be the case and we can distribute each edge to its own side // remember which node side is already taken by an in- or out-edge bool westTakenByInEdge = false; bool eastTakenByInEdge = false; bool westTakenByOutEdge = false; bool eastTakenByOutEdge = false; if (n.InDegree > 0 && n.OutDegree < 3) { // if there are at least three out-edges, we distribute those first, otherwise we start with the in-edges var firstInEdge = n.FirstInEdge; var lastInEdge = n.LastInEdge; if (GetLaneCrossing(firstInEdge) == LaneCrossing.ToEast && (n.InDegree > 1 || IsSameLayerEdge(firstInEdge, ldp))) { // the first in-edge comes from west and is either a same layer edge or there are other in-edges ConstrainWest(firstInEdge, false, itemFactory); westTakenByInEdge = true; } if (!westTakenByInEdge || n.OutDegree < 2) { // don't use west and east side for in-edges if there are at least 2 out-edges if (GetLaneCrossing(lastInEdge) == LaneCrossing.ToWest && (n.InDegree > 1 || IsSameLayerEdge(lastInEdge, ldp))) { // the last in-edge comes from east and is either // a same-layer edge or there are other in-edges ConstrainEast(lastInEdge, false, itemFactory); eastTakenByInEdge = true; } } } if (n.OutDegree > 0) { var firstOutEdge = n.FirstOutEdge; var lastOutEdge = n.LastOutEdge; if (!westTakenByInEdge) { // the west side is still free if (BpmnLayout.IsBoundaryInterrupting(firstOutEdge, graph) || (GetLaneCrossing(firstOutEdge) == LaneCrossing.ToWest) && (n.OutDegree > 1 || IsSameLayerEdge(firstOutEdge, ldp))) { // the first out-edge is either boundary interrupting or goes to west and // is either a same layer edge or there are other out-edges ConstrainWest(firstOutEdge, true, itemFactory); westTakenByOutEdge = true; } else if (eastTakenByInEdge && n.OutDegree >= 2 && !IsSameLayerEdge(firstOutEdge.NextOutEdge, ldp)) { // the east side is already taken but we have more then one out edge. // if the second out edge is a same layer edge, constraining the firstOutEdge could lead to // no in-flow edge ConstrainWest(firstOutEdge, true, itemFactory); westTakenByOutEdge = true; } } if (!eastTakenByInEdge) { // the east side is still free if (GetLaneCrossing(lastOutEdge) == LaneCrossing.ToEast && (n.OutDegree > 1 || IsSameLayerEdge(lastOutEdge, ldp))) { // the last out-edge goes to east and // is either a same layer edge or there are other out-edges ConstrainEast(lastOutEdge, true, itemFactory); eastTakenByOutEdge = true; } else if (westTakenByInEdge && n.OutDegree >= 2 && !IsSameLayerEdge(lastOutEdge.PrevOutEdge, ldp)) { // the west side is already taken but we have more then one out edge. // if the second last out edge is a same layer edge, constraining the lastOutEdge could lead to // no in-flow edge ConstrainEast(lastOutEdge, true, itemFactory); eastTakenByOutEdge = true; } } } // distribute remaining in-edges if (n.InDegree == 2 && !(eastTakenByInEdge || westTakenByInEdge)) { // two in-edges but none distributed, yet if (bestInEdge == n.FirstInEdge && !eastTakenByOutEdge) { // first in-edge is in-flow edge and east side is still free ConstrainEast(n.LastInEdge, false, itemFactory); eastTakenByInEdge = true; } else if (bestInEdge == n.LastInEdge && !westTakenByOutEdge) { // last in-edge is in-flow edge and west side is still free ConstrainWest(n.FirstInEdge, false, itemFactory); westTakenByInEdge = true; } } else if (n.InDegree == 3 && !(eastTakenByInEdge && westTakenByInEdge) && !(IsSameLayerEdge(n.FirstInEdge.NextInEdge, ldp))) { // three in-edges but not both sides taken, yet and the middle edge is no same layer edge if (!eastTakenByOutEdge) { // if not already taken, constraint the last in-edge to east ConstrainEast(n.LastInEdge, false, itemFactory); eastTakenByInEdge = true; } if (!westTakenByOutEdge) { // if not already taken, constraint the first in-edge to west ConstrainWest(n.FirstInEdge, false, itemFactory); westTakenByInEdge = true; } } // distribute remaining out-edges if (n.OutDegree == 2 && !(eastTakenByOutEdge || westTakenByOutEdge)) { // two out-edges but none distributed, yet if (bestOutEdge == n.FirstOutEdge && !eastTakenByInEdge) { // first out-edge is in-flow edge and east side is still free ConstrainEast(n.LastOutEdge, true, itemFactory); eastTakenByOutEdge = true; } else if (bestOutEdge == n.LastOutEdge && !westTakenByInEdge) { // last out-edge is in-flow edge and west side is still free ConstrainWest(n.FirstOutEdge, true, itemFactory); westTakenByOutEdge = true; } } else if (n.OutDegree == 3 && !(eastTakenByOutEdge && westTakenByOutEdge) && !(IsSameLayerEdge(n.FirstOutEdge.NextOutEdge, ldp))) { // three out-edges but not both sides taken, yet and the middle edge is no same layer edge if (!eastTakenByInEdge) { // if not already taken, constraint the last out-edge to east ConstrainEast(n.LastOutEdge, true, itemFactory); eastTakenByOutEdge = true; } if (!westTakenByInEdge) { // if not already taken, constraint the first out-edge to west ConstrainWest(n.FirstOutEdge, true, itemFactory); westTakenByOutEdge = true; } } } } // register the data provider for critical edge paths. It is deregistered again by BpmnLayout itself graph.AddDataProvider(HierarchicLayout.CriticalEdgePriorityDpKey, criticalEdges); sameLayerData = null; edge2LaneCrossing = null; node2LaneAlignment = null; }
public IManagedImage RetrieveMonoImage() { IManagedImage imgResult = null; // Retrieve singleton reference to system object ManagedSystem system = new ManagedSystem(); // Retrieve list of cameras from the system IList <IManagedCamera> camList = system.GetCameras(); if (camList.Count < 1) { writeLog(String.Format("No camera detected. Aborted.\n\n")); return(null); } else { writeLog(String.Format("Number of cameras detected: {0}\n\n", camList.Count)); } // Use the first camera using (camList[0]) { writeLog(String.Format("Running example for the 1st camera...\n")); IManagedCamera cam = camList[0]; try { // Run for a camera // Retrieve TL device nodemap and print device information INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap(); PrintDeviceInfo(nodeMapTLDevice); // Initialize camera cam.Init(); // Retrieve GenICam nodemap INodeMap nodeMap = cam.GetNodeMap(); /***** Acquire single BW image from the camera *****/ writeLog(String.Format("\n*** BW IMAGE ACQUISITION ***\n\n")); SetNodeMapItem(nodeMap, "AcquisitionMode", "Continuous"); cam.BeginAcquisition(); using (IManagedImage rawImage = cam.GetNextImage()) { if (rawImage.IsIncomplete) { writeLog(String.Format( "Image incomplete with image status {0}...\n", rawImage.ImageStatus)); imgResult = null; } else { // TODO: Need to return the acquired rawImage here. //IManagedImage monoImage = rawImage.Convert( // PixelFormatEnums.Mono16, ColorProcessingAlgorithm.EDGE_SENSING); IManagedImage monoImage = rawImage.Convert(PixelFormatEnums.Mono8); imgResult = monoImage; } } cam.EndAcquisition(); /***** Acquiring Complete *****/ // Deinitialize camera cam.DeInit(); } catch (SpinnakerException ex) { writeLog(String.Format("Error: {0}\n", ex.Message)); imgResult = null; } writeLog(String.Format("Camera example complete...\n")); } // Clear camera list before releasing system camList.Clear(); // Release system system.Dispose(); writeLog(String.Format("Done!\n")); return(imgResult); }
/// <summary>Throws Spinnaker Exception</summary> /// <returns>The property node.</returns> protected bool GetNode(ref NodeType newNode) { try { if (camera == null) { throw new SpinnakerException("Camera is null."); } INodeMap map = camera.GetNodeMap(); if (map == null) { throw new SpinnakerException("Could not retrieve node map."); } newNode = map.GetNode <NodeType>(NodeName); if (newNode == null) { return(false); } return(true); } catch (SpinnakerException ex) { Console.Error.WriteLine("Unable to retrieve node: " + ex.Message); return(false); } }
// This function prints the device information of the camera from the // transport layer; please see NodeMapInfo_CSharp example for more // in-depth comments on printing device information from the nodemap. public int PrintDeviceInfo(INodeMap nodeMap) { int result = 0; try { writeLog(String.Format("\n*** DEVICE INFORMATION ***\n")); ICategory category = nodeMap.GetNode <ICategory>("DeviceInformation"); if (category != null && category.IsReadable) { for (int i = 0; i < category.Children.Length; i++) { writeLog(String.Format( "{0}: {1}\n", category.Children[i].Name, (category.Children[i].IsReadable ? category.Children[i].ToString() : "Node not available"))); } writeLog(String.Format("\n")); } else { writeLog(String.Format("Device control information not available.\n")); } } catch (SpinnakerException ex) { writeLog(String.Format("Error: {0}\n", ex.Message)); result = -1; } 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); // ============================================================================================================== // Saving current setting to UserSet1 of camera, with setting it as default when camera power on. // Please notice the UserSet saving can be only avaliable when camera is not in acquiring. // Create NodeMap pointer for accessing parameters INodeMap nodeMap = device.GetRemoteIStPort().GetINodeMap(); // Select which UserSet to save the setting (UserSet1) IEnum enumUserSetSelector = nodeMap.GetNode <IEnum>("UserSetSelector"); enumUserSetSelector.FromString("UserSet1"); // Acquire and execute saving setting to UserSet ICommand cmdSaveToUserSet = nodeMap.GetNode <ICommand>("UserSetSave"); cmdSaveToUserSet.Execute(); Console.WriteLine("Save Current setting to UserSet1 succeed."); // Set UserSetDefault to UsetSet1 for using this setting when camera power on. IEnum enumUserSetDefault = nodeMap.GetNode <IEnum>("UserSetDefault"); enumUserSetDefault.FromString("UserSet1"); Console.WriteLine("Set UserSetDefault to UserSet1 succeed."); // ============================================================================================================== } } catch (Exception e) { Console.Error.WriteLine("An exception occurred. \r\n" + e.Message); } finally { Console.WriteLine("\r\nPress Enter to exit."); Console.ReadLine(); } }