private static char GetPrefix(FrameTypes frametype) { switch (frametype) { case FrameTypes.Image: return 'I'; case FrameTypes.Number: return 'N'; case FrameTypes.Rating: return 'R'; case FrameTypes.Text: return 'T'; case FrameTypes.Actor: return 'A'; case FrameTypes.Direcor: return 'D'; case FrameTypes.Producer: return 'P'; case FrameTypes.Writer: return 'W'; case FrameTypes.Genreset: return 'G'; default: return '\0'; } }
/// <summary> /// 发送数据到客户端 /// </summary> /// <param name="client">客户端</param> /// <param name="frameType">帧类型</param> /// <param name="bytes">内容</param> private void Send(SocketAsync <Hybi13Packet> client, FrameTypes frameType, byte[] bytes) { var packet = new ResponsePacket(); packet.SetBody(frameType, bytes); client.Send(packet); }
/// <summary> /// Writes the given frame to the dump file /// </summary> /// <param name="fInputFrame">The frame to dump</param> protected override void HandleTraffic(Frame fInputFrame) { byte[] bData; if (bReadyToLog || bIsLiveLogging) { if (FrameTypes.IsIP(fInputFrame)) //IP hack { Ethernet.EthernetFrame ethFrame = new Ethernet.EthernetFrame(); if (((IP.IPFrame)fInputFrame).Version == 4) { ethFrame.EtherType = EtherType.IPv4; } else if (((IP.IPFrame)fInputFrame).Version == 6) { ethFrame.EtherType = EtherType.IPv6; } ethFrame.EncapsulatedFrame = fInputFrame; fInputFrame = ethFrame; } bData = fInputFrame.FrameBytes; if (bReadyToLog) { WritePacketHeader(fInputFrame, bw); bw.Write(bData); } if (bIsLiveLogging) { WritePacketHeader(fInputFrame, bwLiveCapture); bwLiveCapture.Write(bData); bwLiveCapture.Flush(); } iLogByteCount += bData.Length; } }
/// <summary> /// 设置二进制数据 /// 数据将被进行帧处理 /// </summary> /// <param name="frameType">帧类型</param> /// <param name="bytes">原始制数据</param> public void SetBody(FrameTypes frameType, byte[] bytes) { if (bytes == null) { bytes = new byte[0]; } this.FrameType = frameType; this.Bytes = base.FrameBuffer(bytes, this.FrameType); }
protected void OnRawFrameIn(byte[] data, FrameTypes type) { if (RawFrameIn != null) { RawFrameIn(this, new RawFrameEventArgs() { Data = data, FrameType = type, FrameID = FrameID }); } }
/** * @brief Function that reads in the list of frame types from a file * * @param path of file to be read in * @return FrameTypes object with a list of all the types of frames tha can be used */ public FrameTypes ReadFrameData(string jsonFile) { string json = File.ReadAllText(jsonFile); Debug.Log(json); FrameTypes frames = JsonUtility.FromJson <FrameTypes>(json); //List<Frame> frameData = new List<Frame>(); return(frames); }
/** * @brief Function to generate the level, creates 20 frames * * @param FrameTypes object read in from ReadFrameData, containing list of frames */ public void CreateBuilding(FrameTypes listOfFrames) { //Uses the premade list of frames to create a level GameObject building = new GameObject(); building.tag = "Building"; building.name = "Building"; BoxCollider bc = building.AddComponent <BoxCollider>(); bc.isTrigger = true; bc.transform.position = lastFrame.transform.position; Frame frame; numBuildings++; int length = 20; for (int i = 0; i < length; i++) { //Copy ------------ CalculateWeight(); //Sort for the heightest weight frame = HighestWeightFrame(); frame.lastUsed = Time.timeSinceLevelLoad; //Call CreateFrame to make each piece based on the Frame's data if (frame.repeat > 0) { //Check for repeats, then simply create the same piece again (Potentially with an empty space between?) for (int j = 0; j < frame.repeat; j++) { CreateFrame(frame, building); i++; if (i == length) { break; } } } else { CreateFrame(frame, building); } //Piece pieces together to create a complete building //Use configuration settings(ie. Lane Width, Frame Length, etc.) } //Return building GameObject to have and reference later potentially? return; //Copy -------------- }
public static BlokFrame GetBlokFrame(CanFrame f) { if (!FrameTypes.ContainsKey(f.Descriptor)) { throw new ApplicationException("Не найдено описание сообщения с таким дескриптором"); } Type t = FrameTypes[f.Descriptor]; var res = (BlokFrame)t.GetConstructor(new Type[0]).Invoke(new object[0]); FillWithData(res, f.Data); return(res); }
private void KinectSensor_AllFramesReady(object sender, AllFramesReadyEventArgs e) { DepthFrameStream360.DepthFrame depthFrame360 = null; BodyFrameStream360.BodyFrame bodyFrame360 = null; ColorFrameStream360.ColorFrame colorFrame360 = null; if (FrameTypes.HasFlag(MultiFrameTypes.Color)) { var colorFrame = e.OpenColorImageFrame(); if (colorFrame == null) { return; } colorFrame360 = new ColorFrameStream360.ColorFrame(colorFrame); } if (FrameTypes.HasFlag(MultiFrameTypes.Body)) { var skeletonFrame = e.OpenSkeletonFrame(); if (skeletonFrame == null) { return; } bodyFrame360 = new BodyFrameStream360.BodyFrame(skeletonFrame); } if (FrameTypes.HasFlag(MultiFrameTypes.Depth)) { var depthFrame = e.OpenDepthImageFrame(); if (depthFrame == null) { return; } depthFrame360 = new DepthFrameStream360.DepthFrame(depthFrame); } MultiFrameArrived?.Invoke(this, new MultiFrameReadyEventArgs(new MultiFrame(colorFrame360, bodyFrame360, depthFrame360))); }
public static void FillTemplatesSelectList( this BaseController _controller, DisplayMonkeyEntities _db, FrameTypes _frameType, object _selected = null ) { var query = _db.Templates .Where(t => t.FrameType == _frameType) .Select(t => new { TemplateId = t.TemplateId, Name = t.Name }) .OrderBy(t => t.Name) .ToList() ; _controller.ViewBag.Templates = new SelectList(query, "TemplateId", "Name", _selected); }
// GET: /Template/ public ActionResult Index(FrameTypes? frameType) { this.SaveReferrer(); IQueryable<Template> list = db.Templates; if (frameType.HasValue) { list = list .Where(s => s.FrameType == frameType.Value) ; } list = list .OrderBy(t => t.FrameType) .ThenBy(t => t.Name) ; FillFrameTypesSelectList(); return View(list.ToList()); }
/// <summary> /// 将数据作帧处理 /// </summary> /// <param name="bytes">原始数据</param> /// <param name="frameType">帧类型</param> /// <returns></returns> protected byte[] FrameBuffer(byte[] bytes, FrameTypes frameType) { var builder = new ByteBuilder(); builder.Add((byte)((byte)frameType + 128)); if (bytes.Length > UInt16.MaxValue) { builder.Add((byte)127); builder.Add((ulong)bytes.Length, Endians.Big); } else if (bytes.Length > 125) { builder.Add((byte)126); builder.Add((ushort)bytes.Length, Endians.Big); } else { builder.Add((byte)bytes.Length); } builder.Add(bytes); return(builder.ToArray()); }
void DisplayCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (DisplayCombo.SelectedIndex == 0) { _displayType = FrameTypes.Body; OutputImage.Source = null; } else if (DisplayCombo.SelectedIndex == 1) { _displayType = FrameTypes.Color; OutputImage.Source = _colorBitmap.Bitmap; } else if (DisplayCombo.SelectedIndex == 2) { _displayType = FrameTypes.Depth; OutputImage.Source = _depthBitmap.Bitmap; } else { _displayType = FrameTypes.Infrared; OutputImage.Source = _infraredBitmap.Bitmap; } }
public static dynamic GetTSObject(FrameTypes dynEnum) { var tsType = TSActivator.CreateInstance("Tekla.Structures.Drawing.FrameTypes").GetType(); switch (dynEnum) { case FrameTypes.None: return(System.Enum.Parse(tsType, "None")); case FrameTypes.Rectangular: return(System.Enum.Parse(tsType, "Rectangular")); case FrameTypes.Line: return(System.Enum.Parse(tsType, "Line")); case FrameTypes.Round: return(System.Enum.Parse(tsType, "Round")); case FrameTypes.Circle: return(System.Enum.Parse(tsType, "Circle")); case FrameTypes.Diamond: return(System.Enum.Parse(tsType, "Diamond")); case FrameTypes.Hexagon: return(System.Enum.Parse(tsType, "Hexagon")); case FrameTypes.Triangle: return(System.Enum.Parse(tsType, "Triangle")); case FrameTypes.Sharpened: return(System.Enum.Parse(tsType, "Sharpened")); default: throw new DynamicAPIException(dynEnum.ToString() + "- enum value is not implemented"); } }
void OutputCombo_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (OutputCombo.SelectedValue == null) { return; } if (OutputCombo.SelectedValue.ToString() == "Body") { _displayType = FrameTypes.Body; OutputImage.Source = null; } else if (OutputCombo.SelectedValue.ToString() == "Color") { _displayType = FrameTypes.Color; if (_colorBitmap != null) { OutputImage.Source = _colorBitmap.Bitmap; } } else if (OutputCombo.SelectedValue.ToString() == "Depth") { _displayType = FrameTypes.Depth; if (_depthBitmap != null) { OutputImage.Source = _depthBitmap.Bitmap; } } else { _displayType = FrameTypes.Infrared; if (_infraredBitmap != null) { OutputImage.Source = _infraredBitmap.Bitmap; } } }
public Frame(string body, int fn, FrameTypes frameType, AstmLowLevelSettings lowLevelSettings) { _lowLevelSettings = lowLevelSettings; if (string.IsNullOrEmpty(body)) { throw new FrameConstructionException("Can not construct frame", new ArgumentNullException("Body is null or empty")); } if (body.Length > _lowLevelSettings.MaxFrameLength) { throw new FrameConstructionException("Can not construct frame", new ArgumentException("Body length is exceeded 240")); } if (fn < 0 || fn > 7) { throw new FrameConstructionException("Can not construct frame", new ArgumentOutOfRangeException("FN must be between 0..7")); } Body = body; FN = fn; FrameType = frameType; _lowLevelSettings = lowLevelSettings; }
public ScopeFrame(ScopeFrame original) : base((StructureFrame)original) { Name = original.Name; Type = original.Type; }
public ScopeFrame(StructureFrame original, string Name, FrameTypes Type) : base(original) { this.Name = Name; this.Type = Type; }
public Frame(int x, int y, FrameTypes type) : base(x, y) { Type = type; }
public static int GetDefaultCacheInterval(DisplayMonkeyEntities _db, FrameTypes? _frameType) { int ret = 0; Keys key = Keys.Count; switch (_frameType) { //case FrameTypes.Clock: //case FrameTypes.Html: //case FrameTypes.Memo: case FrameTypes.Outlook: key = Keys.DefaultCacheIntervalOutlook; break; case FrameTypes.Picture: key = Keys.DefaultCacheIntervalPicture; break; //case FrameTypes.Powerbi: case FrameTypes.Report: key = Keys.DefaultCacheIntervalReport; break; case FrameTypes.Video: key = Keys.DefaultCacheIntervalVideo; break; case FrameTypes.Weather: key = Keys.DefaultCacheIntervalWeather; break; //case FrameTypes.YouTube: default: return ret; } Setting defCacheInt = Setting.GetSetting(_db, key); if (defCacheInt != null) { ret = defCacheInt.IntValuePositive; } return ret; }
/// <summary> /// Initializes a new instance of the <see cref="FrameIdentifier"/>. /// </summary> /// <param name="frametype">The type of data associated with this <see cref="FrameIdentifier"/></param> /// <param name="identifier">A user-defined string for the identifier. Must be 3 chars or more.</param> public FrameIdentifier(FrameTypes frametype, string identifier) { if (identifier.Length < 3) throw new ArgumentException("An identifier can be no shorter than 3 characters."); foreach (char c in identifier) { if (!char.IsLetterOrDigit(c)) throw new ArgumentException("An identifier cannot contain the char '" + c + "'"); } this.type = frametype; char prefix = GetPrefix(frametype); if (prefix == '\0') throw new ArgumentException("Unknown frametype: " + frametype.ToString()); else this.identifier = prefix + identifier; this.buffer = Encoding.ASCII.GetBytes(this.identifier); if (this.buffer.Length > byte.MaxValue) throw new ArgumentException("An identifier can be no longer than " + byte.MaxValue + " characters."); }
public bool IsFrameType(FrameTypes type) { return this.type == type; }
private void FillFrameTypeSelectList(FrameTypes? selected = null) { ViewBag.FrameType = selected.TranslatedSelectList(valueAsText: true); }
public static int GetDefaultTemplate(DisplayMonkeyEntities _db, FrameTypes? _frameType) { int ret = 0; Keys key = Keys.Count; switch (_frameType) { case FrameTypes.Clock: key = Keys.DefaultTemplateClock; break; case FrameTypes.Html: key = Keys.DefaultTemplateHtml; break; case FrameTypes.Memo: key = Keys.DefaultTemplateMemo; break; case FrameTypes.Outlook: key = Keys.DefaultTemplateOutlook; break; case FrameTypes.Picture: key = Keys.DefaultTemplatePicture; break; case FrameTypes.Powerbi: key = Keys.DefaultTemplatePowerbi; break; case FrameTypes.Report: key = Keys.DefaultTemplateReport; break; case FrameTypes.Video: key = Keys.DefaultTemplateVideo; break; case FrameTypes.Weather: key = Keys.DefaultTemplateWeather; break; case FrameTypes.YouTube: key = Keys.DefaultTemplateYouTube; break; default: return ret; } Setting defTemplate = GetSetting(_db, key); if (defTemplate != null) { string templateName = defTemplate.StringValue; ret = _db.Templates .Where(t => t.Name == templateName && t.FrameType == _frameType) .FirstOrDefault() .TemplateId ; } return ret; }
public static string IconFromFrameType(FrameTypes? _frameType) { if (_frameType.HasValue) switch (_frameType.Value) { case FrameTypes.Clock: return "~/images/clock.png"; case FrameTypes.Html: return "~/images/html.png"; //case FrameTypes.News: // return "~/images/news.png"; case FrameTypes.Memo: return "~/images/memo.png"; case FrameTypes.Outlook: return "~/images/calendar.png"; case FrameTypes.Picture: return "~/images/image.png"; case FrameTypes.Report: return "~/images/ssrs.png"; case FrameTypes.Video: return "~/images/video_thmb.png"; case FrameTypes.Weather: return "~/images/weather.png"; case FrameTypes.YouTube: return "~/images/youtube.png"; } return "~/images/unknown.png"; }
public static Expression<Func<Frame, bool>> FilterByFrameType(FrameTypes? frameType) { if (frameType == null) return (f => true); else return (f => f.Template.FrameType == frameType.Value); }
public RoomPlacement(Room room, string positions, int rotation, FrameTypes type) : this( positions, rotation, type ) { Room = room; }
public RoomPlacement(string positions, int rotation, FrameTypes type) { Positions = positions; Rotation = rotation; Type = type; }
public ScopeFrame(ScopeFrame original) : base((StructureFrame) original) { Name = original.Name; Type = original.Type; }
public ScopeFrame() : base() { Name = ""; Type = FrameTypes.None; }
private void FillFrameTypesSelectList(FrameTypes? selected = null) { ViewBag.FrameTypes = selected.TranslatedSelectList(); }
//IEnumerator CoBuild; // Start is called before the first frame update void Start() { #region PlayerPrefs Loading if (PlayerPrefs.GetInt("Save?", 1) > 0) { save = true; } else { save = false; } if (PlayerPrefs.GetInt("SaveAsJson?", 1) > 0) { json = true; } else { json = false; } fileSaveLocation = PlayerPrefs.GetString("SaveDataLocation", ""); configFilePath = PlayerPrefs.GetString("WorldConfig", ""); playerName = PlayerPrefs.GetString("PlayerName", ""); if (PlayerPrefs.GetInt("LoadLevel?", 0) > 0) { loadLevel = true; } else { loadLevel = false; } #endregion origin.Set(0, -1.57f, -(frameLength / 2)); fabScale.Set((float)laneWidth, 1f, (float)frameLength); GameObject first = new GameObject(); first.transform.position = origin; lastFrame = first; lastFramePos = origin; //FrameTypes frameData; if (configFilePath != "") { frameData = ReadFrameData(configFilePath); } else { frameData = ReadFrameData(Application.dataPath + "/data.txt"); } Debug.Log(frameData.frameTypes[1].weight); Debug.Log(frameData.frameTypes.Length); //If a pregenerated level is selected, create that instead of generating one if (loadLevel) { } else { CreateBuilding(frameData); } //Create empty frames to start off //Debug.Log("Frame length :" + frameLength); //rand = new System.Random(); SpawnClouds(); }
public ScopeFrame(string Name, FrameTypes Type) : base() { this.Name = Name; this.Type = Type; }
/// <summary> /// Internal constructor! Only to be used by <see cref="FrameScanner"/>! /// </summary> /// <param name="bytes">A buffer from which the identifier is read</param> /// <param name="index">The index of the first byte in the identifier</param> /// <param name="count">The number of bytes in the identifier</param> internal FrameIdentifier(byte[] bytes, int index, int count) { this.identifier = Encoding.ASCII.GetString(bytes, index, count); this.type = GetFrameType(this.identifier[0]); this.buffer = new byte[count]; Buffer.BlockCopy(bytes, index, this.buffer, 0, count); }
// // GET: /Frame/Create public ActionResult Create(int canvasId = 0, int panelId = 0, FrameTypes? frameType = null) { Panel panel = null; if (panelId != 0) { panel = db.Panels .Include(p => p.Canvas) .FirstOrDefault(p => p.PanelId == panelId) ; if (panel == null) panelId = 0; } if (frameType == null || panel == null) { if (canvasId == 0 && panel != null) canvasId = panel.CanvasId; return RedirectToAction("ForFrameType", new { canvasId = canvasId, panelId = panelId, frameType = frameType }); } TempData[SelectorFrameKey] = new Frame() { Panel = panel, PanelId = panelId, CacheInterval = 0, }; return RedirectToAction("Create", frameType.ToString()); }
public IEnumerable<FrameIdentifier> GetIdentifiers(FrameTypes type) { return fs.Frames.Keys.IsFrameType(type); }
void OutputCombo_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (OutputCombo.SelectedValue == null) return; if (OutputCombo.SelectedValue.ToString() == "Body") { _displayType = FrameTypes.Body; OutputImage.Source = null; } else if (OutputCombo.SelectedValue.ToString() == "Color") { _displayType = FrameTypes.Color; if (_colorBitmap != null) OutputImage.Source = _colorBitmap.Bitmap; } else if (OutputCombo.SelectedValue.ToString() == "Depth") { _displayType = FrameTypes.Depth; if (_depthBitmap != null) OutputImage.Source = _depthBitmap.Bitmap; } else { _displayType = FrameTypes.Infrared; if (_infraredBitmap != null) OutputImage.Source = _infraredBitmap.Bitmap; } }
/// <summary> /// 表示请求封包 /// </summary> /// <param name="frameType">帧类型</param> /// <param name="bytes">处理后的二进制数据</param> private RequestPacket(FrameTypes frameType, byte[] bytes) { this.FrameType = frameType; this.Bytes = bytes; }
public ControlApiOperation(FrameTypes handlerType, CommandTypes command, bool isSequenceNumberRequired) : base(true, command, isSequenceNumberRequired) { HandlerType = handlerType; }
public ApiHandler(FrameTypes frameType, CommandTypes command) { Mask = new ByteIndex[] { new ByteIndex((byte)frameType), new ByteIndex((byte)command) }; }
public void SortFrames(FrameTypes data) { }
/*public ActionResult ForCanvas() { FillCanvasesSelectList(); return View(); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult ForCanvas(Canvas canvas) { if (canvas.CanvasId > 0) { return RedirectToAction("ForPanel", new { canvasId = canvas.CanvasId }); } return RedirectToAction("ForCanvas"); }*/ /*public ActionResult ForPanel(int canvasId) { Panel panel = db.Panels .Include(p => p.Canvas) .FirstOrDefault(p => p.CanvasId == canvasId) ; if (panel.PanelId == 0) { return RedirectToAction("ForCanvas"); } FillPanelsSelectList(canvasId: canvasId); return View(panel); } [HttpPost] [ValidateAntiForgeryToken] public ActionResult ForPanel(Panel panel) { if (panel.PanelId > 0) { return RedirectToAction("ForFrameType", new { panelId = panel.PanelId }); } return RedirectToAction("ForPanel", new { canvasId = panel.Canvas.CanvasId }); }*/ public ActionResult ForFrameType(int canvasId = 0, int panelId = 0, FrameTypes? frameType = null) { if (canvasId == 0) { Canvas canvas = db.Canvases .OrderBy(c => c.Name) .FirstOrDefault() ; if (canvas != null) canvasId = canvas.CanvasId; } FrameSelector selector = new FrameSelector() { CanvasId = canvasId, PanelId = panelId, FrameType = frameType.HasValue ? frameType.Value : 0, }; FillCanvasesSelectList(canvasId); FillPanelsSelectList(panelId, canvasId); FillFrameTypeSelectList(frameType); return View(selector); }
// // GET: /Frame/ public ActionResult Index(int canvasId = 0, int panelId = 0, FrameTypes? frameType = null, int? timingOption = null /*, int page = 1*/) { this.SaveReferrer(); //if (page <= 0) page = 1; IQueryable<Frame> list = db.Frames .Include(f => f.Panel) .Include(f => f.Panel.Canvas) .Include(f => f.News) .Include(f => f.Clock) .Include(f => f.Weather) .Include(f => f.Memo) .Include(f => f.Report) .Include(f => f.Picture) .Include(f => f.Video) .Include(f => f.Html) ; if (canvasId > 0) { list = list.Where(f => f.Panel.CanvasId == canvasId); } if (panelId > 0) { list = list.Where(f => f.PanelId == panelId); } if (frameType != null) { list = list.Where(Frame.FilterByFrameType(frameType)); } DateTime dt = DateTime.Now; if (timingOption != null) { switch ((Frame.TimingOptions)timingOption) { case Frame.TimingOptions.TimingOption_Pending: list = list.Where(f => dt < f.BeginsOn); break; case Frame.TimingOptions.TimingOption_Current: list = list.Where(f => (f.BeginsOn == null || f.BeginsOn <= dt) && (f.EndsOn == null || dt < f.EndsOn)); break; case Frame.TimingOptions.TimingOption_Expired: list = list.Where(f => f.EndsOn <= dt); break; } } //ViewBag.TotalPages = (int)Math.Ceiling((float)list.Count() / 20.0); //ViewBag.CurrentPage = page; list = list //.Skip((page - 1) * 20) //.Take(20) .OrderBy(f => f.Panel.Canvas.Name) .ThenBy(f => f.Panel.Name) .ThenBy(f => f.Sort == null ? (float)f.FrameId : (float)f.Sort) .ThenBy(f => f.FrameId) ; FillCanvasesSelectList(canvasId); FillPanelsSelectList(panelId, canvasId); FillFrameTypeSelectList(frameType); FillTimingOptionsSelectList((Frame.TimingOptions?)timingOption); return View(list.ToList()); }
public static IEnumerable<FrameIdentifier> IsFrameType(this IEnumerable<FrameIdentifier> collection, FrameTypes type) { foreach (FrameIdentifier fi in collection) if (fi.IsFrameType(type)) yield return fi; }
//////////////////////////////////////////////////////////////////////////// #region CONSTRUCTOR / DESTRUCTOR //////////////////////////////////////////////////////////////////////////// /// <summary> /// Creates a new instance of a <c>KinectReplay</c> using the referenced stream. /// This will read in the headers for all frames in the stream and make them /// available for playback. The stream will remain open until the instance /// is disposed. /// </summary> public KinectReplay(Stream stream) { this._stream = stream; _reader = new BinaryReader(stream); _timer.Tick += _timer_Tick; var metadata = JsonConvert.DeserializeObject <FileMetadata>(_reader.ReadString()); Version version = this.GetType().GetTypeInfo().Assembly.GetName().Version; // default to this Version.TryParse(metadata.Version, out version); while (_reader.BaseStream.Position != _reader.BaseStream.Length) { try { FrameTypes type = (FrameTypes)_reader.ReadInt32(); switch (type) { case FrameTypes.Body: if (_bodyReplay == null) { _bodyReplay = new ReplayBodySystem(); _activeReplaySystems.Add(_bodyReplay); _bodyReplay.PropertyChanged += replay_PropertyChanged; _bodyReplay.FrameArrived += bodyReplay_FrameArrived; } _bodyReplay.AddFrame(_reader, version); break; case FrameTypes.Color: if (_colorReplay == null) { IColorCodec codec = new RawColorCodec(); if (metadata.ColorCodecId == ColorCodecs.Jpeg.CodecId) { codec = new JpegColorCodec(); } _colorReplay = new ReplayColorSystem(codec); _activeReplaySystems.Add(_colorReplay); _colorReplay.PropertyChanged += replay_PropertyChanged; _colorReplay.FrameArrived += colorReplay_FrameArrived; } _colorReplay.AddFrame(_reader); break; case FrameTypes.Depth: if (_depthReplay == null) { _depthReplay = new ReplayDepthSystem(); _activeReplaySystems.Add(_depthReplay); _depthReplay.PropertyChanged += replay_PropertyChanged; _depthReplay.FrameArrived += depthReplay_FrameArrived; } _depthReplay.AddFrame(_reader); break; case FrameTypes.Infrared: if (_infraredReplay == null) { _infraredReplay = new ReplayInfraredSystem(); _activeReplaySystems.Add(_infraredReplay); _infraredReplay.PropertyChanged += replay_PropertyChanged; _infraredReplay.FrameArrived += infraredReplay_FrameArrived; } _infraredReplay.AddFrame(_reader); break; } } catch { throw; } } foreach (var replaySystem in _activeReplaySystems) { if (replaySystem.Frames.Count > 0) { replaySystem.Frames.Sort(); for (var i = 0; i < replaySystem.Frames.Count; i++) { replaySystem.FrameTimeToIndex[replaySystem.Frames[i].RelativeTime] = i; } var first = replaySystem.Frames.First().RelativeTime; var last = replaySystem.Frames.Last().RelativeTime; if (first < _minTimespan) { _minTimespan = first; } if (last > _maxTimespan) { _maxTimespan = last; } } } bool hasFrames = false; foreach (var replaySystem in _activeReplaySystems) { if (replaySystem.Frames.Count > 0) { replaySystem.StartingOffset = _minTimespan; hasFrames = true; } } if (hasFrames) { this.Duration = _maxTimespan - _minTimespan; } else { this.Duration = TimeSpan.Zero; } }
public RequestApiOperation(FrameTypes handlerType, CommandTypes command, bool isSequenceNumberRequired) : base(true, command, isSequenceNumberRequired) { TimeoutMs = RET_TIMEOUT; HandlerType = handlerType; }
public ControlApiOperation(CommandTypes command, FrameTypes handlerType) : this(handlerType, command, true) { }
/// <summary> /// Decapsulates the given IP frame if the binding of this socket matches the frame and invokes the FrameDecapsulated event when finished. /// <remarks>This mehtod also handles IP fragmentation</remarks> /// </summary> /// <param name="fFrame">The frame to process</param> /// <param name="bPush">A bool indicating whether the frame is delivered with a push flag</param> /// <returns>A bool indicating whether the given frame matched the binding of this socket</returns> public override bool PushUp(Frame fFrame, bool bPush) { if (!FrameTypes.IsIP(fFrame)) { fFrame = IPFrame.Create(fFrame.FrameBytes); } IPFrame ipFrame = (IPFrame)fFrame; if (!ipFrame.SourceAddress.Equals(RemoteBinding) || !ipFrame.DestinationAddress.Equals(LocalBinding)) { return(false); } if (ipFrame.FrameType == FrameTypes.IPv4) { IPv4Frame ipv4Frame = (IPv4Frame)ipFrame; if (ipv4Frame.Protocol != this.ProtocolBinding) { return(false); } if (ipv4Frame.EncapsulatedFrame != null) { if (ipv4Frame.PacketFlags.MoreFragments) { HandleFragment(bPush, ipv4Frame.PacketFlags.MoreFragments, ipv4Frame.Identification, ipv4Frame.FragmentOffset, ipv4Frame.EncapsulatedFrame.FrameBytes); } else { InvokeFrameDecapsulated(ipv4Frame.EncapsulatedFrame, bPush); } } return(true); } else if (ipFrame.FrameType == FrameTypes.IPv6) { ProtocolParser.ParseCompleteFrame(fFrame); Frame fPayload = null; Frame ipHeader = fFrame; while (ipHeader.EncapsulatedFrame != null && ipHeader.EncapsulatedFrame is IIPHeader) { if (((IIPHeader)ipHeader).Protocol == this.ProtocolBinding) { fPayload = ipHeader.EncapsulatedFrame; break; } } if (fPayload == null) { return(false); //Wrong payload type :( } FragmentExtensionHeader fragHeader = (FragmentExtensionHeader)ProtocolParser.GetFrameByType(fFrame, FragmentExtensionHeader.DefaultFrameType); if (fragHeader != null) { HandleFragment(bPush, fragHeader.MoreFragments, fragHeader.Identification, fragHeader.FragmentOffset, fPayload.FrameBytes); } else { InvokeFrameDecapsulated(fPayload, bPush); } } throw new ArgumentException("Only IPv4 and IPv6 frames are supported at the moment."); }