Beispiel #1
0
        /// <summary>
        /// Call this method to resolve full path to GeometryFactoryAssembly
        /// assembly, given the root folder and the version. This method throws
        /// an exception if either of the folders/assembly cannot be found.
        /// </summary>
        /// <param name="rootFolder">Full path of the directory that contains
        /// LibG_xxx folder, where 'xxx' represents the library version. In a
        /// typical setup this would be the same directory that contains Dynamo
        /// core modules. This must represent a valid directory.</param>
        /// <param name="version">Version number of the targeted geometry library.
        /// If the resulting folder does not exist, this method throws an
        /// FileNotFoundException.</param>
        /// <returns>The full path to GeometryFactoryAssembly assembly.</returns>
        ///
        public static string GetGeometryFactoryPath(string rootFolder, LibraryVersion version)
        {
            if (string.IsNullOrEmpty(rootFolder))
            {
                throw new ArgumentNullException("rootFolder");
            }

            if (!Directory.Exists(rootFolder))
            {
                // Root directory must be specified and valid.
                throw new DirectoryNotFoundException(string.Format(
                                                         "Directory not found: {0}", rootFolder));
            }

            var libGFolderName = string.Format("libg_{0}", ((int)version));
            var libGFolder     = Path.Combine(rootFolder, libGFolderName);

            if (!Directory.Exists(libGFolder))
            {
                // LibG_xxx folder must be valid.
                throw new DirectoryNotFoundException(string.Format(
                                                         "Directory not found: {0}", libGFolder));
            }

            var assemblyPath = Path.Combine(libGFolder, GeometryFactoryAssembly);

            if (!File.Exists(assemblyPath))
            {
                throw new FileNotFoundException(string.Format(
                                                    "File not found: {0}", assemblyPath));
            }

            return(assemblyPath);
        }
Beispiel #2
0
        public Preloader(string rootFolder, string shapeManagerPath, LibraryVersion version)
        {
            if (string.IsNullOrEmpty(rootFolder))
            {
                throw new ArgumentNullException("rootFolder");
            }
            if (!Directory.Exists(rootFolder))
            {
                throw new DirectoryNotFoundException(rootFolder);
            }

            if (string.IsNullOrEmpty(shapeManagerPath))
            {
                throw new ArgumentNullException("shapeManagerPath");
            }
            if (!Directory.Exists(shapeManagerPath))
            {
                throw new DirectoryNotFoundException(shapeManagerPath);
            }

            if (version == LibraryVersion.None)
            {
                throw new ArgumentOutOfRangeException("version");
            }

            this.version          = MapLibGVersionEnumToFullVersion(version);
            this.shapeManagerPath = shapeManagerPath;

            var libGFolderName = string.Format("libg_{0}_{1}_{2}", this.version.Major, this.version.Minor, this.version.Build);

            preloaderLocation   = Path.Combine(rootFolder, libGFolderName);
            geometryFactoryPath = Path.Combine(preloaderLocation,
                                               Utilities.GeometryFactoryAssembly);
        }
Beispiel #3
0
        /// <summary>
        /// Constructs a preloader object to help preload a specific version of
        /// shape manager.
        /// </summary>
        /// <param name="rootFolder">Full path of the directory that contains
        /// LibG_xxx folder, where 'xxx' represents the library version. In a
        /// typical setup this would be the same directory that contains Dynamo
        /// core modules. This must represent a valid directory.
        /// </param>
        /// <param name="versions">A list of version numbers to check for in order
        /// of preference. This argument cannot be null or empty.</param>
        ///
        public Preloader(string rootFolder, IEnumerable <LibraryVersion> versions)
        {
            if (string.IsNullOrEmpty(rootFolder))
            {
                throw new ArgumentNullException("rootFolder");
            }
            if (!Directory.Exists(rootFolder))
            {
                throw new DirectoryNotFoundException(rootFolder);
            }
            if ((versions == null) || !versions.Any())
            {
                throw new ArgumentNullException("versions");
            }

            var versionList = versions.ToList();

            shapeManagerPath = string.Empty; // Folder that contains ASM binaries.
            version          = Utilities.GetInstalledAsmVersion(versionList, ref shapeManagerPath, rootFolder);

            var libGFolderName = string.Format("libg_{0}", ((int)version));

            preloaderLocation   = Path.Combine(rootFolder, libGFolderName);
            geometryFactoryPath = Path.Combine(preloaderLocation,
                                               Utilities.GeometryFactoryAssembly);
        }
