internal Frame(FrameType frameType) { Shiny = false; EncounterMod = EncounterMod.None; Offset = 0; FrameType = frameType; }
private static byte[] FrameData(byte[] payload, FrameType frameType) { using (var memoryStream = new MemoryStream()) { var op = (byte) ((byte) frameType + 128); memoryStream.WriteByte(op); if (payload.Length > UInt16.MaxValue) { memoryStream.WriteByte(127); var lengthBytes = payload.Length.ToBigEndianBytes<ulong>(); memoryStream.Write(lengthBytes, 0, lengthBytes.Length); } else if (payload.Length > 125) { memoryStream.WriteByte(126); var lengthBytes = payload.Length.ToBigEndianBytes<ushort>(); memoryStream.Write(lengthBytes, 0, lengthBytes.Length); } else { memoryStream.WriteByte((byte) payload.Length); } memoryStream.Write(payload, 0, payload.Length); return memoryStream.ToArray(); } }
//Correct spares from GUI input (slashes input as -1) public void CombSpare() { if(scores[1] == -1) { scores[1] = 10 - scores[0]; type = FrameType.spare; } }
public static ByteBuffer Encode(FrameType type, ushort channel, DescribedList command) { ByteBuffer buffer = new ByteBuffer(cmdBufferSize, true); EncodeFrame(buffer, type, channel, command); AmqpBitConverter.WriteInt(buffer.Buffer, 0, buffer.Length); return buffer; }
public static void ProcessFrame(FrameType frameType, byte[] data, Action<string> onMessage, Fleck2Extensions.Action onClose, Action<byte[]> onBinary) { switch (frameType) { case FrameType.Close: if (data.Length == 1 || data.Length>125) throw new WebSocketException(WebSocketStatusCodes.ProtocolError); if (data.Length >= 2) { var closeCode = (ushort) (data.Take(2).ToArray().ToLittleEndianInt()); if (!WebSocketStatusCodes.Contains(closeCode) && (closeCode < 3000 || closeCode > 4999)) throw new WebSocketException(WebSocketStatusCodes.ProtocolError); } if (data.Length > 2) ReadUtf8PayloadData(data.Skip(2)); onClose(); break; case FrameType.Binary: onBinary(data); break; case FrameType.Text: onMessage(ReadUtf8PayloadData(data)); break; default: FleckLog.Debug("Received unhandled " + frameType); break; } }
public static Frame Create (FrameType frameType) { switch (frameType) { case FrameType.Data: return new DataFrame (); case FrameType.Headers: return new HeadersFrame (); case FrameType.Priority: return new PriorityFrame (); case FrameType.RstStream: return new RstStreamFrame (); case FrameType.Settings: return new SettingsFrame (); case FrameType.PushPromise: return new PushPromiseFrame (); case FrameType.Ping: return new PingFrame (); case FrameType.GoAway: return new GoAwayFrame (); case FrameType.WindowUpdate: return new WindowUpdateFrame (); case FrameType.Continuation: return new ContinuationFrame (); } return null; }
public GuideFrame CreateTextFrame(Mode mode, FrameType type ) { Bounds newBounds = contentBounds.Clone(); newBounds.top = GetNextTop(); newBounds.height = 10; TextFrame textFrame = page.TextFrames.Add(miss, idLocationOptions.idAtEnd, miss); textFrame.GeometricBounds = newBounds.raw; textFrame.TextFramePreferences.FirstBaselineOffset = idFirstBaseline.idLeadingOffset; if (mode==Mode.TwoColumns) { textFrame.TextFramePreferences.TextColumnCount = 2; } //$.global.textFrames.push( myTextFrame ); GuideFrame frame = new GuideFrame(textFrame, this.guide, this, mode, type); frame.bounds = newBounds; //currentFrame = frame; frames.Add(frame); //currentMode = mode; return frame; }
public Frame(FrameType frameType) { VerifyConstructorCall (this); #pragma warning disable 618 Type = frameType; #pragma warning restore 618 }
private static void _drawFrame(int x, int y, int width, int height, FrameType frameType, bool isFilled, string caption, Color captionColor = Color.White, Color captionBackColor = Color.Black) { var charSet = frameCharSets[(int) _validate(frameType)]; ZOutput.Print(x, y, charSet[0].ToString().PadRight(width-1, charSet[1]) + charSet[2]); var fill = charSet[3].ToString().PadRight(width - 1, ' ') + charSet[4]; for (var i = 1; i < height-1; i++) { if (isFilled) { ZOutput.Print(x, y+i, fill); } else { ZOutput.Print(x, y+i, charSet[3]); ZOutput.Print(x+width-1, y+i, charSet[4]); } } ZOutput.Print(x, y+height-1, charSet[5].ToString().PadRight(width-1, charSet[6]) + charSet[7]); if (!string.IsNullOrEmpty(caption)) { ZOutput.Print(x + 2, y, " " + caption + " ", captionColor, captionBackColor); } }
public static String Name(FrameType type, CelestialBody selected) { switch (type) { case FrameType.BODY_CENTRED_NON_ROTATING: return selected.name + "-Centred Inertial"; case FrameType.BARYCENTRIC_ROTATING: if (selected.is_root()) { throw Log.Fatal("Naming barycentric rotating frame of root body"); } else { return selected.referenceBody.name + "-" + selected.name + " Barycentric"; } case FrameType.BODY_CENTRED_PARENT_DIRECTION: if (selected.is_root()) { throw Log.Fatal( "Naming parent-direction rotating frame of root body"); } else { // TODO(egg): find a proper name... return selected.name + "-Centred " + selected.referenceBody.name + "-Fixed"; } case FrameType.BODY_SURFACE: return selected.name + "-Centred " + selected.name + "-Fixed"; default: throw Log.Fatal("Unexpected type " + type.ToString()); } }
public static ByteBuffer Encode(FrameType type, ushort channel, Transfer transfer, ByteBuffer payload, int maxFrameSize, out int payloadSize) { int bufferSize = cmdBufferSize + payload.Length; if (bufferSize > maxFrameSize) { bufferSize = maxFrameSize; } bool more = false; // estimate it first if (payload.Length > bufferSize - 32) { transfer.More = more = true; } ByteBuffer buffer = new ByteBuffer(bufferSize, false); EncodeFrame(buffer, type, channel, transfer); if (more && payload.Length <= buffer.Size) { // guessed it wrong. correct it transfer.More = false; buffer.Reset(); EncodeFrame(buffer, type, channel, transfer); } payloadSize = Math.Min(payload.Length, buffer.Size); AmqpBitConverter.WriteBytes(buffer, payload.Buffer, payload.Offset, payloadSize); payload.Complete(payloadSize); AmqpBitConverter.WriteInt(buffer.Buffer, 0, buffer.Length); return buffer; }
public packetBase(int frameNumber, FrameType type, int length, byte checksum, DateTime recTime) { this.frameNumber = frameNumber; this.length = length; this.checksum = checksum; this.recTime = recTime; this.type = type; }
public static void Encode(ByteBuffer buffer, FrameType type, ushort channel, DescribedList command) { buffer.Append(FixedWidth.UInt); AmqpBitConverter.WriteUByte(buffer, DOF); AmqpBitConverter.WriteUByte(buffer, (byte)type); AmqpBitConverter.WriteUShort(buffer, channel); Codec.Encode(command, buffer); AmqpBitConverter.WriteInt(buffer.Buffer, buffer.Offset, buffer.Length); }
public Frame(FrameDirection direction, FrameType type, byte id, byte seq, byte[] data) { this.Direction = direction; this.Type = type; this.Id = id; this.Seq = seq; this.Data = data; }
public EggParents(FrameType frameType, EncounterType encounterType, uint seed) { InitializeComponent(); this.seed = seed; this.encounterType = encounterType; this.frameType = frameType; if (frameType == FrameType.BWBred || frameType == FrameType.BWBredInternational) { Text = "Display Parent IVs"; buttonRetrieveIVs.Text = "Get IVs from IVRNG (Frame 8)"; } else if (frameType == FrameType.DPPtBred || frameType == FrameType.HGSSBred || frameType == FrameType.Bred || frameType == FrameType.BredSplit || frameType == FrameType.BredAlternate) { labelParentA.Text = "Parent A"; labelParentB.Text = "Parent B"; labelParentA.Location = new Point(39, 40); labelParentB.Location = new Point(39, 66); labelIVRNG.Visible = false; maskedTextBoxHP_IVRNG.Visible = false; maskedTextBoxAtk_IVRNG.Visible = false; maskedTextBoxDef_IVRNG.Visible = false; maskedTextBoxSpA_IVRNG.Visible = false; maskedTextBoxSpD_IVRNG.Visible = false; maskedTextBoxSpe_IVRNG.Visible = false; } else { maskedTextBoxHP_ParentA.Enabled = false; maskedTextBoxAtk_ParentA.Enabled = false; maskedTextBoxDef_ParentA.Enabled = false; maskedTextBoxSpA_ParentA.Enabled = false; maskedTextBoxSpD_ParentA.Enabled = false; maskedTextBoxSpe_ParentA.Enabled = false; maskedTextBoxHP_ParentB.Enabled = false; maskedTextBoxAtk_ParentB.Enabled = false; maskedTextBoxDef_ParentB.Enabled = false; maskedTextBoxSpA_ParentB.Enabled = false; maskedTextBoxSpD_ParentB.Enabled = false; maskedTextBoxSpe_ParentB.Enabled = false; Text = "Display Characteristics in List"; buttonRetrieveIVs.Text = encounterType == EncounterType.LarvestaEgg ? "Get IVs from IVRNG (Frame 2)" : "Get IVs from IVRNG (Frame 1)"; } }
public void Reset(NavigationFrameParameters parameters) { frame_type = (FrameType)parameters.extension; switch (frame_type) { case FrameType.BODY_CENTRED_NON_ROTATING: selected_celestial_ = FlightGlobals.Bodies[parameters.centre_index]; break; case FrameType.BARYCENTRIC_ROTATING: selected_celestial_ = FlightGlobals.Bodies[parameters.secondary_index]; break; } }
// Creates an outgoing frame (packet) public Frame(FrameType type, ushort channel, Performative command) { this.Type = type; this.Channel = channel; this.Command = command; this.dataOffset = Frame.DefaultDataOffset; this.size = HeaderSize; if (this.Command != null) { this.size += AmqpCodec.GetSerializableEncodeSize(this.Command) + this.Command.PayloadSize; } }
//Receive & Frame methods private Rfc6455DataFrame GetDataFrame(FrameType frameType, byte[] payload) { var frame = new Rfc6455DataFrame { FrameType = frameType, IsFinal = true, IsMasked = true, MaskKey = new Random().Next(0, 34298), Payload = payload }; return frame; }
private UInt16 fixedLengthWithFrameType(FrameType type) { switch (type) { case FrameType.RemoteATCommand: return 15; case FrameType.ATCommand: default: return 4; } }
/// <summary> /// Converts the given value to its string representation. /// </summary> /// <param name="value">The type of the frame.</param> /// <returns>The string representing the given frame type.</returns> public string ToString(FrameType value) { switch (value) { case FrameType.Default: case FrameType.Row: return "ROWS"; case FrameType.Range: return "RANGE"; default: throw new ArgumentException(Resources.UnknownFrameType, "value"); } }
public void SetFrameType (FrameType type) { Frame f = (Frame) Frontend; switch (type) { case FrameType.Custom: if (!(Widget is HeaderBox)) { HeaderBox box = new HeaderBox (); box.Show (); box.BackgroundColor = UsingCustomBackgroundColor ? (Color?)BackgroundColor : null; box.SetMargins ((int)f.BorderWidthTop, (int)f.BorderWidthBottom, (int)f.BorderWidthLeft, (int)f.BorderWidthRight); box.SetPadding ((int)f.Padding.Top, (int)f.Padding.Bottom, (int)f.Padding.Left, (int)f.Padding.Right); if (borderColor != null) box.SetBorderColor (borderColor.Value); var c = paddingAlign != null ? paddingAlign.Child : Widget.Child; if (c != null) { ((Gtk.Container)c.Parent).Remove (c); box.Add (c); } Widget = box; if (paddingAlign != null) { paddingAlign.Destroy (); paddingAlign = null; } } break; case FrameType.WidgetBox: if (!(Widget is Gtk.Frame)) { var c = Widget.Child; if (c != null) Widget.Remove (c); Gtk.Frame gf = new Gtk.Frame (); if (!string.IsNullOrEmpty (label)) gf.Label = label; if (f.Padding.HorizontalSpacing != 0 || f.Padding.VerticalSpacing != 0) { paddingAlign = new Gtk.Alignment (0, 0, 1, 1); paddingAlign.Show (); UreatePaddingAlign (f.Padding.Top, f.Padding.Bottom, f.Padding.Left, f.Padding.Right); if (c != null) paddingAlign.Add (c); gf.Add (paddingAlign); } else { if (c != null) gf.Add (c); } gf.Show (); Widget = gf; } break; } }
public static String ShortName(FrameType type, CelestialBody selected) { switch (type) { case FrameType.BODY_CENTRED_NON_ROTATING: return selected.name[0] + "CI"; case FrameType.BARYCENTRIC_ROTATING: if (selected.is_root()) { throw Log.Fatal("Naming barycentric rotating frame of root body"); } else { return selected.referenceBody.name[0] + (selected.name[0] + "B"); } default: throw Log.Fatal("Unexpected type " + type.ToString()); } }
private void Parse() { var strings = FinalString.Split(' '); ThisFrameType = Util.FrameTypeFromString(strings[0]); Channel = Int32.Parse(strings[1]); MessageNo = Int32.Parse(strings[2]); More = Util.IsMoreIndicator(strings[3]); SequenceNo = UInt32.Parse(strings[4]); Size = Int32.Parse(strings[5]); if (ThisFrameType == FrameType.Answer) { AnswerNo = Int32.Parse(strings[6]); } }
public FrameInfo(FrameType type, float timestamp, int mostDetailedMip, int colorDiffThreshold, int width, int height, int mouseX, int mouseY) { Type = type; Timestamp = timestamp; MostDetailedMip = mostDetailedMip; ColorDiffThreshold = colorDiffThreshold; OriginalWidth = width; OriginalHeight = height; MouseX = mouseX; MouseY = mouseY; AlignedWidth = AlignDimension(width); AlignedHeight = AlignDimension(height); UncompressedSize = CalculateUncompressedSize(AlignedWidth, AlignedHeight, mostDetailedMip); }
public Frame(FrameType frameType, byte[] bytes) { Type = frameType; IsValid = true; FrameLenght = FrameHeadSize + bytes.Length; frameStream.Write(BeginFrame, 0, BeginFrame.Length); var typeBytes = BitConverter.GetBytes((int)frameType); frameStream.Write(typeBytes, 0, typeBytes.Length); var frameLenght = BitConverter.GetBytes(bytes.Length); frameStream.Write(frameLenght, 0, frameLenght.Length); frameStream.Write(bytes, 0, bytes.Length); }
public static void ProcessFrame(FrameType frameType, byte[] data, Action<string> onMessage, Action onClose) { switch (frameType) { case FrameType.Close: onClose(); break; case FrameType.Binary: case FrameType.Text: onMessage(Encoding.UTF8.GetString(data)); break; default: FleckLog.Debug("Recieved unhandled " + frameType); break; } }
public byte[] EncodePayload(byte[] payload, FrameType frametype) { int length = payload.Length; byte[] encoded = new byte[length + 5]; var chk = Checksum(payload, 0, length); encoded[0] = PACKETSTARTCODE; encoded[1] = (byte)frametype; encoded[2] = (byte)length; int i = 0; for (i = 0; i < length; i++) { encoded[i + 3] = payload[i]; } encoded[i + 3] = (byte)(chk % 256); encoded[i + 4] = (byte)(chk / 256); return encoded; }
public CsmDataFrame(CAN.DataFrame CanDataFram) { Address = (ushort)(CanDataFram.ID >> 3 & 0x1F); if ((CanDataFram.ID & 0x07) != 1) { this._type = (FrameType)(CanDataFram.ID & 0x07); } else { throw new Exception(string.Format("帧类型错误!\nID:{0}\nData:{1}", CanDataFram.ID.ToString(),BitConverter.ToString(CanDataFram.Date))); } Data = CanDataFram.Date; _prority = (FramePrority)(CanDataFram.ID>>8 & 0x1); _feature = (FrameFeature)(CanDataFram.ID>>9 &0x1); _direction = (FrameDirection)(CanDataFram.ID>>10 &0x1); }
public Frame(int _index, int[] _scores) { if(_scores.Length != 2 && _scores.Length != 3) { throw new Exception("Frame must have either 2 or 3 rolls."); } else { index = _index; scores = _scores; if(scores.Length == 3) { type = FrameType.final; } else if(scores[0] == 10) { type = FrameType.strike; } else if (scores[0]+scores[1] == 10) { type = FrameType.spare; } else { type = FrameType.open; } } }
/// <summary> /// 构造函数 /// </summary> public CsmDataFrame(ushort address, byte[] data, FrameDirection direction = FrameDirection.Send, FrameFeature feature = FrameFeature.independ, FrameType type = FrameType.OneIndependFrame, FramePrority prority = FramePrority.Low) { try { Address = address; Data = data; _direction = direction; _feature = feature; _type = type; _prority = prority; } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.ToString(), "错误:", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }
protected virtual void OnFrameTypeChanged(FrameType oldValue, FrameType newValue) { this.UpdateSizeFromRadius(); }
public void SetFrameType(FrameType type) { Frame f = (Frame)Frontend; switch (type) { case FrameType.Custom: if (!(Widget is HeaderBox)) { HeaderBox box = new HeaderBox(); box.Show(); box.BackgroundColor = UsingCustomBackgroundColor ? (Color?)BackgroundColor : null; box.SetMargins((int)f.BorderWidthTop, (int)f.BorderWidthBottom, (int)f.BorderWidthLeft, (int)f.BorderWidthRight); box.SetPadding((int)f.Padding.Top, (int)f.Padding.Bottom, (int)f.Padding.Left, (int)f.Padding.Right); if (borderColor != null) { box.SetBorderColor(borderColor.Value); } var c = paddingAlign != null ? paddingAlign.Child : Widget.Child; if (c != null) { ((Gtk.Container)c.Parent).Remove(c); box.Add(c); } Widget = box; if (paddingAlign != null) { paddingAlign.Destroy(); paddingAlign = null; } } break; case FrameType.WidgetBox: if (!(Widget is Gtk.Frame)) { var c = Widget.Child; if (c != null) { Widget.Remove(c); } Gtk.Frame gf = new Gtk.Frame(); if (!string.IsNullOrEmpty(label)) { gf.Label = label; } if (f.Padding.HorizontalSpacing != 0 || f.Padding.VerticalSpacing != 0) { paddingAlign = new Gtk.Alignment(0, 0, 1, 1); paddingAlign.Show(); UreatePaddingAlign(f.Padding.Top, f.Padding.Bottom, f.Padding.Left, f.Padding.Right); if (c != null) { paddingAlign.Add(c); } gf.Add(paddingAlign); } else { if (c != null) { gf.Add(c); } } gf.Show(); Widget = gf; } break; } }
public instruction(long delay, FrameType frameType, byte[] body) : this(delay, (int)frameType, body) { }
public void Deserialize(IXunitSerializationInfo info) { Name = info.GetValue <string>("name"); Bytes = info.GetValue <byte[]>("bytes"); FrameType = info.GetValue <FrameType>("frameType"); }
public override bool GetTransformOutputTypes(FrameType inType, ArrayList outTypes) { outTypes.Add(new FrameType(MediaSubtypes.Y800, inType.Width, inType.Height)); return(true); }
public bool HandleShortcuts() { bool bShiftDown = Input.GetKey(KeyCode.LeftShift); bool bCtrlDown = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl); // ESCAPE CLEARS ACTIVE TOOL OR SELECTION if (Input.GetKeyUp(KeyCode.Escape)) { if (context.ToolManager.HasActiveTool(0) || context.ToolManager.HasActiveTool(1)) { OGActions.CancelCurrentTool(); } else if (context.Scene.Selected.Count > 0) { context.Scene.ClearSelection(); } return(true); // ENTER AND LETTER A APPLY CURRENT TOOL IF POSSIBLE } else if (Input.GetKeyUp(KeyCode.Return) || Input.GetKeyUp(KeyCode.A)) { if (OGActions.CanAcceptCurrentTool()) { OGActions.AcceptCurrentTool(); } return(true); } else if (Input.GetKeyUp(KeyCode.T)) { //RMSTests.TestIsoCurve(); return(true); } else if (Input.GetKeyUp(KeyCode.Delete)) { if (context.Scene.Selected.Count == 1) { DeleteSOChange change = new DeleteSOChange() { scene = context.Scene, so = context.Scene.Selected[0] }; context.Scene.History.PushChange(change, false); } return(true); // CENTER TARGET (??) } else if (Input.GetKeyUp(KeyCode.C)) { Ray3f cursorRay = context.MouseController.CurrentCursorWorldRay(); AnyRayHit hit = null; if (context.Scene.FindSceneRayIntersection(cursorRay, out hit)) { context.ActiveCamera.Manipulator().ScenePanFocus(context.Scene, context.ActiveCamera, hit.hitPos, true); } return(true); // TOGGLE FRAME TYPE } else if (Input.GetKeyUp(KeyCode.F)) { FrameType eCur = context.TransformManager.ActiveFrameType; context.TransformManager.ActiveFrameType = (eCur == FrameType.WorldFrame) ? FrameType.LocalFrame : FrameType.WorldFrame; return(true); } else if (Input.GetKeyUp(KeyCode.D)) { return(true); // VISIBILITY (V HIDES, SHIFT+V SHOWS) } else if (Input.GetKeyUp(KeyCode.V)) { // show/hide (should be abstracted somehow?? instead of directly accessing GOs?) if (bShiftDown) { foreach (SceneObject so in context.Scene.SceneObjects) { so.RootGameObject.Show(); } } else { foreach (SceneObject so in context.Scene.Selected) { so.RootGameObject.Hide(); } context.Scene.ClearSelection(); } return(true); // UNDO } else if (bCtrlDown && Input.GetKeyUp(KeyCode.Z)) { context.Scene.History.InteractiveStepBack(); return(true); // REDO } else if (bCtrlDown && Input.GetKeyUp(KeyCode.Y)) { context.Scene.History.InteractiveStepForward(); return(true); } else if (Input.GetKeyUp(KeyCode.Backspace)) { if (OG.IsInState(OGWorkflow.SocketState) && OG.CanTransitionToState(OGWorkflow.RectifyState)) { OG.TransitionToState(OGWorkflow.RectifyState); OG.Leg.SetOpWidgetVisibility(true); } return(true); } else if (Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow)) { float sign = Input.GetKeyUp(KeyCode.UpArrow) ? 1 : -1; if (OG.LastActiveModelingOp != null) { if (OG.LastActiveModelingOp is PlaneBandExpansionOp) { PlaneBandExpansionOp deform = OG.LastActiveModelingOp as PlaneBandExpansionOp; deform.BandDistance = MathUtil.Clamp(deform.BandDistance + sign * 2.0f, 10.0f, 1000.0f); } if (OG.LastActiveModelingOp is EnclosedRegionSmoothOp) { EnclosedRegionSmoothOp deform = OG.LastActiveModelingOp as EnclosedRegionSmoothOp; deform.OffsetDistance += sign * 0.1f; } } return(true); } else if (Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow)) { float sign = Input.GetKeyUp(KeyCode.RightArrow) ? 1 : -1; if (OG.LastActiveModelingOp != null) { if (OG.LastActiveModelingOp is PlaneBandExpansionOp) { PlaneBandExpansionOp deform = OG.LastActiveModelingOp as PlaneBandExpansionOp; deform.PushPullDistance += sign * 0.25f; } if (OG.LastActiveModelingOp is EnclosedRegionOffsetOp) { EnclosedRegionOffsetOp deform = OG.LastActiveModelingOp as EnclosedRegionOffsetOp; deform.PushPullDistance += sign * 0.25f; } if (OG.LastActiveModelingOp is EnclosedRegionSmoothOp) { EnclosedRegionSmoothOp deform = OG.LastActiveModelingOp as EnclosedRegionSmoothOp; deform.SmoothAlpha += sign * 0.1f; } } else if (bCtrlDown && bShiftDown && OG.Model.HasSocket()) { int debug = OG.Socket.DeviceGenerator.DebugStep; if (debug == int.MaxValue) { debug = 0; } else { debug = MathUtil.Clamp(debug + (int)sign, 0, 10); } OG.Socket.DeviceGenerator.DebugStep = debug; } return(true); } else if (Input.GetKeyUp(KeyCode.LeftBracket) || Input.GetKeyUp(KeyCode.RightBracket)) { SculptCurveTool tool = OG.ActiveToolAs <SculptCurveTool>(); if (tool != null) { float fSign = Input.GetKeyUp(KeyCode.LeftBracket) ? -1 : 1; double fRadiusS = tool.Radius.SceneValue; fRadiusS = MathUtil.Clamp(fRadiusS + 2.5 * fSign, 5.0, 100.0); tool.Radius = fDimension.Scene(fRadiusS); } return(true); // REDO } else if (Input.GetKeyUp(KeyCode.M)) { if (OG.IsInState(OGWorkflow.ScanState)) { context.Scene.Select(OG.Scan.SO, true); } else if (OG.IsInState(OGWorkflow.RectifyState)) { context.Scene.Select(OG.Leg.SO, true); } if (context.Scene.Selected.Count > 0) { context.ToolManager.SetActiveToolType(TwoPointMeasureTool.Identifier, 0); context.ToolManager.ActivateTool(0); } return(true); } else if (Input.GetKeyUp(KeyCode.L)) { OGActions.AddLengthenOp(); return(true); } else if (Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.R)) { OGSerializer serializer = new OGSerializer(); if (Input.GetKeyUp(KeyCode.R)) { serializer.RestoreToCurrent("c:\\scratch\\OGSCENE.txt"); } else { serializer.StoreCurrent("c:\\scratch\\OGSCENE.txt"); } return(true); } else { return(false); } }
public void commitFrame(FrameType frameType) { _frames[frameType].commit(); }
public void GetData(int typeId) { FrameType type = (FrameType)typeId; byte[] ToDecode; byte[] Decoded; /*Log.Invoke(new EventHandler(delegate * { * Log.AppendText("get frame " + type +"\n"); * }));*/ switch (type) { case FrameType.MSG: #region MSG if (IsConnected()) { int n = Port.BytesToRead; byte[] msgByteBuffer = new byte[n]; Port.Read(msgByteBuffer, 0, n); //считываем сообщение string Message = Encoding.Default.GetString(msgByteBuffer); Log.Invoke(new EventHandler(delegate { Log.AppendText("(" + Port.PortName + ") GetData: новое сообщение > " + Message + "\n"); })); WriteData(null, FrameType.ACK); } else { WriteData(null, FrameType.RET_MSG); } break; #endregion case FrameType.FILEOK: #region FILEOK if (IsConnected()) { int n = Port.BytesToRead; byte[] msgByteBuffer = new byte[n]; Port.Read(msgByteBuffer, 0, n); //считываем сообщение string Message = Encoding.Default.GetString(msgByteBuffer); Log.Invoke(new EventHandler(delegate { Log.AppendText("[" + DateTime.Now + "]: Получено предложение на прием файла размером: " + Message + " байт\n"); })); //SuccessfulFrameNumber = int.Parse(Message); int Message_num = int.Parse(Message); double fileSize = Math.Round((double)Message_num / 1024, 3); if (MessageBox.Show("Получено предложение на прием файла. Размер: " + fileSize.ToString() + " Кбайт.\nПринять?", "Прием файла", MessageBoxButtons.YesNo) == DialogResult.Yes) { WriteData("OK", FrameType.ACK); b_ChooseFile.Invoke(new EventHandler(delegate { b_ChooseFile.Enabled = false; })); } } else { MessageBox.Show("Нет соединения!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; #endregion case FrameType.FILE: while ((!IsConnected()) && (BreakConnection)) { Port.DiscardInBuffer(); Log.Invoke(new EventHandler(delegate { Log.AppendText( "[" + DateTime.Now + "]: " + "Ожидание файла..." + "\r\n"); Log.ScrollToCaret(); Thread.Sleep(1000); })); } #region FILE if (IsConnected()) { byte fileId = (byte)Port.ReadByte(); string typeFile = TypeFileAnalysis(fileId); byte[] size = new byte[sizeLenght]; Port.Read(size, 0, sizeLenght); int ssize = (int)Double.Parse(Encoding.Default.GetString(size)); byte[] byte_NumOfFrames = new byte[NumOfFrameLenght]; Port.Read(byte_NumOfFrames, 0, NumOfFrameLenght); int NumOfFrames = (int)Double.Parse(Encoding.Default.GetString(byte_NumOfFrames)); ProgressBar.Invoke(new EventHandler(delegate { ProgressBar.Visible = true; ProgressBar.Maximum = NumOfFrames; })); byte[] byte_FrameNumber = new byte[NumOfFrameLenght]; Port.Read(byte_FrameNumber, 0, NumOfFrameLenght); int FrameNumber = (int)Double.Parse(Encoding.Default.GetString(byte_FrameNumber)); if (FrameNumber == 1) { file_buffer = new byte[NumOfFrames * (Port.WriteBufferSize - 27)]; } Log.Invoke(new EventHandler(delegate { Log.AppendText( "[" + DateTime.Now + "]: " + "Загружен кадр " + FrameNumber.ToString() + "\r\n"); Log.ScrollToCaret(); })); int n = Port.WriteBufferSize - InfoLen; byte[] newPart = new byte[n]; Port.Read(newPart, 0, n); newPart.CopyTo(file_buffer, n * (FrameNumber - 1)); if (ProgressBar.Value != FrameNumber) { ProgressBar.Invoke(new EventHandler(delegate { ProgressBar.Value++; })); } WriteData(FrameNumber.ToString(), FrameType.FRAME); if (FrameNumber == NumOfFrames) { Decoded = new byte[ssize]; ToDecode = new byte[2]; for (int i = 0; i < ssize; i++) { ToDecode[0] = file_buffer[i * 2]; ToDecode[1] = file_buffer[(i * 2) + 1]; Decoded[i] = Hamming.Decode(ToDecode); } Log.Invoke(new EventHandler(delegate { Log.AppendText( "[" + DateTime.Now + "]: " + "Файл успешно получен" + "\r\n"); Log.ScrollToCaret(); b_ChooseFile.Enabled = true; })); SaveFileDialog saveFileDialog = new SaveFileDialog(); MainForm.Invoke(new EventHandler(delegate { saveFileDialog.FileName = ""; saveFileDialog.Filter = "TypeFile (*." + typeFile + ")|*." + typeFile + "|All files (*.*)|*.*"; if (DialogResult.OK == saveFileDialog.ShowDialog()) { File.WriteAllBytes(saveFileDialog.FileName, Decoded); //WriteData(null, FrameType.ACK); Log.Invoke(new EventHandler(delegate { Log.AppendText( "[" + DateTime.Now + "]: " + "Файл сохранен" + "\r\n"); Log.ScrollToCaret(); b_ChooseFile.Enabled = true; })); } else { // MessageBox.Show("Отмена "); Log.Invoke(new EventHandler(delegate { Log.AppendText( "[" + DateTime.Now + "]: " + "Вы не сохранили файл" + "\r\n"); Log.ScrollToCaret(); })); } })); ProgressBar.Invoke(new EventHandler(delegate { ProgressBar.Value = 0; })); } } else { WriteData(null, FrameType.ERR_FILE); } break; #endregion //====================================================== case FrameType.ACK: #region ACK WriteData(FilePath, FrameType.FILE); break; #endregion case FrameType.RET_MSG: #region RET_MSG Log.AppendText("Ошибка отправки! Нет соединения\n"); break; #endregion case FrameType.ERR_FILE: #region RET_FILE Log.AppendText("Ошибка отправки файла! Нет соединения\n"); break; #endregion } }
public override string ToString() { var bld = new StringBuilder(); if ((byte)FrameType < 0x7F) { bld.AppendFormat("\r\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\n"); } else { bld.AppendFormat("\r\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\r\n"); } bld.AppendFormat("Frame Type \t: {0}\r\n", FrameType.ToString()); if (FrameType == FrameTypes.RxModemStatus) { bld.AppendFormat("Modem Status \t: {0}\r\n", ModemStatus.ToString()); } if (FrameType == FrameTypes.RxTransmitStatus) { bld.AppendFormat("Retry Count \t: {0}\r\n", TransmitRetryCount); bld.AppendFormat("Transmit Status \t: {0}\r\n", DeliveryStatus); bld.AppendFormat("Discovery Status \t: {0}\r\n", DiscoveryStatus); } if (FrameType == FrameTypes.TxATCommand) { bld.AppendFormat("AT Command \t: {0}\r\n", ATCommandString); WritePayload(bld); } if (FrameType == FrameTypes.RxAtCommandResponse) { bld.AppendFormat("AT Command \t: {0}\r\n", ATCommandString); bld.AppendFormat("Sending Frame Id \t: {0}\r\n", FrameId); bld.AppendFormat("AT Status \t: {0}\r\n", ATCommandStatus); WritePayload(bld); } if (FrameType == FrameTypes.RxReceivePacket) { bld.AppendFormat("Length \t: {0}\r\n", FormatHex(Length)); bld.AppendFormat("Payload Length \t: {0}\r\n", FormatHex(Convert.ToUInt16(Length - 17))); bld.AppendFormat("Dest 64 Bit Addr \t: {0}\r\n", FormatHex(DestinationAddress64Bit)); bld.AppendFormat("Dest 16 Bit Addr \t: {0}\r\n", FormatHex(DestinationAddress16Bit)); bld.AppendFormat("Source End Point \t: {0:X2}\r\n", SourceEndPoint); bld.AppendFormat("Dest End Point \t: {0:X2}\r\n", DestinationEndPoint); bld.AppendFormat("Cluster ID \t: {0}\r\n", FormatHex(ClusterId)); bld.AppendFormat("Profile ID \t: {0}\r\n", FormatHex(ProfileId)); bld.AppendFormat("Receive Options \t: {0:X2}\r\n", ReceiveOptions); WritePayload(bld); } if (FrameType == FrameTypes.TxExplicitAddressCommand) { bld.AppendFormat("Frame ID \t: {0:X2}\r\n", FrameId); bld.AppendFormat("Dest 64 Bit Addr \t: {0}\r\n", FormatHex(DestinationAddress64Bit)); bld.AppendFormat("Dest 16 Bit Addr \t: {0}\r\n", FormatHex(DestinationAddress16Bit)); bld.AppendFormat("Source End Point \t: {0:X2}\r\n", SourceEndPoint); bld.AppendFormat("Dest End Point \t: {0:X2}\r\n", DestinationEndPoint); bld.AppendFormat("Cluster ID \t: {0}\r\n", FormatHex(ClusterId)); bld.AppendFormat("Profile ID \t: {0}\r\n", FormatHex(ProfileId)); bld.AppendFormat("Broadcast Radius \t: {0:X2}\r\n", BroadcastRadius); bld.AppendFormat("Transmit Options \t: {0:X2}\r\n", Options); bld.AppendFormat("Check Sum \t: {0:X2}\r\n", CheckSum); WritePayload(bld); } if ((byte)FrameType < 0x7F) { bld.AppendFormat(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\r\n"); } else { bld.AppendFormat("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\r\n"); } bld.Append("\r\n"); return(bld.ToString()); }
public IConditionBuilder Has(FrameType frameType) => CreateCondition(This, o => $"{o} has frame type {frameType}");
public void WriteData(string input, FrameType type) { byte[] Header = { STARTBYTE, (byte)type }; byte[] fileId = { 0 }; byte[] size; byte[] NumOfFrames; byte[] FrameNumber; byte[] BufferToSend; byte[] Telegram; string Telegram_s; string size_s; byte[] ByteToEncode; byte[] ByteEncoded; switch (type) { case FrameType.ERR_FILE: break; case FrameType.MSG: #region MSG if (IsConnected()) { // Telegram[] = Coding(input); Telegram = Encoding.Default.GetBytes(input); //потом это кыш BufferToSend = new byte[Header.Length + Telegram.Length]; //буфер для отправки = заголовок+сообщение Header.CopyTo(BufferToSend, 0); Telegram.CopyTo(BufferToSend, Header.Length); Port.Write(BufferToSend, 0, BufferToSend.Length); Log.AppendText("(" + Port.PortName + ") WriteData: sent message > " + Encoding.Default.GetString(Telegram) + "\n"); } break; #endregion case FrameType.ACK: #region ACK if (IsConnected()) { // Telegram[] = Coding(input); Telegram = Encoding.Default.GetBytes(input); //потом это кыш BufferToSend = new byte[Header.Length + Telegram.Length]; //буфер для отправки = заголовок+сообщение Header.CopyTo(BufferToSend, 0); Telegram.CopyTo(BufferToSend, Header.Length); Port.Write(BufferToSend, 0, BufferToSend.Length); Telegram_s = Encoding.Default.GetString(Telegram); //Log.AppendText("[" + DateTime.Now + "] Отправлено ACK согласие на принятие файла: " + Telegram_s + "\n"); } break; #endregion case FrameType.FILEOK: #region FILEOK if (IsConnected()) { ByteToEncode = File.ReadAllBytes(input); FilePath = input; size = new byte[sizeLenght]; size = Encoding.Default.GetBytes(((double)ByteToEncode.Length).ToString()); //нужны байты //Telegram = Encoding.Default.GetBytes(size); //потом это кыш BufferToSend = new byte[Header.Length + size.Length]; //буфер для отправки = заголовок+сообщение Header.CopyTo(BufferToSend, 0); size.CopyTo(BufferToSend, Header.Length); Port.Write(BufferToSend, 0, BufferToSend.Length); size_s = Encoding.Default.GetString(size); Log.AppendText("[" + DateTime.Now + "] Отправлена информация о размере файла: " + size_s + " байт\n"); //SuccessfulFrameNumber = int.Parse(Telegram_s); } break; #endregion case FrameType.FRAME: #region FRAME if (IsConnected()) { // Telegram[] = Coding(input); Telegram = Encoding.Default.GetBytes(input); //потом это кыш BufferToSend = new byte[Header.Length + Telegram.Length]; //буфер для отправки = заголовок+сообщение Header.CopyTo(BufferToSend, 0); Telegram.CopyTo(BufferToSend, Header.Length); Port.Write(BufferToSend, 0, BufferToSend.Length); Telegram_s = Encoding.Default.GetString(Telegram); //Log.AppendText("[" + DateTime.Now + "] Получен кадр " + Telegram_s + " .Отправлено подтверждение о получении\n"); //SuccessfulFrameNumber = int.Parse(Telegram_s); } else { Log.Invoke(new EventHandler(delegate { Log.AppendText("[" + DateTime.Now + "]: Передача файла нарушена."); })); //MessageBox.Show("Соединение прервано. Передача нарушена.4"); BreakConnection = true; break; } break; #endregion case FrameType.FILE: #region FILE int i; int parts = 0; int EncodedByteIndex; int Part_ByteEncodedIndex; ByteEncoded = new byte[0]; size = new byte[0]; NumOfFrames = new byte[0]; if (IsConnected()) { ByteToEncode = File.ReadAllBytes(@FilePath); //b_ChooseFile.Invoke(new EventHandler(delegate //{ // b_ChooseFile.Enabled = false; //})); b_ChooseFile.Invoke(new EventHandler(delegate { b_ChooseFile.Enabled = false; })); size = new byte[sizeLenght]; size = Encoding.Default.GetBytes(((double)ByteToEncode.Length).ToString()); //нужны байты //WriteData(Encoding.Default.GetString(size), FrameType.FILEOK); NumOfFrames = new byte[NumOfFrameLenght]; FrameNumber = new byte[NumOfFrameLenght]; string typeFile = @input.Split('.')[1]; fileId[0] = TypeFile_to_IdFile(typeFile); ByteEncoded = new byte[ByteToEncode.Length * 2]; for (i = 0; i < ByteToEncode.Length; i++) { Hamming.HammingEncode74(ByteToEncode[i]).CopyTo(ByteEncoded, i * 2); } if (ByteEncoded.Length + InfoLen < Port.WriteBufferSize) { BufferToSend = new byte[InfoLen + ByteEncoded.Length]; Header.CopyTo(BufferToSend, 0); fileId.CopyTo(BufferToSend, Header.Length); size.CopyTo(BufferToSend, Header.Length + fileId.Length); NumOfFrames = Encoding.Default.GetBytes(1.ToString()); NumOfFrames.CopyTo(BufferToSend, Header.Length + fileId.Length + sizeLenght); FrameNumber = Encoding.Default.GetBytes(1.ToString()); FrameNumber.CopyTo(BufferToSend, Header.Length + fileId.Length + sizeLenght + NumOfFrameLenght); ByteEncoded.CopyTo(BufferToSend, InfoLen); bool flag = false; while (!flag) { if (MessageBox.Show("Отправить?", "Файл", MessageBoxButtons.YesNo) == DialogResult.Yes) { flag = true; Port.Write(BufferToSend, 0, BufferToSend.Length); //loading.Hide(); MessageBox.Show("Готово!"); //loading.progressBar1.Value = 0; //loading.i = 1; } else { flag = true; //loading.Hide(); //loading.progressBar1.Value = 0; MessageBox.Show("Вы отменили передачу файла."); // loading.i = 1; } } } else { //EncodedByteIndex; //Part_ByteEncodedIndex; parts = (int)Math.Ceiling((double)ByteEncoded.Length / (double)(Port.WriteBufferSize - InfoLen)); ProgressBar.Invoke(new EventHandler(delegate { ProgressBar.Visible = true; ProgressBar.Maximum = parts; })); NumOfFrames = Encoding.Default.GetBytes(parts.ToString()); for (i = 0; i < parts; i++) { EncodedByteIndex = i * (Port.WriteBufferSize - InfoLen); Part_ByteEncodedIndex = (Port.WriteBufferSize - InfoLen); byte[] Part_ByteEncoded = new byte[Part_ByteEncodedIndex]; int Part_Len = 0; if (((ByteEncoded.Length - EncodedByteIndex) >= Part_ByteEncodedIndex)) { Part_Len = Part_ByteEncodedIndex; } else if (ByteEncoded.Length - EncodedByteIndex > 0) { Part_Len = ByteEncoded.Length - i * (Port.WriteBufferSize - InfoLen); } BufferToSend = new byte[Port.WriteBufferSize]; Header.CopyTo(BufferToSend, 0); fileId.CopyTo(BufferToSend, Header.Length); size.CopyTo(BufferToSend, Header.Length + fileId.Length); NumOfFrames.CopyTo(BufferToSend, Header.Length + fileId.Length + sizeLenght); FrameNumber = Encoding.Default.GetBytes((i + 1).ToString()); FrameNumber.CopyTo(BufferToSend, Header.Length + fileId.Length + sizeLenght + NumOfFrameLenght); Array.ConstrainedCopy(ByteEncoded, EncodedByteIndex, BufferToSend, InfoLen, Part_Len); //Log.AppendText("[" + DateTime.Now + "]: Отправляется фрейм: " + (SuccessfulFrameNumber + 1).ToString() + "\n"); if (IsConnected()) { Port.Write(BufferToSend, 0, BufferToSend.Length); } Log.Invoke(new EventHandler(delegate { Log.AppendText("[" + DateTime.Now + "]: Отправка кадра " + (i + 1).ToString() + "\n"); Log.ScrollToCaret(); })); if (ProgressBar.Value != parts) { ProgressBar.Invoke(new EventHandler(delegate { ProgressBar.Value++; })); } byte[] ByteCheck = new byte[1]; if (i > 0 && IsConnected()) { //Thread.Sleep(10); int WaitTime = 0; try { Port.Read(ByteCheck, 0, 1); } catch (Exception e) { Log.AppendText(e.Message); break; } while (ByteCheck[0] != STARTBYTE) { if (WaitTime <= 100) { Thread.Sleep(10); WaitTime += 10; Port.Read(ByteCheck, 0, 1); } else { MessageBox.Show("Передача файла прервана"); break; } } if (IsConnected()) { continue; } Port.Read(ByteCheck, 0, 1); if (ByteCheck[0] == (int)FrameType.FRAME) { int n = FrameNumber.Length;//Port.BytesToRead; byte[] msgByteBuffer = new byte[n]; Port.Read(msgByteBuffer, 0, n); //считываем сообщение string Message = Encoding.Default.GetString(msgByteBuffer); //Log.Invoke(new EventHandler(delegate //{ // Log.AppendText("[" + DateTime.Now + "] Получено подтверждение об успешной доставке кадра " + Message + "\n"); //})); SuccessfulFrameNumber = int.Parse(Message); } if (i == SuccessfulFrameNumber) { continue; } //if (i != SuccessfulFrameNumber) //{ // MessageBox.Show("Передача файла нарушена.1"); // break; //} } if (!IsConnected()) { Log.Invoke(new EventHandler(delegate { Log.AppendText("[" + DateTime.Now + "]: Передача файла нарушена\n"); })); DialogResult result; while (!IsConnected()) { result = MessageBox.Show("Соединение прервано. Передача нарушена.\n" + "Восстановите соединение и нажмите ОК для докачки файла.\n" + "Иначе нажмите ОТМЕНА.", "Ошибка", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (result == DialogResult.Cancel) { Log.Invoke(new EventHandler(delegate { Log.AppendText("[" + DateTime.Now + "]: Передача файла отменена\n"); })); ProgressBar.Invoke(new EventHandler(delegate { ProgressBar.Value = 0; })); return; } } //BreakConnection = true; i = SuccessfulFrameNumber - 1; //break; } } Log.Invoke(new EventHandler(delegate { Log.AppendText("[" + DateTime.Now + "]: Файл успешно передан\n"); })); ProgressBar.Invoke(new EventHandler(delegate { ProgressBar.Value = 0; })); b_ChooseFile.Invoke(new EventHandler(delegate { b_ChooseFile.Enabled = true; })); } } else { Log.Invoke(new EventHandler(delegate { Log.AppendText("[" + DateTime.Now + "]: Передача файла нарушена.\n" + "Последний успешный фрейм: " + SuccessfulFrameNumber.ToString()); })); //MessageBox.Show("Соединение прервано. Передача нарушена.3"); BreakConnection = true; break; } break; #endregion default: if (IsConnected()) { Port.Write(Header, 0, Header.Length); } break; } //Зачем такая конструкция? //Log.Invoke(new EventHandler(delegate //{ // Log.AppendText("sent frame " + type + "\n"); //всё записываем, мы же снобы //})); }
private void ProcessReceivedBytes(byte[] buffer, int offset, int bytesTransferred) { while (bytesTransferred > 0) { if (!_handshakeCompleted) { var flags = (FrameFlags)buffer[offset]; if ((flags & FrameFlags.ErrorFrame) != 0) { _frameType = FrameType.Error; _handshakeCompleted = true; continue; } var isCompleted = _handshakeFrame.Read(buffer, ref offset, ref bytesTransferred); if (!isCompleted) { return; } HandshakeReceived(this, new HandshakeFrameReceivedEventArgs(_handshakeFrame)); _handshakeFrame.ResetRead(); continue; } switch (_frameType) { case FrameType.Unknown: var flags = (FrameFlags)buffer[offset]; if ((flags & FrameFlags.ErrorFrame) != 0) { _frameType = FrameType.Error; } if ((flags & FrameFlags.ExtensionFrame) != 0) { _frameType = FrameType.Extension; } else if ((flags & FrameFlags.CommandFrame) != 0) { _frameType = FrameType.Command; } else { _frameType = FrameType.Message; } //do not increase offset, let the frame handle the flags. //only peek it to be able to switch state break; case FrameType.Message: var isCompleted = _inboundMessage.Read(buffer, ref offset, ref bytesTransferred); if (isCompleted) { MessageFrameReceived(_inboundMessage); _inboundMessage.ResetRead(); _frameType = FrameType.Unknown; } break; case FrameType.Error: var isCompleted1 = _errorFrame.Read(buffer, ref offset, ref bytesTransferred); if (!isCompleted1) { Fault(this, new FaultExceptionEventArgs(_errorFrame.ErrorMessage, new RemoteEndPointException(_errorFrame.ErrorMessage))); Close(); } break; case FrameType.Extension: var isCompleted2 = _extensionFrameProcessor.Read(buffer, ref offset, ref bytesTransferred); if (isCompleted2) { _frameType = FrameType.Unknown; } break; } } }
public static int encounterSlot(uint result, FrameType frameType, EncounterType encounterType) { return(encounterSlot(result, frameType, encounterType, false)); }
public AnimationFrame(FrameType type, int value1, int value2) { this.type = type; this.value1 = value1; this.value2 = value2; }
/// <summary> /// Inserts a recorded frame into the specified frame index. This can be useful if you want to add frames into the recording that shouldn't be placed last. Use FrameCount() to determine how many frames you currently have. /// </summary> /// <param name="frame">The index of where the frame should be inserted.</param> /// <param name="frameType">The type of the inserted frame (by default FrameType.Middle).</param> public void InsertOneFrame(int frame, FrameType frameType = FrameType.Middle) { InsertRecFrame(frame, frameType); }
public unsafe extern static ReturnStatus StopFrame(int deviceIndex, FrameType frameType);
public override void OnGet(HttpRequest request, HttpResponse response) { if (request.Upgrade == null || request.Upgrade.Trim().ToLower() != "websocket") { response.Send(); return; } lock (objLock) { if (IsOnSurveillance)//已经用客户端连接了 { response.SetContent("False"); //response.SetContent(JsonConvert.SerializeObject(hit)); //response.SendOnLongConnetion(); response.SendWebsocketData(); response.TcpClient.Close(); return; } } lock (objLock) { IsOnSurveillance = true; } if (request.RestConvention != null) { Log.Debug(string.Format("准备开始布控任务 布控ID{0}", request.RestConvention)); //更具p.restConvention(taskID)进行 //SurveillanceTask task = ; } HitAlertService.response = response; int id = -1; try { id = Convert.ToInt32(request.RestConvention); } catch { return; } if (!Init(id)) //开启监控失败 { Log.Debug("开启布控任务失败"); response.SetContent("False"); response.SendWebsocketData(); response.TcpClient.Close(); IsOnSurveillance = false; return; } ; byte[] buffer = new byte[1024]; FrameType type = FrameType.Continuation; while (type != FrameType.Close) { int length = 0; if (response.TcpClient.Connected) { length = response.TcpClient.Client.Receive(buffer); //等待客户端的数据,主要等待客户端发送关闭数据 } byte[] data = new byte[length]; Array.Copy(buffer, data, length); type = Hybi13Handler.GetFrameType(new List <byte>(data)); //FRSServerHttp.Server.Websocket.Hybi13Handler.ReceiveData(new List<byte>(data), readState); } StopSurveillance(); }
public Frame(FrameType type, int channel) { Type = type; Channel = channel; Payload = null; }
public static string GetString(FrameType type) { return(_enumKeyDictionary[type]); }
private InboundFrame(FrameType type, int channel, byte[] payload) : base(type, channel, payload) { }
public int FramesPerSecond(FrameType frameType) { return(_frames[frameType].getFrameRate()); }
protected SingleFrameConsumer(FrameQueue queue, FrameType frameType) : base(queue, frameType) { _frameType = frameType; }
public OutboundFrame(FrameType type, int channel) : base(type, channel) { m_accumulator = new MemoryStream(); writer = new NetworkBinaryWriter(m_accumulator); }
public instruction(long delay, FrameType frameType, string body) : this(delay, (int)frameType, Encoding.UTF8.GetBytes(body)) { }
public unsafe extern static ReturnStatus GetFrameMode(int deviceIndex, FrameType frameType, out FrameMode pFrameMode);
//every parameter value for frame type except values of FrameType enumeration should throw InvalidFrameTypeException public void GetCommand_ValidFrameTypeParameterForStartGameCommand_ReturnsStartGameCommand([Values] FrameType frameType) { //arrange CommandManager testedCommandManager = new CommandManager(_gameCreatorStub.Object, _manipulatorStub.Object, _historyStub.Object); string[] testInput = { "start", "3", "easy", frameType.ToString() }; //act ICommand returnedCommand = testedCommandManager.GetCommand(testInput); //assert Assert.AreEqual(returnedCommand.GetType(), typeof(StartGameCommand)); }
public Channel(IntermediateNode root) { //Fetch from nodes foreach (LeafNode channelSubNode in root) { if (channelSubNode.Name.Equals("header", StringComparison.OrdinalIgnoreCase)) { ReadHeader(channelSubNode); } else if (channelSubNode.Name.Equals("frames", StringComparison.OrdinalIgnoreCase)) { channelData = channelSubNode.ByteArrayData; } } FrameType frameType = FrameType.Float; QuaternionMethod = QuaternionMethod.Full; bool vec = false; bool quat = false; bool comp = false; bool floats = false; switch (ChannelType) { case BIT_NORM: case 0x50: case 0x40: comp = true; break; case BIT_VEC: case 0x22: vec = true; break; case BIT_QUAT: quat = true; break; case BIT_VEC | BIT_QUAT: vec = true; quat = true; break; case BIT_VEC | BIT_NORM: case BIT_VEC | 0x40: //special case normal? unsure frameType = FrameType.VecWithQuat; QuaternionMethod = QuaternionMethod.HalfAngle; vec = true; comp = true; break; default: floats = true; break; } InterpretedType = frameType; if (Interval == -1) { Times = new FloatAccessor(this, 0); stride += 4; } if (vec) { Positions = new Vector3Accessor(this, stride); stride += 12; } if (quat) { Quaternions = new QuaternionAccessor(this, stride); stride += 16; } if (comp) { Quaternions = new CompressedAccessor(this, stride); stride += 6; } if (floats) { Angles = new FloatAccessor(this, stride); stride += 4; } }
/// <summary> /// Makes the frame fixed. /// </summary> public void DisableMoving() { FrameType frameType = control.SerializationObject as FrameType; if (frameType != null) { //frameType.movable = false; ScriptsType scripts = FrameDesigner.FrameDesignerActionList.GetScripts(frameType, false); if (scripts != null) { if (scripts.Events.ContainsKey(EventChoice.OnMouseDown)) { // Retrieve current OnMouseDown event string currentDown = scripts.Events[EventChoice.OnMouseDown] ?? String.Empty; // Remove the start move snippet from the event handler script currentDown = currentDown.Replace(FrameDesigner.startMoveScript, String.Empty); // If there is no code left, remove the event handler script altogether, update otherwise if (String.IsNullOrEmpty(currentDown)) { scripts.Events.Remove(EventChoice.OnMouseDown); } else { scripts.Events[EventChoice.OnMouseDown] = currentDown; } } if (scripts.Events.ContainsKey(EventChoice.OnMouseUp)) { // Retrieve current OnMouseUp event string currentUp = (scripts.Events[EventChoice.OnMouseUp] ?? String.Empty); // Remvoe the stop move snippet from the event handler sciprt currentUp = currentUp.Replace(FrameDesigner.stopMoveScript, String.Empty); // If there is no code left, remove the event handler script altogether, update otherwise if (String.IsNullOrEmpty(currentUp)) { scripts.Events.Remove(EventChoice.OnMouseUp); } else { scripts.Events[EventChoice.OnMouseUp] = currentUp; } } // Remove the <Scripts> element if no events have handlers now if (scripts.Events.Count == 0) { frameType.Scripts.Remove(scripts); } } // Raise ComponentChangedEvent this.OnComponentChanged(EventArgs.Empty); // Refresh the Designer Action UI designerActionUIService.Refresh(this.Component); } }
public Frame(FrameType type, int channel, byte[] payload) { Type = type; Channel = channel; Payload = payload; }
protected override void ResortGrid(BindingSource bindingSource, DoubleBufferedDataGridView dataGrid, FrameType frameType) { dataGrid.DataSource = bindingSource; bindingSource.ResetBindings(false); }