2using System.Collections.Generic;
3using System.Collections.ObjectModel;
7using System.Runtime.InteropServices.WindowsRuntime;
8using System.Security.Policy;
10using System.Threading.Tasks;
19 [TypeConverter(typeof(ExpandableObjectConverter))]
22 List<ValueStreamDescriptor> m_rgValStrmDesc =
new List<ValueStreamDescriptor>();
23 List<ValueItemDescriptor> m_rgValItemDesc =
new List<ValueItemDescriptor>();
55 get {
return m_rgValStrmDesc; }
56 set { m_rgValStrmDesc = value; }
74 get {
return m_rgValItemDesc; }
75 set { m_rgValItemDesc = value; }
83 get {
return m_rgValItemDesc.AsReadOnly(); }
97 nTotal = Math.Max(nTotal, vsd.
Steps);
111 DateTime dt = m_rgValStrmDesc.Min(p => p.Start.GetValueOrDefault(DateTime.MaxValue));
112 if (dt == DateTime.MaxValue)
126 DateTime dt = m_rgValStrmDesc.Max(p => p.End.GetValueOrDefault(DateTime.MinValue));
127 if (dt == DateTime.MinValue)
146 using (MemoryStream ms =
new MemoryStream(rgb))
147 using (BinaryReader br =
new BinaryReader(ms))
149 int nCount = br.ReadInt32();
150 for (
int i = 0; i < nCount; i++)
155 nCount = br.ReadInt32();
156 for (
int i = 0; i < nCount; i++)
171 using (MemoryStream ms =
new MemoryStream())
172 using (BinaryWriter bw =
new BinaryWriter(ms))
174 bw.Write(m_rgValStrmDesc.Count);
180 bw.Write(m_rgValItemDesc.Count);
196 Dictionary<STREAM_CLASS_TYPE, Dictionary<STREAM_VALUE_TYPE, List<ValueStreamDescriptor>>> m_rgOrdered =
new Dictionary<STREAM_CLASS_TYPE, Dictionary<STREAM_VALUE_TYPE, List<ValueStreamDescriptor>>>();
206 if (!m_rgOrdered.ContainsKey(vsd.
ClassType))
207 m_rgOrdered.Add(vsd.
ClassType,
new Dictionary<STREAM_VALUE_TYPE, List<ValueStreamDescriptor>>());
222 public List<ValueStreamDescriptor>
GetStreamDescriptors(STREAM_CLASS_TYPE classType, STREAM_VALUE_TYPE valueType)
224 if (!m_rgOrdered.ContainsKey(classType))
227 if (!m_rgOrdered[classType].ContainsKey(valueType))
230 return m_rgOrdered[classType][valueType];
238 [TypeConverter(typeof(ExpandableObjectConverter))]
271 m_strName = vid.m_strName;
272 m_dtStart = vid.m_dtStart;
273 m_dtEnd = vid.m_dtEnd;
274 m_nSteps = vid.m_nSteps;
284 int nID = br.ReadInt32();
285 string strName = br.ReadString();
286 DateTime? dtStart =
null;
287 DateTime? dtEnd =
null;
290 if (br.ReadBoolean())
292 dtStart =
new DateTime(br.ReadInt64());
293 dtEnd =
new DateTime(br.ReadInt64());
294 nSteps = br.ReadInt32();
311 if (m_dtStart.HasValue && m_dtEnd.HasValue && m_nSteps.HasValue)
314 bw.Write(m_dtStart.Value.Ticks);
315 bw.Write(m_dtEnd.Value.Ticks);
316 bw.Write(m_nSteps.Value);
330 get {
return m_nID; }
339 get {
return m_strName; }
348 get {
return m_dtStart; }
357 get {
return m_dtEnd; }
366 get {
return m_nSteps; }
383 [TypeConverter(typeof(ExpandableObjectConverter))]
391 DateTime? m_dtStart =
null;
392 DateTime? m_dtEnd =
null;
393 int? m_nSecondsPerStep =
null;
446 m_nOrdering = nOrdering;
447 m_classType = classType;
448 m_valueType = valueType;
451 m_nSecondsPerStep = nSecPerStep;
462 m_strName = vsd.m_strName;
463 m_nOrdering = vsd.m_nOrdering;
464 m_classType = vsd.m_classType;
465 m_valueType = vsd.m_valueType;
466 m_dtStart = vsd.m_dtStart;
467 m_dtEnd = vsd.m_dtEnd;
468 m_nSecondsPerStep = vsd.m_nSecondsPerStep;
469 m_nSteps = vsd.m_nSteps;
479 int nID = br.ReadInt32();
480 string strName = br.ReadString();
481 int nOrdering = br.ReadInt32();
484 DateTime? dtStart =
null;
485 DateTime? dtEnd =
null;
486 int? nSecondsPerStep =
null;
488 bool bHasStart = br.ReadBoolean();
490 dtStart =
new DateTime(br.ReadInt64());
492 bool bHasEnd = br.ReadBoolean();
494 dtEnd =
new DateTime(br.ReadInt64());
496 bool bHasSecondsPerStep = br.ReadBoolean();
497 if (bHasSecondsPerStep)
498 nSecondsPerStep = br.ReadInt32();
500 int nSteps = br.ReadInt32();
502 return new ValueStreamDescriptor(nID, strName, nOrdering, classType, valueType, dtStart, dtEnd, nSecondsPerStep, nSteps);
513 bw.Write(m_nOrdering);
514 bw.Write((
int)m_classType);
515 bw.Write((
int)m_valueType);
517 bw.Write(m_dtStart.HasValue);
518 if (m_dtStart.HasValue)
519 bw.Write(m_dtStart.Value.Ticks);
521 bw.Write(m_dtEnd.HasValue);
522 if (m_dtEnd.HasValue)
523 bw.Write(m_dtEnd.Value.Ticks);
525 bw.Write(m_nSecondsPerStep.HasValue);
526 if (m_nSecondsPerStep.HasValue)
527 bw.Write(m_nSecondsPerStep.Value);
538 get {
return m_nID; }
547 get {
return m_strName; }
556 get {
return m_nOrdering; }
565 get {
return m_classType; }
574 get {
return m_valueType; }
583 get {
return m_dtStart; }
592 get {
return m_dtEnd; }
601 get {
return m_nSecondsPerStep; }
610 get {
return m_nSteps; }
619 string strOut = m_nOrdering.ToString() +
". " + m_strName +
" (" + m_classType.ToString() +
", " + m_valueType.ToString() +
")";
621 if (m_dtStart.HasValue)
622 strOut +=
" start = " + m_dtStart.ToString();
624 if (m_dtEnd.HasValue)
625 strOut +=
" end = " + m_dtEnd.ToString();
627 if (m_nSecondsPerStep.HasValue)
628 strOut +=
" seconds_per_step = " + m_nSecondsPerStep.ToString();
The ordered value stream descriptor set is used to order the value stream descriptors by class and va...
OrderedValueStreamDescriptorSet(List< ValueStreamDescriptor > rg)
The constructor.
List< ValueStreamDescriptor > GetStreamDescriptors(STREAM_CLASS_TYPE classType, STREAM_VALUE_TYPE valueType)
Retrieves the set of stream descriptors with the given class and value type.
The TemporalDescriptor is used to describe a temporal aspects of the data source.
DateTime? EndDate
Return the end date.
OrderedValueStreamDescriptorSet OrderedValueStreamDescriptors
Retunrs the ordered set of stream descriptors.
byte[] ToBytes()
Returns the temporal descriptor as a byte array.
DateTime? StartDate
Return the start date.
int TotalSteps
Returns the total number of temporal steps.
TemporalDescriptor()
The constructor.
ReadOnlyCollection< ValueItemDescriptor > ValueItemDescriptorItems
Returns the value item descriptors as a read-only array.
static TemporalDescriptor FromBytes(byte[] rgb)
Returns a new TemporalDescriptor from a byte array.
List< ValueItemDescriptor > ValueItemDescriptors
Returns the value item descriptor.
TemporalDescriptor(TemporalDescriptor td)
The constructor.
List< ValueStreamDescriptor > ValueStreamDescriptors
Returns the value stream descriptor.
The ValueItemDescriptor describes each value item (e.g., customer, station or stock)
void ToBytes(BinaryWriter bw)
Returns the value item descriptor as a byte array.
ValueItemDescriptor(ValueItemDescriptor vid)
The copy constructor.
int ID
Returns the value item ID.
DateTime? Start
Returns the start time (if any).
ValueItemDescriptor(int nID, string strName, DateTime? dtStart, DateTime? dtEnd, int? nSteps)
The constructor.
int? Steps
Returns the steps (if any).
DateTime? End
Returns the end time (if any).
static ValueItemDescriptor FromBytes(BinaryReader br)
Returns a new ValueItemDescriptor from a binary reader.
string Name
Returns the value item name.
override string ToString()
Returns a string representation of the value item descriptor.
The value stream descriptor describes a single value stream within a value item.
STREAM_CLASS_TYPE ClassType
Returns the value stream class type.
int? SecondsPerStep
Returns the value stream seconds per step (null with STATIC class).
void ToBytes(BinaryWriter bw)
Returns the value stream descriptor as a byte array.
override string ToString()
Returns the string rendering of the value stream descriptor.
int Ordering
Returns the value stream ordering.
int Steps
Returns the number of items in the value stream.
DateTime? End
Returns the value stream end time (null with STATIC class).
static ValueStreamDescriptor FromBytes(BinaryReader br)
Returns a new ValueStreamDescriptor from a byte array.
int ID
Returns the value stream ID.
STREAM_VALUE_TYPE ValueType
Returns the value stream value type.
ValueStreamDescriptor(int nID, string strName, int nOrdering, STREAM_CLASS_TYPE classType, STREAM_VALUE_TYPE valueType, DateTime? dtStart=null, DateTime? dtEnd=null, int? nSecPerStep=null, int nSteps=1)
The constructor.
ValueStreamDescriptor(ValueStreamDescriptor vsd)
The constructor.
DateTime? Start
Returns the value stream start time (null with STATIC class).
STREAM_CLASS_TYPE
Defines the stream class type.
STREAM_VALUE_TYPE
Defines the stream value type.
string Name
Return the value stream name.
The descriptors namespace contains all descriptor used to describe various items stored within the da...
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...