MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
Interfaces.cs
1using MyCaffe.basecode;
2using System;
3using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using System.Runtime.Serialization;
7using System.ServiceModel;
8using System.Text;
9using System.Threading.Tasks;
10
14namespace MyCaffe.db.stream
15{
16#pragma warning disable 1591
17
18 [ServiceContract]
19 public interface IXStreamDatabaseEvent
20 {
21 [OperationContract(IsOneWay = false)]
22 void OnResult(string strMsg, double dfProgress);
23
24 [OperationContract(IsOneWay = false)]
25 void OnError(StreamDatabaseErrorData err);
26 }
27
28#pragma warning restore 1591
29
33 [Serializable]
34 [DataContract]
35 public enum QUERY_TYPE
36 {
40 GENERAL,
45 }
46
50 [ServiceContract(CallbackContract = typeof(IXStreamDatabaseEvent), SessionMode = SessionMode.Required)]
51 public interface IXStreamDatabase
52 {
73 [OperationContract(IsOneWay = false)]
74 void Initialize(QUERY_TYPE qt, string strSchema);
75
79 [OperationContract(IsOneWay = false)]
80 void Shutdown();
81
86 [OperationContract(IsOneWay = false)]
87 void Reset(int nStartOffset = 0);
88
94 [OperationContract(IsOneWay = false)]
95 SimpleDatum Query(int nWait = 1000);
96
101 [OperationContract(IsOneWay = false)]
102 int[] QuerySize();
103
108 [OperationContract(IsOneWay = false)]
109 Dictionary<string, float> QueryInfo();
110 }
111
112#pragma warning disable 1591
113
117 public interface IXQuery
118 {
119 void AddDirectQuery(IXCustomQuery iqry);
120 void Reset(int nStartOffset);
121 void Shutdown();
122 List<int> GetQuerySize();
123 SimpleDatum Query(int nWait);
124 byte[] ConvertOutput(float[] rg, out string type);
125 Dictionary<string, float> QueryInfo();
126 }
127
128#pragma warning restore 1591
129
134 {
138 BYTE,
150 TIME
151 }
152
153
167 public interface IXCustomQuery
168 {
176 string Name { get; }
180 int FieldCount { get; }
184 void Open();
188 void Close();
193 List<int> GetQuerySize();
202 double[] QueryByTime(DateTime dt, TimeSpan ts, int nCount);
207 byte[] QueryBytes();
212 List<double[]> QueryRealD();
217 List<float[]> QueryRealF();
222 Dictionary<string, float> QueryInfo();
228 IXCustomQuery Clone(string strParam);
232 void Reset();
239 byte[] ConvertOutput(float[] rg, out string strType);
240 }
241
245 public class ParamPacker
246 {
252 public static string Pack(string str)
253 {
254 str = Utility.Replace(str, ';', '|');
255 return Utility.Replace(str, '=', '~');
256 }
257
263 public static string UnPack(string str)
264 {
265 str = Utility.Replace(str, '|', ';');
266 return Utility.Replace(str, '~', '=');
267 }
268 }
269
270#pragma warning disable 1591
271
272 [DataContract]
273 public class StreamDatabaseErrorData
274 {
275 [DataMember]
276 public bool Result { get; set; }
277 [DataMember]
278 public string ErrorMessage { get; set; }
279 [DataMember]
280 public string ErrorDetails { get; set; }
281 }
282
283#pragma warning restore 1591
284}
The Result class contains a single result.
Definition: Result.cs:14
The SimpleDatum class holds a data input within host memory.
Definition: SimpleDatum.cs:161
The Utility class provides general utility funtions.
Definition: Utility.cs:35
static string Replace(string str, char ch1, char ch2)
Replaces each instance of one character with another character in a given string.
Definition: Utility.cs:864
The ParamPacker is use to pack and unpack parameters sent to each custom query.
Definition: Interfaces.cs:246
static string Pack(string str)
Pack the custom query parameters.
Definition: Interfaces.cs:252
static string UnPack(string str)
Unpack the custom query parameters.
Definition: Interfaces.cs:263
The custom query interface defines the functions implemented by each Custom Query object used to spec...
Definition: Interfaces.cs:168
CUSTOM_QUERY_TYPE QueryType
Returns the custom query type supported by the custom query.
Definition: Interfaces.cs:172
int FieldCount
Returns the field count for this query.
Definition: Interfaces.cs:180
void Open()
Open a connection to the underlying database using the connection string specified.
IXCustomQuery Clone(string strParam)
Return a new instance of the custom query.
string Name
Returns the name of the Custom Query.
Definition: Interfaces.cs:176
List< float[]> QueryRealF()
Query the data as a set one or more float arrays.
byte[] QueryBytes()
Query the raw bytes.
List< double[]> QueryRealD()
Query the data as a set one or more double arrays.
Dictionary< string, float > QueryInfo()
The Query information returns information about the data queried such as header information.
byte[] ConvertOutput(float[] rg, out string strType)
Converts the output values into the native type used by the CustomQuery.
double[] QueryByTime(DateTime dt, TimeSpan ts, int nCount)
Query the fields specified (in the Open function) starting from the date-time specified.
void Reset()
Reset the custom query.
List< int > GetQuerySize()
Returns the query count for the current query.
void Close()
Close a currently open connection.
The IXStreamDatabase interface is the main interface to the MyCaffe Streaing Database.
Definition: Interfaces.cs:52
Dictionary< string, float > QueryInfo()
The Query information returns information about the data queried such as header information.
int[] QuerySize()
Returns the Query size using the Blob sizing methodology.
void Shutdown()
Shutdown the database.
void Reset(int nStartOffset=0)
Reset the query postion to the start established during Initialize.
void Initialize(QUERY_TYPE qt, string strSchema)
Initialize the streaming database by loading the initial queues.
SimpleDatum Query(int nWait=1000)
Query a setgment of data from the internal queueus.
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.
CUSTOM_QUERY_TYPE
Defines the custom query type to use.
Definition: Interfaces.cs:134
@ TIME
Each custom query supporting the TIME query, must implement the QueryByTime funtion.
@ REAL_FLOAT
Each custom query supporting the REAL query, where the base type is float, must implement the QueryRe...
@ BYTE
Each custom query supporting the BYTE query, must implement the QueryByte function.
@ REAL_DOUBLE
Each custom query supporting the REAL query, where the base type is double, must implement the QueryR...
QUERY_TYPE
Defines the query type to use.
Definition: Interfaces.cs:36
@ SYNCHRONIZED
Specifies to use a synchronized query.
@ GENERAL
Specifies to use a general query.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12