Esempio n. 1
0
        private void addCustomQueries()
        {
            string     codeBase = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder uri      = new UriBuilder(codeBase);
            string     path     = Uri.UnescapeDataString(uri.Path);
            string     strPath  = Path.GetDirectoryName(path);

            strPath += "\\CustomQuery";

            if (Directory.Exists(strPath))
            {
                string[] rgstrFiles = Directory.GetFiles(strPath);

                foreach (string strFile in rgstrFiles)
                {
                    FileInfo fi = new FileInfo(strFile);

                    if (fi.Extension.ToLower() == ".dll")
                    {
                        IXCustomQuery iqry = loadCustomQuery(strFile);
                        if (iqry != null)
                        {
                            m_rgCustomQueries.Add(iqry);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// The constructor.
 /// </summary>
 /// <param name="iquery">Specifies the custom query managed.</param>
 /// <param name="dtStart">Specifies the start date for queries.</param>
 /// <param name="tsInc">Specifies the time increment between data items within a query.</param>
 /// <param name="nSegmentSize">Specifies the number of items to collect on each query.</param>
 /// <param name="nMaxCount">Specifies the maximum number of items to store in memory.</param>
 public DataQuery(IXCustomQuery iquery, DateTime dtStart, TimeSpan tsInc, int nSegmentSize, int nMaxCount)
 {
     m_nSegmentSize = nSegmentSize;
     m_nMaxCount    = nMaxCount;
     m_dtStart      = dtStart;
     m_dt           = dtStart;
     m_tsInc        = tsInc;
     m_iquery       = iquery;
     m_queryTask    = Task.Factory.StartNew(new Action(queryThread));
 }
Esempio n. 3
0
        /// <summary>
        /// The constructor.
        /// </summary>
        /// <param name="nQueryCount">Specifies the size of each query.</param>
        /// <param name="dtStart">Specifies the state date used for data collection.</param>
        /// <param name="nTimeSpanInMs">Specifies the time increment used between each data item.</param>
        /// <param name="nSegmentSize">Specifies the amount of data to query on the back-end from each custom query.</param>
        /// <param name="nMaxCount">Specifies the maximum number of items to allow in memory.</param>
        /// <param name="strSchema">Specifies the database schema.</param>
        /// <param name="rgCustomQueries">Optionally, specifies any custom queries to add directly.</param>
        /// <remarks>
        /// The database schema defines the number of custom queries to use along with their names.  A simple key=value; list
        /// defines the streaming database schema using the following format:
        /// \code{.cpp}
        ///  "ConnectionCount=2;
        ///   Connection0_CustomQueryName=Test1;
        ///   Connection0_CustomQueryParam=param_string1
        ///   Connection1_CustomQueryName=Test2;
        ///   Connection1_CustomQueryParam=param_string2"
        /// \endcode
        /// Each param_string specifies the parameters of the custom query and may include the database connection string, database
        /// table, and database fields to query.
        /// </remarks>
        public MgrQueryTime(int nQueryCount, DateTime dtStart, int nTimeSpanInMs, int nSegmentSize, int nMaxCount, string strSchema, List <IXCustomQuery> rgCustomQueries)
        {
            m_colCustomQuery.Load();
            m_colData      = new DataItemCollection(nQueryCount);
            m_nQueryCount  = nQueryCount;
            m_nSegmentSize = nSegmentSize;

            m_schema = new PropertySet(strSchema);

            foreach (IXCustomQuery icustomquery in rgCustomQueries)
            {
                m_colCustomQuery.Add(icustomquery);
            }

            int nConnections = m_schema.GetPropertyAsInt("ConnectionCount");

            for (int i = 0; i < nConnections; i++)
            {
                string strConTag           = "Connection" + i.ToString();
                string strCustomQuery      = m_schema.GetProperty(strConTag + "_CustomQueryName");
                string strCustomQueryParam = m_schema.GetProperty(strConTag + "_CustomQueryParam");

                IXCustomQuery iqry = m_colCustomQuery.Find(strCustomQuery);
                if (iqry == null)
                {
                    throw new Exception("Could not find the custom query '" + strCustomQuery + "'!");
                }

                if (iqry.QueryType != CUSTOM_QUERY_TYPE.TIME)
                {
                    throw new Exception("The custom query '" + iqry.Name + "' does not support the 'CUSTOM_QUERY_TYPE.TIME'!");
                }

                DataQuery dq = new DataQuery(iqry.Clone(strCustomQueryParam), dtStart, TimeSpan.FromMilliseconds(nTimeSpanInMs), nSegmentSize, nMaxCount);
                m_colDataQuery.Add(dq);

                m_nFieldCount += (dq.FieldCount - 1);  // subtract each sync field.
            }

            m_nFieldCount += 1; // add the sync field
            m_colDataQuery.Start();

            m_evtCancel.Reset();
            m_taskConsolidate = Task.Factory.StartNew(new Action(consolidateThread));
            m_evtEnabled.Set();
            m_colData.WaitData(10000);
        }
Esempio n. 4
0
        /// <summary>
        /// The constructor.
        /// </summary>
        /// <param name="strSchema">Specifies the database schema.</param>
        /// <param name="rgCustomQueries">Optionally, specifies any custom queries to diretly add.</param>
        /// <remarks>
        /// The database schema defines the number of custom queries to use along with their names.  A simple key=value; list
        /// defines the streaming database schema using the following format:
        /// \code{.cpp}
        ///  "ConnectionCount=1;
        ///   Connection0_CustomQueryName=Test1;
        ///   Connection0_CustomQueryParam=param_string1
        /// \endcode
        /// Each param_string specifies the parameters of the custom query and may include the database connection string, database
        /// table, and database fields to query.
        /// </remarks>
        public MgrQueryGeneral(string strSchema, List <IXCustomQuery> rgCustomQueries)
        {
            m_colCustomQuery.Load();
            m_schema = new PropertySet(strSchema);

            m_colCustomQuery.Add(new StandardQueryTextFile());
            m_colCustomQuery.Add(new StandardQueryWAVFile());

            foreach (IXCustomQuery icustomquery in rgCustomQueries)
            {
                m_colCustomQuery.Add(icustomquery);
            }

            int nConnections = m_schema.GetPropertyAsInt("ConnectionCount");

            if (nConnections != 1)
            {
                throw new Exception("Currently, the general query type only supports 1 connection.");
            }

            string strConTag           = "Connection0";
            string strCustomQuery      = m_schema.GetProperty(strConTag + "_CustomQueryName");
            string strCustomQueryParam = m_schema.GetProperty(strConTag + "_CustomQueryParam");

            IXCustomQuery iqry = m_colCustomQuery.Find(strCustomQuery);

            if (iqry == null)
            {
                throw new Exception("Could not find the custom query '" + strCustomQuery + "'!");
            }

            if (iqry.QueryType != CUSTOM_QUERY_TYPE.BYTE && iqry.QueryType != CUSTOM_QUERY_TYPE.REAL_FLOAT && iqry.QueryType != CUSTOM_QUERY_TYPE.REAL_DOUBLE)
            {
                throw new Exception("The custom query '" + iqry.Name + "' must support the 'CUSTOM_QUERY_TYPE.BYTE' or 'CUSTOM_QUERY_TYPE.REAL_FLOAT' or 'CUSTOM_QUERY_TYPE.REAL_DOUBLE' query type!");
            }

            string strParam = ParamPacker.UnPack(strCustomQueryParam);

            m_iquery = iqry.Clone(strParam);
            m_iquery.Open();
        }
Esempio n. 5
0
 /// <summary>
 /// Directly adds a custom query to the list.
 /// </summary>
 /// <param name="iqry">Specifies the custom query interface.</param>
 public void Add(IXCustomQuery iqry)
 {
     m_rgCustomQueries.Add(iqry);
 }
Esempio n. 6
0
 /// <summary>
 /// Add a custom query directly to the streaming database.
 /// </summary>
 /// <remarks>
 /// By default, the streaming database looks in the \code{.cpp}'./CustomQuery'\endcode folder relative
 /// to the streaming database assembly to look for CustomQuery DLL's that implement
 /// the IXCustomQuery interface.  When found, these assemblies are added to the list
 /// accessible via the schema.  Alternatively, custom queries may be added directly
 /// using this method.
 /// </remarks>
 /// <param name="iqry">Specifies the custom query to add.</param>
 public void AddDirectQuery(IXCustomQuery iqry)
 {
     m_colCustomQuery.Add(iqry);
 }
Esempio n. 7
0
        /// The Query information returns information about the data queried such as header information.
        /// </summary>
        /// <returns>The information about the data is returned.</returns>
        public Dictionary <string, float> QueryInfo()
        {
            IXCustomQuery iqry = m_colCustomQuery.Find("Info");

            return(iqry.QueryInfo());
        }
Esempio n. 8
0
        /// <summary>
        /// Converts the output values into the native type used by the CustomQuery.
        /// </summary>
        /// <param name="rg">Specifies the raw output data.</param>
        /// <param name="type">Returns the output type.</param>
        /// <returns>The converted output data is returned as a byte stream.</returns>
        public byte[] ConvertOutput(float[] rg, out string type)
        {
            IXCustomQuery iqry = m_colCustomQuery.Find("OutputConverter");

            return(iqry.ConvertOutput(rg, out type));
        }
Esempio n. 9
0
 /// <summary>
 /// Add a custom query directly to the streaming database.
 /// </summary>
 /// <remarks>
 /// By default, the streaming database looks in the \code{.cpp}'./CustomQuery'\endcode folder relative
 /// to the streaming database assembly to look for CustomQuery DLL's that implement
 /// the IXCustomQuery interface.  When found, these assemblies are added to the list
 /// accessible via the schema.  Alternatively, custom queries may be added directly
 /// using this method.
 /// </remarks>
 /// <param name="iqry">Specifies the custom query to add.</param>
 public void AddDirectQuery(IXCustomQuery iqry)
 {
     m_rgCustomQueryToAdd.Add(iqry);
 }