MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MyCaffeStreamDatabase.cs
1using MyCaffe.basecode;
2using System;
3using System.Collections.Generic;
5using System.Diagnostics;
6using System.IO;
7using System.Linq;
8using System.Text;
9using System.Threading.Tasks;
10
14namespace MyCaffe.db.stream
15{
20 {
21 Log m_log;
22 IXQuery m_iquery;
23 List<IXCustomQuery> m_rgCustomQueryToAdd = new List<IXCustomQuery>();
24
30 {
31 m_log = log;
32 InitializeComponent();
33 }
34
39 public MyCaffeStreamDatabase(IContainer container)
40 {
41 container.Add(this);
42
43 InitializeComponent();
44 }
45
46 private void dispose()
47 {
48 m_iquery.Shutdown();
49 }
50
83 public void Initialize(QUERY_TYPE qt, string strSchema)
84 {
85 if (qt == QUERY_TYPE.SYNCHRONIZED)
86 {
87 PropertySet ps = new PropertySet(strSchema);
88 int nQueryCount = ps.GetPropertyAsInt("QueryCount", 0);
89 DateTime dtStart = ps.GetPropertyAsDateTime("Start");
90 int nTimeSpanInMs = ps.GetPropertyAsInt("TimeSpanInMs");
91 int nSegmentSize = ps.GetPropertyAsInt("SegmentSize");
92 int nMaxCount = ps.GetPropertyAsInt("MaxCount");
93
94 m_iquery = new MgrQueryTime(nQueryCount, dtStart, nTimeSpanInMs, nSegmentSize, nMaxCount, strSchema, m_rgCustomQueryToAdd);
95 }
96 else
97 {
98 m_iquery = new MgrQueryGeneral(strSchema, m_rgCustomQueryToAdd);
99 }
100 }
101
105 public void Shutdown()
106 {
107 m_iquery.Shutdown();
108 }
109
122 {
123 m_rgCustomQueryToAdd.Add(iqry);
124 }
125
131 public SimpleDatum Query(int nWait)
132 {
133 return m_iquery.Query(nWait);
134 }
135
143 public int[] QuerySize()
144 {
145 List<int> rg = m_iquery.GetQuerySize();
146
147 if (rg == null)
148 return null;
149
150 return rg.ToArray();
151 }
152
157 public Dictionary<string, float> QueryInfo()
158 {
159 return m_iquery.QueryInfo();
160 }
161
166 public void Reset(int nStartOffset = 0)
167 {
168 m_iquery.Reset(nStartOffset);
169 }
170
177 public byte[] ConvertOutput(float[] rg, out string type)
178 {
179 return m_iquery.ConvertOutput(rg, out type);
180 }
181 }
182}
The Log class provides general output in text form.
Definition: Log.cs:13
Specifies a key-value pair of properties.
Definition: PropertySet.cs:16
DateTime GetPropertyAsDateTime(string strName)
Returns a property as a DateTime value.
Definition: PropertySet.cs:250
int GetPropertyAsInt(string strName, int nDefault=0)
Returns a property as an integer value.
Definition: PropertySet.cs:287
The SimpleDatum class holds a data input within host memory.
Definition: SimpleDatum.cs:161
The MgrQueryTime class manages the collection of data queries, and the internal data queue that conta...
The MgrQueryTime class manages the collection of data queries, and the internal data queue that conta...
Definition: MgrQueryTime.cs:19
The MyCaffeStreamDatabase provides a streaming data input source to MyCaffe gyms used as input for dy...
void AddDirectQuery(IXCustomQuery iqry)
Add a custom query directly to the streaming database.
void Reset(int nStartOffset=0)
Reset the query to the start date used in Initialize, optionally with an offset from the start.
MyCaffeStreamDatabase(IContainer container)
The constructor.
Dictionary< string, float > QueryInfo()
The Query information returns information about the data queried such as header information.
void Shutdown()
Shutdonw the streaming database.
int[] QuerySize()
Returns the query size of the data in the form: [0] = channels [1] = height [2] = width.
void Initialize(QUERY_TYPE qt, string strSchema)
The Initialize method initializes the streaming database component, preparing it for data queries.
SimpleDatum Query(int nWait)
Query the next data in the streaming database.
byte[] ConvertOutput(float[] rg, out string type)
Converts the output values into the native type used by the first CustomQuery.
The Component class is a standard Microsoft.NET class that implements the IComponent interface and is...
Definition: Component.cs:18
The custom query interface defines the functions implemented by each Custom Query object used to spec...
Definition: Interfaces.cs:168
The IXStreamDatabase interface is the main interface to the MyCaffe Streaing Database.
Definition: Interfaces.cs:52
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.db.stream namespace contains all data streaming related classes.
QUERY_TYPE
Defines the query type to use.
Definition: Interfaces.cs:36
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12