Beispiel #4
0
        private void _UpdateFromLegacy()
        {
            // Search for the appropriate JMSML Library elements, given the older/legacy (2525C, 2525B, etc.)
            // SIDC for this Symbol.

            _librarian.ResetStatusCode();

            _version = _librarian.Version(1, 0);

            _affiliation = _librarian.Affiliation(_legacySIDC.Substring(1, 1), _legacySIDC.Substring(2, 1));

            if (_affiliation != null)
            {
                _context          = _librarian.Context(_affiliation.ContextID);
                _standardIdentity = _librarian.StandardIdentity(_affiliation.StandardIdentityID);
            }

            _dimension = _librarian.DimensionByLegacyCode(_legacySIDC.Substring(2, 1));

            if (_dimension != null)
            {
                _symbolSet = _librarian.SymbolSet(_dimension.ID, _legacySIDC.Substring(4, 6));
            }

            _status    = _librarian.Status(_legacySIDC.Substring(3, 1));
            _hqTFDummy = _librarian.HQTFDummy(_legacySIDC.Substring(10, 1));

            if (_context != null && _affiliation != null)
            {
                _contextAmplifier = _librarian.ContextAmplifier(_context, _affiliation.Shape);
            }

            _amplifier = _librarian.Amplifier(_legacySIDC.Substring(11, 1));

            if (_amplifier != null)
            {
                _amplifierGroup = _librarian.AmplifierGroup(_amplifier);
            }

            if (_symbolSet != null)
            {
                _legacySymbol = _librarian.LegacySymbol(_symbolSet, _legacySIDC.Substring(4, 6), _legacySIDC.Substring(0, 1), _legacySIDC.Substring(2, 1));
            }

            if (_legacySymbol != null)
            {
                _entity        = _librarian.Entity(_symbolSet, _legacySymbol.EntityID);
                _entityType    = _librarian.EntityType(_entity, _legacySymbol.EntityTypeID);
                _entitySubType = _librarian.EntitySubType(_entityType, _legacySymbol.EntitySubTypeID);
                _modifierOne   = _librarian.ModifierOne(_symbolSet, _legacySymbol.ModifierOneID);
                _modifierTwo   = _librarian.ModifierTwo(_symbolSet, _legacySymbol.ModifierTwoID);
            }

            _librarian.LogConversionResult(_legacySIDC);

            _ValidateStatus();
        }
        private void Startup(LibraryMode mode)
        {
            var version = new LibraryVersion();

            var result = link.Startup(version, mode);

            logger.Information("link.Startup({Mode}) => {Result}", mode, result);
            logger.Information("LibraryVersion {@Version}", new { version.major, version.minor, version.maintenance, version.release });
        }
Beispiel #6
0
        /// <summary>
        /// A TestSessionConfiguration specifies test session configuration properties
        /// for a test.
        /// </summary>
        /// <param name="dynamoCoreDirectory">The location of Dynamo's core directory. If the config file
        /// contains a value for DynamoBasePath, then this parameter will be ignored.</param>
        /// <param name="configFileDirectory">The location of the directory containing the TestServices.dll.config file.
        /// If this parameter is null, the value of dynamoCoreDirectory will be used.</param>
        public TestSessionConfiguration(string dynamoCoreDirectory, string configFileDirectory = null)
        {
            string configPath;

            if (configFileDirectory == null || !Directory.Exists(configFileDirectory))
            {
                configPath = Path.Combine(dynamoCoreDirectory, CONFIG_FILE_NAME);
            }
            else
            {
                configPath = Path.Combine(configFileDirectory, CONFIG_FILE_NAME);
            }

            // If a config file cannot be found, fall back to
            // using the executing assembly's directory for core
            // and version 219 for the shape manager.
            if (!File.Exists(configPath))
            {
                DynamoCorePath = dynamoCoreDirectory;

                var versions = new List <LibraryVersion>
                {
                    LibraryVersion.Version223,
                    LibraryVersion.Version222,
                    LibraryVersion.Version221,
                    LibraryVersion.Version220
                };
                var shapeManagerPath = string.Empty;
                RequestedLibraryVersion = Utilities.GetInstalledAsmVersion(versions, ref shapeManagerPath, dynamoCoreDirectory);
                return;
            }

            // Adjust the config file map because the config file
            // might not always be in the same directory as the dll.
            var map = new ExeConfigurationFileMap {
                ExeConfigFilename = configPath
            };
            var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

            var dir = GetAppSetting(config, "DynamoBasePath");

            DynamoCorePath = string.IsNullOrEmpty(dir) ? dynamoCoreDirectory : dir;

            var versionStr = GetAppSetting(config, "RequestedLibraryVersion");

            LibraryVersion version;

            RequestedLibraryVersion = LibraryVersion.TryParse(versionStr, out version) ?
                                      version : LibraryVersion.Version220;
        }
