/// <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); }
/// <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(); }