123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System.IO;
- namespace fis.Vid
- {
- public enum VinnoProbeType
- {
- Undefined,
- Linear,
- Convex,
- Sector,
- };
- public class VinnoProbe
- {
- public string Name { get; }
- public VinnoProbeType Type { get; }
- public VinnoApplication Application { get; }
- public double FrameRate { get; }
- public VinnoProbe(string name,VinnoProbeType type, VinnoApplication application, double frameRate)
- {
- Name = name;
- Type = type;
- Application = application;
- FrameRate = frameRate;
- }
- public byte[] ToBytes()
- {
- byte[] result;
- using (var stream = new MemoryStream())
- {
- var writer = new VinnoStreamWriter(stream);
- writer.WriteString(Name);
- writer.WriteByte((byte)Type);
- writer.WriteBytes(Application.ToBytes());
- writer.WriteDouble(FrameRate);
- result = stream.ToArray();
- }
- return result;
- }
- public static VinnoProbe FromBytes(byte[] bytes)
- {
- if (bytes == null)
- {
- return null;
- }
- VinnoProbe result;
- using (var stream = new MemoryStream(bytes))
- {
- stream.Position = 0;
- var reader = new VinnoStreamReader(stream);
- var name = reader.ReadString();
- var type = (VinnoProbeType)reader.ReadByte();
- var application = VinnoApplication.FromBytes(reader.ReadBytes());
- var frameRate = reader.ReadDouble();
- if (frameRate == 0)
- {
- frameRate = 15;
- }
- if (frameRate<10&&frameRate>= 1)
- {
- frameRate = 10;
- }
-
- result = new VinnoProbe(name, type, application, frameRate);
- }
- return result;
- }
- }
- }
|