Beispiel #7
0
        internal static Version MapLibGVersionEnumToFullVersion(LibraryVersion libVersion)
        {
            Version version;

            if (ASMLibVersionToVersion.TryGetValue(libVersion, out version))
            {
                return(version);
            }
            else
            {
                version = new Version((int)libVersion, 0, 0);
                Console.WriteLine("Could not find a full version mapping for LibGVersion: " + libVersion + "returning: " + version.ToString());
                return(version);
            }
        }
        internal LibraryVersion Version(ushort codeOne, ushort codeTwo)
        {
            LibraryVersion retObj = null;

            foreach (LibraryVersion lObj in this._library.Versions)
            {
                if (lObj.VersionCode.DigitOne == codeOne &&
                    lObj.VersionCode.DigitTwo == codeTwo)
                {
                    return(lObj);
                }
            }

            _statusFlag -= 1;

            return(retObj);
        }
        /// <summary>
        /// A TestSessionConfiguration specifies test session configuration properties
        /// for a test.
        /// </summary>
        /// <param name="dynamoCoreDirectory">The location of Dynamo's core directory. If the config file
        /// contains a value for DynamoBasePath, then this parameter will be ignored.</param>
        /// <param name="configFileDirectory">The location of the directory containing the TestServices.dll.config file.
        /// If this parameter is null, the value of dynamoCoreDirectory will be used.</param>
        public TestSessionConfiguration(string dynamoCoreDirectory, string configFileDirectory = null)
        {
            string configPath;
            if (configFileDirectory == null || !Directory.Exists(configFileDirectory))
            {
                configPath = Path.Combine(dynamoCoreDirectory, CONFIG_FILE_NAME);
            }
            else
            {
                configPath = Path.Combine(configFileDirectory, CONFIG_FILE_NAME);
            }

            // If a config file cannot be found, fall back to 
            // using the executing assembly's directory for core
            // and version 219 for the shape manager.
            if (!File.Exists(configPath))
            {
                DynamoCorePath = dynamoCoreDirectory;

                var versions = new List<LibraryVersion>
                {
                    LibraryVersion.Version220,
                    LibraryVersion.Version221,
                    LibraryVersion.Version222
                };
                var shapeManagerPath = string.Empty;
                RequestedLibraryVersion = Utilities.GetInstalledAsmVersion(versions, ref shapeManagerPath, dynamoCoreDirectory);
                return;
            }

            // Adjust the config file map because the config file
            // might not always be in the same directory as the dll.
            var map = new ExeConfigurationFileMap { ExeConfigFilename = configPath };
            var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

            var dir = GetAppSetting(config, "DynamoBasePath");
            DynamoCorePath = string.IsNullOrEmpty(dir) ? dynamoCoreDirectory : dir;

            var versionStr = GetAppSetting(config, "RequestedLibraryVersion");

            LibraryVersion version;
            RequestedLibraryVersion = LibraryVersion.TryParse(versionStr, out version) ? 
                version : LibraryVersion.Version220;
            
        }
        private void _SetInvalidSymbolProps()
        {
            // If a symbol can't be recognized, this method sets up
            // the current symbol to represent the special Invalid symbol.

            _version          = _librarian.Version(1, 0);
            _context          = _librarian.Context(0);
            _dimension        = _librarian.Dimension("INTERNAL");
            _standardIdentity = _librarian.StandardIdentity(1);
            _symbolSet        = _librarian.SymbolSet(9, 8);
            _status           = _librarian.Status(0);
            _hqTFDummy        = _librarian.HQTFDummy(0);
            _amplifierGroup   = _librarian.AmplifierGroup(0);
            _amplifier        = _librarian.Amplifier(_amplifierGroup, 0);
            _affiliation      = _librarian.Affiliation("REALITY", "INTERNAL", "SI_UNKNOWN");
            _entity           = _librarian.Entity(_symbolSet, "INVALID");
            _entityType       = null;
            _entitySubType    = null;
            _modifierOne      = null;
            _modifierTwo      = null;
        }
Beispiel #11
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (LibraryVersion != 0)
            {
                hash ^= LibraryVersion.GetHashCode();
            }
            if (Compressed != false)
            {
                hash ^= Compressed.GetHashCode();
            }
            if (Data.Length != 0)
            {
                hash ^= Data.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Beispiel #12
0
        /// <summary>
        /// Call this method to resolve full path to GeometryFactoryAssembly 
        /// assembly, given the root folder and the version. This method throws 
        /// an exception if either of the folders/assembly cannot be found.
        /// </summary>
        /// <param name="rootFolder">Full path of the directory that contains 
        /// LibG_xxx folder, where 'xxx' represents the library version. In a 
        /// typical setup this would be the same directory that contains Dynamo 
        /// core modules. This must represent a valid directory.</param>
        /// <param name="version">Version number of the targeted geometry library.
        /// If the resulting folder does not exist, this method throws an 
        /// FileNotFoundException.</param>
        /// <returns>The full path to GeometryFactoryAssembly assembly.</returns>
        /// 
        public static string GetGeometryFactoryPath(string rootFolder, LibraryVersion version)
        {
            if (string.IsNullOrEmpty(rootFolder))
                throw new ArgumentNullException("rootFolder");

            if (!Directory.Exists(rootFolder))
            {
                // Root directory must be specified and valid.
                throw new DirectoryNotFoundException(string.Format(
                    "Directory not found: {0}", rootFolder));
            }

            var libGFolderName = string.Format("libg_{0}", ((int) version));
            var libGFolder = Path.Combine(rootFolder, libGFolderName);
            if (!Directory.Exists(libGFolder))
            {
                // LibG_xxx folder must be valid.
                throw new DirectoryNotFoundException(string.Format(
                    "Directory not found: {0}", libGFolder));
            }

            var assemblyPath = Path.Combine(libGFolder, GeometryFactoryAssembly);
            if (!File.Exists(assemblyPath))
            {
                throw new FileNotFoundException(string.Format(
                    "File not found: {0}", assemblyPath));
            }

            return assemblyPath;
        }
Beispiel #13
0
        /// <summary>
        /// Constructs a preloader object to help preload the specified version 
        /// of shape manager from the given directory.
        /// </summary>
        /// <param name="rootFolder">Full path of the directory that contains 
        /// LibG_xxx folder, where 'xxx' represents the library version. In a 
        /// typical setup this would be the same directory that contains Dynamo 
        /// core modules. This must represent a valid directory.
        /// </param>
        /// <param name="shapeManagerPath">The directory from where shape manager
        /// binaries can be preloaded from.</param>
        /// <param name="version">The version of shape manager.</param>
        /// 
        public Preloader(string rootFolder, string shapeManagerPath, LibraryVersion version)
        {
            if (string.IsNullOrEmpty(rootFolder))
                throw new ArgumentNullException("rootFolder");
            if (!Directory.Exists(rootFolder))
                throw new DirectoryNotFoundException(rootFolder);

            if (string.IsNullOrEmpty(shapeManagerPath))
                throw new ArgumentNullException("shapeManagerPath");
            if (!Directory.Exists(shapeManagerPath))
                throw new DirectoryNotFoundException(shapeManagerPath);

            if (version == LibraryVersion.None)
                throw new ArgumentOutOfRangeException("version");

            this.version = version;
            this.shapeManagerPath = shapeManagerPath;

            var libGFolderName = string.Format("libg_{0}", ((int) version));
            preloaderLocation = Path.Combine(rootFolder, libGFolderName);
            geometryFactoryPath = Path.Combine(preloaderLocation,
                Utilities.GeometryFactoryAssembly);
        }
Beispiel #14
0
 public Preloader(string rootFolder, LibraryVersion version)
     : this(rootFolder, new[] { version })
 {
 }
Beispiel #15
0
        public Form1()
        {
            InitializeComponent();

            // initialize multi-camera system:
            system = new ManagedSystem();

            // Print current Spinnaker library version info:
            LibraryVersion spinVersion = system.GetLibraryVersion();

            Console.WriteLine(
                "Spinnaker library version: {0}.{1}.{2}.{3}\n\n",
                spinVersion.major,
                spinVersion.minor,
                spinVersion.type,
                spinVersion.build);

            // Find all Flir cameras on the system:
            managedCameras = system.GetCameras();
            nCameras       = managedCameras.Count;

            // Finish and dispose system if no cameres are detected:
            if (nCameras != 2)
            {
                managedCameras.Clear();
                system.Dispose();
                Console.WriteLine("{0} cameras detected. This application supports exactly 2 cameras. System disposed", nCameras.ToString());
            }

            // Create or select folder to write video data:
            sessionPaths = Util.SetDataWritePaths(animalName: Util.AnimalName.Charlie, nCameras: 2);

            // Initialize OryxSetupInfo Object to pass to camera constructors upon initialization:
            oryxSetupInfos = new Util.OryxSetupInfo[nCameras];
            for (int i = 0; i < nCameras; i++)
            {
                oryxSetupInfos[i] = new Util.OryxSetupInfo();
            }

            bool areCamerasSharingSettings = true;

            if (areCamerasSharingSettings)
            {
                Console.WriteLine("These settings will be loaded on both cameras:");
                oryxSetupInfos[0].PrintSettingsToLoad();
                Console.WriteLine("\n\n");
            }

            // Initialize camera control message queues to control cameras from XBox controller:
            camControlMessageQueues = new ConcurrentQueue <ButtonCommands> [nCameras];
            for (int i = 0; i < nCameras; i++)
            {
                camControlMessageQueues[i] = new ConcurrentQueue <ButtonCommands>();
            }

            // Initialize XBox Controller
            xBoxController = new XBoxController(mainForm: this, camControlMessageQueues: camControlMessageQueues);

            // Initialize queue to connect output from each camera to a thread to merge camera streams:
            streamQueue0 = new ConcurrentQueue <RawMat> [nCameras];
            for (int i = 0; i < nCameras; i++)
            {
                streamQueue0[i] = new ConcurrentQueue <RawMat>();
            }

            // Open each camera on its own thread.
            oryxCameraThreads = new Thread[nCameras];
            for (int i = 0; i < nCameras; i++)
            {
                int    _i           = i;
                string _sessionPath = string.Copy(sessionPaths[i]);

                oryxCameraThreads[i] = new Thread(() => new OryxCamera(camNumber: _i, managedCamera: managedCameras[_i], camControlMessageQueue: camControlMessageQueues[_i],
                                                                       streamOutputQueue: streamQueue0[_i], setupInfo: oryxSetupInfos[_i], sessionPath: _sessionPath));
                oryxCameraThreads[i].IsBackground = false;
                oryxCameraThreads[i].Priority     = ThreadPriority.Highest;
                oryxCameraThreads[i].Start();
            }

            // Initialize queue to send combined images to display form:
            displayQueue = new ConcurrentQueue <Tuple <byte[], Mat> >();

            // Initialize Size of camera stream output image and merged image for display:
            streamFramesize  = new Size(width: oryxSetupInfos[0].streamFramesize.Width, height: oryxSetupInfos[0].streamFramesize.Height);
            displayFramesize = new Size(width: streamFramesize.Width, height: streamFramesize.Height * 2);

            // Initialize thread to merge camera stream data into a single byte array:
            Size _inputImageSize = new Size(width: streamFramesize.Width, height: streamFramesize.Height);

            processingThreadMessageQueue    = new ConcurrentQueue <ButtonCommands>();
            mergeStreamsThread              = new Thread(() => MergeStreamsThreadInit(inputQueues: streamQueue0, outputQueue: displayQueue, messageQueue: processingThreadMessageQueue, inputImgSize: _inputImageSize));
            mergeStreamsThread.IsBackground = true;
            mergeStreamsThread.Priority     = ThreadPriority.Highest;
            mergeStreamsThread.Start();

            // Initialize streaming state
            isStreaming = false;

            // Initialize Timer:
            displayTimer          = new System.Windows.Forms.Timer();
            displayTimer.Interval = 5;
            displayTimer.Tick    += DisplayTimerEventProcessor;
            displayTimer.Enabled  = true;
        }
Beispiel #16
0
        // Example entry point; please see Enumeration_CSharp example for more
        // in-depth comments on preparing and cleaning up the system.
        public static int Start()
        {
            int result = 0;

            Program program = new Program();

            // Ensure write permissions to current folder
            try {
                FileStream fileStream = new FileStream(@"test.txt", FileMode.Create);
                fileStream.Close();
                File.Delete("test.txt");
            } catch {
                Console.WriteLine("Failed to create file in current folder.  Please check permissions.\n");
                Console.WriteLine("\nDone! Press enter to exit...");
                Console.ReadLine();
                return(-1);
            }

            // Retrieve singleton reference to system object
            ManagedSystem system = new ManagedSystem();

            // Print out current library version
            LibraryVersion spinVersion = system.GetLibraryVersion();

            Console.WriteLine("Spinnaker library version: {0}.{1}.{2}.{3}\n\n",
                              spinVersion.major,
                              spinVersion.minor,
                              spinVersion.type,
                              spinVersion.build);

            // Retrieve list of cameras from the system
            List <IManagedCamera> camList = system.GetCameras();

            Console.WriteLine("Number of cameras detected: {0}\n", camList.Count);

            // Finish if there are no cameras
            if (camList.Count == 0)
            {
                // Clear camera list before releasing system
                camList.Clear();

                // Release system
                system.Dispose();

                Console.WriteLine("Not enough cameras!");
                Console.WriteLine("Done! Press Enter to exit...");
                Console.ReadLine();

                return(-1);
            }

            // Run example on each camera
            int index = 0;

            foreach (IManagedCamera managedCamera in camList)
            {
                using (managedCamera) {
                    Console.WriteLine("Running example for camera {0}...", index);

                    try {
                        // Run example
                        result = result | program.RunSingleCamera(managedCamera);
                    } catch (SpinnakerException ex) {
                        Console.WriteLine("Error: {0}", ex.Message);
                        result = -1;
                    }

                    Console.WriteLine("Camera {0} example complete...\n", index++);
                }
            }

            // Clear camera list before releasing system
            camList.Clear();

            // Release system
            system.Dispose();

            Console.WriteLine("\nDone! Press Enter to exit...");
            Console.ReadLine();

            return(result);
        }
Beispiel #17
0
        public string GetSpinnakerLibraryVersion()
        {
            LibraryVersion version = spinnaker.GetLibraryVersion();

            return(version.major + "." + version.minor + "." + version.type + "." + version.build);
        }
Beispiel #18
0
 public static extern Result RFID_Startup
 (
     [In, Out] LibraryVersion pVersion,
     [In]      LibraryMode mode
 );
Beispiel #19
0
 public static string GetGeometryFactoryPath(string rootFolder, LibraryVersion version)
 {
     return(GetGeometryFactoryPath2(rootFolder, Preloader.MapLibGVersionEnumToFullVersion(version)));
 }
        private void _UpdateFromCurrent()
        {
            // Search for the appropriate JMSML Library elements, given the current (2525D)
            // SIDC for this Symbol.

            string first10  = _sidc.PartAString;
            string second10 = _sidc.PartBString;

            _librarian.ResetStatusCode();

            _version = _librarian.Version(Convert.ToUInt16(first10.Substring(0, 1)),
                                          Convert.ToUInt16(first10.Substring(1, 1)));

            _context          = _librarian.Context(Convert.ToUInt16(first10.Substring(2, 1)));
            _standardIdentity = _librarian.StandardIdentity(Convert.ToUInt16(first10.Substring(3, 1)));
            _sig       = _librarian.StandardIdentityGroup(_standardIdentity);
            _symbolSet = _librarian.SymbolSet(Convert.ToUInt16(first10.Substring(4, 1)), Convert.ToUInt16(first10.Substring(5, 1)));

            if (_symbolSet != null)
            {
                _dimension = _librarian.DimensionBySymbolSet(_symbolSet.ID);
            }

            if (_context != null && _dimension != null && _standardIdentity != null)
            {
                _affiliation = _librarian.Affiliation(_context.ID, _dimension.ID, _standardIdentity.ID);
            }

            _status         = _librarian.Status(Convert.ToUInt16(first10.Substring(6, 1)));
            _hqTFDummy      = _librarian.HQTFDummy(Convert.ToUInt16(first10.Substring(7, 1)));
            _amplifierGroup = _librarian.AmplifierGroup(Convert.ToUInt16(first10.Substring(8, 1)));

            if (_amplifierGroup != null)
            {
                _amplifier = _librarian.Amplifier(_amplifierGroup, Convert.ToUInt16(first10.Substring(9, 1)));
            }

            if (_symbolSet != null)
            {
                _entity = _librarian.Entity(_symbolSet, Convert.ToUInt16(second10.Substring(0, 1)), Convert.ToUInt16(second10.Substring(1, 1)));

                if (_entity != null)
                {
                    _entityType = _librarian.EntityType(_entity, Convert.ToUInt16(second10.Substring(2, 1)), Convert.ToUInt16(second10.Substring(3, 1)));
                }

                if (_entityType != null)
                {
                    _entitySubType = _librarian.EntitySubType(_entityType, Convert.ToUInt16(second10.Substring(4, 1)), Convert.ToUInt16(second10.Substring(5, 1)));

                    if (_entitySubType == null)
                    {
                        _entitySubType = _librarian.EntitySubType(_symbolSet, Convert.ToUInt16(second10.Substring(4, 1)), Convert.ToUInt16(second10.Substring(5, 1)));
                    }
                }

                _modifierOne = _librarian.ModifierOne(_symbolSet, Convert.ToUInt16(second10.Substring(6, 1)), Convert.ToUInt16(second10.Substring(7, 1)));
                _modifierTwo = _librarian.ModifierTwo(_symbolSet, Convert.ToUInt16(second10.Substring(8, 1)), Convert.ToUInt16(second10.Substring(9, 1)));

                _legacySymbol = _librarian.LegacySymbol(_symbolSet, _entity, _entityType, _entitySubType, _modifierOne, _modifierTwo);
            }

            _librarian.LogConversionResult(_sidc.PartAString + ", " + _sidc.PartBString);

            _ValidateStatus();
        }
Beispiel #21
0
        // Example entry points; this function sets up the system and retrieves
        // interfaces to retrieves interfaces for the example.
        public static int Start()
        {
            int result = 0;

            Program program = new Program();

            //
            // Retrieve singleton reference to system object
            //
            // *** NOTES ***
            // Everything originates with the system object. It is important to
            // notice that it has a singleton implementation, so it is impossible
            // to have multiple system objects at the same time.
            //
            // *** LATER ***
            // The system object should be cleared prior to program completion.
            // If not released explicitly, it will be released automatically
            // when all system objects go out of scope.
            //
            ManagedSystem system = new ManagedSystem();

            // Print out current library version
            LibraryVersion spinVersion = system.GetLibraryVersion();

            Console.WriteLine("Spinnaker library version: {0}.{1}.{2}.{3}\n\n",
                              spinVersion.major,
                              spinVersion.minor,
                              spinVersion.type,
                              spinVersion.build);

            //
            // Retrieve list of interfaces from the system
            //
            // *** NOTES ***
            // Interface lists are retrieved from the system object.
            //
            // *** LATER ***
            // Interface lists are constructed using list objects of
            // IManagedInterface objects. Lists are native to C# and must be
            // cleared after use.
            //
            List <IManagedInterface> interfaceList = system.GetInterfaces();

            Console.WriteLine("Number of interfaces detected: {0}\n", interfaceList.Count);

            //
            // Retrieve list of cameras from the system
            //
            // *** NOTES ***
            // Camera lists are retrieved from the system object.
            //
            // *** LATER ***
            // Camera lists are constructed using list objects of IManagedCamera
            // objects. Lists are native to C# and must be cleared after use.
            //
            List <IManagedCamera> camList = system.GetCameras();

            Console.WriteLine("Number of cameras detected: {0}\n", camList.Count);

            // Finish if there are no cameras
            if (camList.Count == 0 || interfaceList.Count == 0)
            {
                // Clear camera list before releasing system
                camList.Clear();

                // Clear interface list before releasing system
                interfaceList.Clear();

                // Release system
                system.Dispose();

                Console.WriteLine("Not enough cameras!");
                Console.WriteLine("Done! Press Enter to exit...");
                Console.ReadLine();

                return(-1);
            }

            Console.WriteLine("\n*** QUERYING INTERFACES ***\n");

            //
            // Run example on each interface
            //
            // *** NOTES ***
            // Managed interfaces will need to be disposed of after use in order
            // to fully clean up. Using-statements help ensure that this is taken
            // care of; otherwise, interfaces can be disposed of manually by calling
            // Dispose().
            //
            foreach (IManagedInterface managedInterface in interfaceList)
            {
                using (managedInterface) {
                    try {
                        // Run example
                        result = result | program.QueryInterface(managedInterface);
                    } catch (SpinnakerException ex) {
                        Console.WriteLine("Error: {0}", ex.Message);
                        result = -1;
                    }
                }
            }

            //
            // Clear camera list before releasing system
            //
            // *** NOTES ***
            // If a camera list is not cleaned up
            // manually, the system will do so when System.Dispose() is
            // called.
            //
            camList.Clear();

            //
            // Clear interface list before releasing system
            //
            // *** NOTES ***
            // If an interface list is not cleaned up
            // manually, the system will do so when System.Dispose() is
            // called.
            //
            interfaceList.Clear();

            //
            // Release system
            //
            // *** NOTES ***
            // The system should be released, but if it is not, it will do so
            // itself. It is often at the release of the system (whether manual
            // or automatic) that unbroken references and still registered
            // events will throw an exception.
            //
            system.Dispose();

            Console.WriteLine("\nDone!");
            //Console.ReadLine();

            return(result);
        }
Beispiel #22
0
        public Form1()
        {
            InitializeComponent();

            system = new ManagedSystem();

            // Print current Spinnaker library version info:
            LibraryVersion spinVersion = system.GetLibraryVersion();

            Console.WriteLine(
                "Spinnaker library version: {0}.{1}.{2}.{3}\n\n",
                spinVersion.major,
                spinVersion.minor,
                spinVersion.type,
                spinVersion.build);

            // Find all Flir cameras on the system:
            managedCameras = system.GetCameras();

            // Assert that exactly two cameras are found:
            int nCamsFound = managedCameras.Count;

            if (nCamsFound != nCameras)
            {
                Console.WriteLine("Need exactly two cameras, but {0} cameras were found. Disposing system.", nCamsFound.ToString());
                managedCameras.Clear();
                system.Dispose();
            }

            // Create or select folder to write video data:
            sessionPaths = Util.SetDataWritePaths(animalName: Util.AnimalName.Charlie);

            // Initialize OryxSetupInfo Object to pass to camera constructors upon initialization:
            oryxSetupInfos = new Util.OryxSetupInfo[nCameras];
            for (int i = 0; i < nCameras; i++)
            {
                oryxSetupInfos[i] = new Util.OryxSetupInfo();
            }

            bool areAllCamSettingsIdentical = true;

            if (areAllCamSettingsIdentical)
            {
                Console.WriteLine("\n\n");
                Console.WriteLine("Cameras have identical settings, shown here:");
                oryxSetupInfos[0].PrintSettingsToLoad();
                Console.WriteLine("\n\n");
            }

            StreamArchitecture architecture = StreamArchitecture.ThreeLevelBasic;

            threadManager = new ThreadManager(architecture: architecture, sessionPaths: sessionPaths,
                                              managedCameras: managedCameras, oryxSetups: oryxSetupInfos);

            xBoxController = new XBoxController(mainForm: this,
                                                messageQueues: threadManager.managerBundle.messageQueues, streamGraph: threadManager.streamGraph);

            displayTimer          = new System.Windows.Forms.Timer();
            displayTimer.Interval = 2;
            displayTimer.Tick    += DisplayTimerEventProcessor;
            displayTimer.Enabled  = true;

            displayQueue = threadManager.managerBundle.mergeStreamsManager.output.displayQueue;
            threadManager.StartThreads();
        }
Beispiel #23
0
 /// <summary>
 /// Construct a Preloader by specifying a required library version.
 /// </summary>
 /// <param name="rootFolder">Full path of the directory that contains 
 /// LibG_xxx folder, where 'xxx' represents the library version. In a 
 /// typical setup this would be the same directory that contains Dynamo 
 /// core modules. This must represent a valid directory.
 /// </param>
 /// <param name="version">The version of shape manager.</param>
 /// <returns></returns>
 public Preloader(string rootFolder, LibraryVersion version)
     : this(rootFolder, new[] { version }) { }
        // Example entry point; please see Enumeration_CSharp example for more
        // in-depth comments on preparing and cleaning up the system.
        public static int Start()
        {
            int result = 0;

            Program program = new Program();

            // Since this application saves images in the current folder
            // we must ensure that we have permission to write to this folder.
            // If we do not have permission, fail right away.
            FileStream fileStream;

            try {
                fileStream = new FileStream(@"test.txt", FileMode.Create);
                fileStream.Close();
                File.Delete("test.txt");
            } catch {
                Console.WriteLine("Failed to create file in current folder. Please check permissions.");
                Console.WriteLine("Press enter to exit...");
                Console.ReadLine();
                return(-1);
            }

            // Retrieve singleton reference to system object
            ManagedSystem system = new ManagedSystem();

            // Print out current library version
            LibraryVersion spinVersion = system.GetLibraryVersion();

            Console.WriteLine("Spinnaker library version: {0}.{1}.{2}.{3}\n\n",
                              spinVersion.major,
                              spinVersion.minor,
                              spinVersion.type,
                              spinVersion.build);

            // Retrieve list of cameras from the system
            IList <IManagedCamera> camList = system.GetCameras();

            Console.WriteLine("Number of cameras detected: {0}\n\n", camList.Count);

            // Finish if there are no cameras
            if (camList.Count == 0)
            {
                // Clear camera list before releasing system
                camList.Clear();

                // Release system
                system.Dispose();

                Console.WriteLine("Not enough cameras!");
                Console.WriteLine("Done! Press Enter to exit...");
                Console.ReadLine();

                return(-1);
            }

            //
            // Run example on each camera
            //
            // *** NOTES ***
            // Cameras can either be retrieved as their own IManagedCamera
            // objects or from camera lists using the [] operator and an index.
            //
            // Using-statements help ensure that cameras are disposed of when
            // they are no longer needed; otherwise, cameras can be disposed of
            // manually by calling Dispose(). In C#, if cameras are not disposed
            // of before the system is released, the system will do so
            // automatically.
            //
            int index = 0;

            foreach (IManagedCamera managedCamera in camList)
            {
                using (managedCamera) {
                    Console.WriteLine("Running example for camera {0}...", index);

                    try {
                        // Run example
                        result = result | program.RunSingleCamera(managedCamera);
                    } catch (SpinnakerException ex) {
                        Console.WriteLine("Error: {0}", ex.Message);
                        result = -1;
                    }

                    Console.WriteLine("Camera {0} example complete...\n", index++);
                }
            }

            // Clear camera list before releasing system
            camList.Clear();

            // Release system
            system.Dispose();

            Console.WriteLine("\nDone! Press Enter to exit...");
            Console.ReadLine();

            return(result);
        }
Beispiel #25
0
        /// <summary>
        /// Constructs a preloader object to help preload a specific version of 
        /// shape manager.
        /// </summary>
        /// <param name="rootFolder">Full path of the directory that contains 
        /// LibG_xxx folder, where 'xxx' represents the library version. In a 
        /// typical setup this would be the same directory that contains Dynamo 
        /// core modules. This must represent a valid directory.
        /// </param>
        /// <param name="versions">A list of version numbers to check for in order 
        /// of preference. This argument cannot be null or empty.</param>
        /// 
        public Preloader(string rootFolder, IEnumerable<LibraryVersion> versions)
        {
            if (string.IsNullOrEmpty(rootFolder))
                throw new ArgumentNullException("rootFolder");
            if (!Directory.Exists(rootFolder))
                throw new DirectoryNotFoundException(rootFolder);
            if ((versions == null) || !versions.Any())
                throw new ArgumentNullException("versions");

            var versionList = versions.ToList();

            shapeManagerPath = string.Empty; // Folder that contains ASM binaries.
            version = Utilities.GetInstalledAsmVersion(versionList, ref shapeManagerPath, rootFolder);
            
            var libGFolderName = string.Format("libg_{0}", ((int) version));
            preloaderLocation = Path.Combine(rootFolder, libGFolderName);
            geometryFactoryPath = Path.Combine(preloaderLocation,
                Utilities.GeometryFactoryAssembly);
        }
Beispiel #26
0
        public MainWindow()
        {
            InitializeComponent();


            time.Tick    += new EventHandler(Time_Tick);
            time.Interval = 10;

            exposureControl.sliderName.Content  = "曝光时间";
            exposureControl.sliderCheck.Content = "手动曝光";

            frameRateControl.sliderName.Content  = "帧率";
            frameRateControl.sliderCheck.Content = "手动帧率";

            blackLevelControl.sliderName.Content  = "灰度偏移";
            blackLevelControl.sliderCheck.Content = "手动偏移";

            GainControl.sliderName.Content  = "增益";
            GainControl.sliderCheck.Content = "手动增益";

            acceptPointValue.sliderName.Content  = "接受阈值";
            acceptPointValue.sliderCheck.Content = "手动";

            if (SavePath == null)
            {
                SavePath = "./";
            }
            FileStream fileStream;

            try
            {
                fileStream = new FileStream(SavePath + "test.txt", FileMode.Create);
                fileStream.Close();
                File.Delete("test.txt");
            }
            catch
            {
                Console.WriteLine("权限不足");
                return;
            }

            // 单例
            system = new ManagedSystem();

            // 输出当前库版本
            LibraryVersion spinVersion = system.GetLibraryVersion();

            Console.WriteLine("Spinnaker library version: {0}.{1}.{2}.{3}\n\n",
                              spinVersion.major,
                              spinVersion.minor,
                              spinVersion.type,
                              spinVersion.build);
            //输出相机参数-0
            camList = system.GetCameras();
            if (camList.Count == 0)
            {
                camList.Clear();
                system.Dispose();
                Console.WriteLine("无相机!");
                return;
            }
            cam = camList[0];
            INodeMap nodeMapTLDevice = cam.GetTLDeviceNodeMap();

            PrintDeviceInfo(nodeMapTLDevice);

            // 为文件名检索设备序列号
            // *** NOTES ***
            // 设备序列号可以放置其他设备覆盖本设备图像
            // 图像ID和帧ID
            //
            deviceSerialNumber = "";
            while (true)
            {
                try
                {
                    cam.Init();
                    break;
                }
                catch (SpinnakerException e)
                {
                    Console.WriteLine("init error");
                    Thread.Sleep(1000);
                }
            }
            while (cam.DeviceIndicatorMode.Value != DeviceIndicatorModeEnums.Active.ToString())
            {
                Thread.Sleep(1000);
            }


            //相机参数初始化
            cam.ExposureAuto.Value = ExposureAutoEnums.Continuous.ToString();
            cam.AcquisitionFrameRateEnable.Value = true;
            frameRateManualDisable();
            //cam.BlackLevelAuto.Value = BlackLevelAutoEnums.Continuous.ToString();
            cam.GainAuto.Value = GainAutoEnums.Continuous.ToString();

            Console.WriteLine("设备序列号为: {0}", cam.DeviceSerialNumber.Value);
            Console.WriteLine("曝光时间设置为 {0} us", cam.ExposureTime.Value);
            cam.DeviceLinkThroughputLimit.Value = cam.DeviceLinkThroughputLimit.Max;
            Console.WriteLine("当前带宽:{0}", cam.DeviceLinkThroughputLimit.Value);
            Console.WriteLine("当前帧率:{0} Hz", cam.AcquisitionFrameRate.Value);
#if DEBUG
            // 判断是否禁用了心跳检测
            if (DisableHeartbeat() != 0)
            {
                Console.WriteLine("心跳检测未禁用");
                System.Windows.Application.Current.Shutdown();
            }
#endif



            //调用刷新控件
            flushControl();

            //接受点阈值
            acceptPointValue.slider.Maximum = 255;
            acceptPointValue.slider.Minimum = 0;
            acceptPointValue.slider.Value   = 60;
            //控件委托
            #region
            exposureControl.setSliderEvent  += () => { cam.ExposureTime.Value = exposureControl.slider.Value; };
            exposureControl.setCheckedEvent += () => { cam.ExposureAuto.Value = ExposureAutoEnums.Off.ToString(); };
            exposureControl.setUnCheckEvent += () => { cam.ExposureAuto.Value = ExposureAutoEnums.Continuous.ToString(); };

            frameRateControl.setSliderEvent  += () => { cam.AcquisitionFrameRate.Value = frameRateControl.slider.Value; };
            frameRateControl.setCheckedEvent += frameRateManualEnable;
            frameRateControl.setUnCheckEvent += frameRateManualDisable;

            //blackLevelControl.setSliderEvent += () => { cam.BlackLevelAuto.Value = BlackLevelAutoEnums.Off.ToString(); };
            blackLevelControl.slider.IsEnabled = false;

            GainControl.setSliderEvent  += () => { cam.Gain.Value = GainControl.slider.Value; };
            GainControl.setCheckedEvent += () => { cam.GainAuto.Value = GainAutoEnums.Off.ToString(); };
            GainControl.setUnCheckEvent += () => { cam.GainAuto.Value = GainAutoEnums.Continuous.ToString(); };
            #endregion
            acceptPointValue.sliderCheck.IsChecked = true;
        }