Ejemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="port">port name, i.e. COM1</param>
 /// <param name="baud">Baud rate for the port. Allowed values depend on the specific port</param>
 /// <param name="dataBits">Number of data bits. Typically 8.</param>
 /// <param name="stopBits"> Stop bits, typically 1</param>
 /// <param name="parity"> Parity, typically none</param>
 /// <param name="flowControl">Flow control, typically none</param>
 public SerialSettings(String port, int baud, int dataBits, int stopBits, Parity parity, FlowControl flowControl)
 {
     this.port = port;
     this.baud = baud;
     this.dataBits = dataBits;
     this.stopBits = stopBits;
     this.parity = parity;
     this.flowControl = flowControl;
 }
Ejemplo n.º 2
0
 private void Awake()
 {
     obstacleControl = GetComponent<ObstacleQueueControl>();
     scoreControl = GetComponent<ScoreControl>();
     timeControl = GetComponent<TimeControl>();
     flowControl = GetComponent<FlowControl>();
     deerLeft = GameObject.Find("DeerLeft");
     deerRight = GameObject.Find("DeerRight");
 }
Ejemplo n.º 3
0
		internal OpCode(string name, Code code, OperandType operandType, FlowControl flowControl, OpCodeType opCodeType, StackBehaviour push, StackBehaviour pop) {
			this.Name = name;
			this.Code = code;
			this.OperandType = operandType;
			this.FlowControl = flowControl;
			this.OpCodeType = opCodeType;
			this.StackBehaviourPush = push;
			this.StackBehaviourPop = pop;
			if (((ushort)code >> 8) == 0)
				OpCodes.OneByteOpCodes[(byte)code] = this;
			else if (((ushort)code >> 8) == 0xFE)
				OpCodes.TwoByteOpCodes[(byte)code] = this;
		}
Ejemplo n.º 4
0
 internal OpCode(string name, byte op1, byte op2, int size, FlowControl flowControl,
     OpCodeType opCodeType, OperandType operandType,
     StackBehaviour pop, StackBehaviour push)
 {
     m_name = name;
     m_op1 = op1;
     m_op2 = op2;
     m_size = size;
     m_flowControl = flowControl;
     m_opCodeType = opCodeType;
     m_operandType = operandType;
     m_stackBehaviourPop = pop;
     m_stackBehaviourPush = push;
 }
Ejemplo n.º 5
0
        internal OpCode(int x, int y)
        {
            m_op1 = (byte)((x >> 0) & 0xff);
            m_op2 = (byte)((x >> 8) & 0xff);
            m_code = (Code)((x >> 16) & 0xff);
            m_flowControl = (FlowControl)((x >> 24) & 0xff);
            m_size = 0;
            m_name = "";

            m_opCodeType = (OpCodeType)((y >> 0) & 0xff);
            m_operandType = (OperandType)((y >> 8) & 0xff);
            m_stackBehaviourPop = (StackBehaviour)((y >> 16) & 0xff);
            m_stackBehaviourPush = (StackBehaviour)((y >> 24) & 0xff);
        }
Ejemplo n.º 6
0
	internal OpCode(String stringname, StackBehaviour pop, StackBehaviour push, OperandType operand, OpCodeType type, int size, byte s1, byte s2, FlowControl ctrl, bool endsjmpblk, int stack)
	{
		m_stringname = stringname;
		m_pop = pop;
		m_push = push;
		m_operand = operand;
		m_type = type;
		m_size = size;
		m_s1 = s1;
		m_s2 = s2;
		m_ctrl = ctrl;
		m_endsUncondJmpBlk = endsjmpblk;
		m_stackChange = stack;

	}
Ejemplo n.º 7
0
	void Awake ()
	{
		//Check if existing instance of class exists in scene
		//If so, then destroy this instance
		if (instance) {
			DestroyImmediate (gameObject);
		} else {
			//Make this active and only instance
			instance = this;
			//Make game manager persistent
			DontDestroyOnLoad (gameObject);

			status = STATUS.START_SCREEN;
			level = 0;
		}
	}
Ejemplo n.º 8
0
	public void InitEvents ()
	{
		fc = FlowControl.Instance;
		lc = LevelControl.Instance;
		sc = ScoreControl.Instance;
		uic = UIControl.Instance;
		dc = DataControl.Instance;
		shootC = GameObject.Find ("Player").GetComponent<ShootingController> ();

		lc.BallsChanged += OnBallsChanged;
		lc.LevelChanged += OnLevelChanged;
		lc.TargetsChanged += OnTargetsChanged;
		sc.ScoreChanged += OnScoreChanged;
		shootC.InitPowerSlider += OnInitPowerSlider;
		shootC.UpdatePowerSlider += OnUpdatePowerSlider;

		string levelKind = dc.GetLevel (fc.Level).Kind;
		if (levelKind.Equals ("T"))
			GameObject.Find ("Player").GetComponent<MoveOnTrails> ().TrailsEndReached += OnTrailsEndReached;
	}
Ejemplo n.º 9
0
	// Construct a new opcode.
	internal OpCode(String name, int value, FlowControl flowControl,
					OpCodeType opcodeType, OperandType operandType,
					StackBehaviour stackPop, StackBehaviour stackPush)
			{
				this.name = name;
				this.value = (short)value;
				this.flowControl = (byte)flowControl;
				this.opcodeType = (byte)opcodeType;
				this.operandType = (byte)operandType;
				if(value < 0x0100)
				{
					this.size = (byte)1;
				}
				else
				{
					this.size = (byte)2;
				}
				this.stackPop = (byte)stackPop;
				this.stackPush = (byte)stackPush;
			}
Ejemplo n.º 10
0
        internal OpCode(string name, byte op1, byte op2, int size,
			Code code, FlowControl flowControl,
			OpCodeType opCodeType, OperandType operandType,
			StackBehaviour pop, StackBehaviour push)
        {
            m_name = name;
            m_op1 = op1;
            m_op2 = op2;
            m_size = size;
            m_code = code;
            m_flowControl = flowControl;
            m_opCodeType = opCodeType;
            m_operandType = operandType;
            m_stackBehaviourPop = pop;
            m_stackBehaviourPush = push;

            if (op1 == 0xff)
                OpCodes.OneByteOpCode [op2] = this;
            else
                OpCodes.TwoBytesOpCode [op2] = this;
        }
Ejemplo n.º 11
0
 //verify the opcode fields
 //if not equal,retun the field name which contains error. 
 private CompareResult CompareOpCode(
     OpCode opcode,
     String stringname,
     StackBehaviour pop,
     StackBehaviour push,
     OperandType operand,
     OpCodeType type,
     int size,
     byte s1,
     byte s2,
     FlowControl ctrl)
 {
     CompareResult returnValue = CompareResult.Equal;
     if (opcode.Name != stringname) returnValue = returnValue | CompareResult.Name;
     if (opcode.StackBehaviourPop != pop) returnValue = returnValue | CompareResult.Pop;
     if (opcode.StackBehaviourPush != push) returnValue = returnValue | CompareResult.Push;
     if (opcode.OperandType != operand) returnValue = returnValue | CompareResult.OpenrandType;
     if (opcode.OpCodeType != type) returnValue = returnValue | CompareResult.OpCodeType;
     if (opcode.Size != size) returnValue = returnValue | CompareResult.Size;
     if (size == 2)
     {
         if (opcode.Value != ((short)(s1 << 8 | s2)))
         {
             returnValue = returnValue | CompareResult.Value;
         }
     }
     else
     {
         if (opcode.Value != ((short)s2))
         {
             returnValue = returnValue | CompareResult.Value;
         }
     }
     if (opcode.FlowControl != ctrl)
     {
         returnValue = returnValue | CompareResult.FlowControl;
     }
     return returnValue;
 }
Ejemplo n.º 12
0
        private void UCFlowControlAction_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            FC = (FlowControl)e.NewValue;


            if (mBfParentRunner != null)
            {
                App.FillComboFromEnumVal(ActionComboBox, FC.BusinessFlowControlAction);
                App.ObjFieldBinding(ActionComboBox, ComboBox.SelectedValueProperty, FC, FlowControl.Fields.BusinessFlowControlAction);
            }
            else
            {
                if (mActParentActivity.GetType() == typeof(ErrorHandler))
                {
                    List <eFlowControlAction> ErrorFlowControlActions = FC.GetFlowControlActionsForErrorAndPopupHandler();

                    App.FillComboFromEnumVal(ActionComboBox, FC.FlowControlAction, ErrorFlowControlActions.Cast <object>().ToList());
                    App.ObjFieldBinding(ActionComboBox, ComboBox.SelectedValueProperty, FC, FlowControl.Fields.FlowControlAction);
                }
                else
                {
                    App.FillComboFromEnumVal(ActionComboBox, FC.FlowControlAction);
                    App.ObjFieldBinding(ActionComboBox, ComboBox.SelectedValueProperty, FC, FlowControl.Fields.FlowControlAction);
                }
            }

            App.ObjFieldBinding(ActionValueTextBox, TextBox.TextProperty, FC, FlowControl.Fields.Value);
            ActionValueTextBox.Init(new Context()
            {
                BusinessFlow = mActParentBusinessFlow
            }, FC, FlowControl.Fields.Value);
            ActionValueTextBox.ValueTextBox.Text = FC.Value;

            SetActionValueComboData();
            ActionValueComboBox.SelectionChanged += ActionValueComboBox_SelectionChanged;
            ActionComboBox.SelectionChanged      += ActionComboBox_SelectionChanged;
        }
Ejemplo n.º 13
0
        public void FlowcontrolTest_WithActivityCreateInstance()
        {
            //Arrange
            Activity activity = new Activity();

            ActUIElement actGotoURL = new ActUIElement();

            actGotoURL.Description = "Launch";

            ActDummy act2 = new ActDummy();

            act2.Description = "WaitForApp";


            FlowControl flowControl = new FlowControl();

            flowControl.Active            = true;
            flowControl.Condition         = "1=1";
            flowControl.FlowControlAction = eFlowControlAction.GoToAction;
            flowControl.Value             = act2.Guid + flowControl.GUID_NAME_SEPERATOR + act2.ItemName;


            actGotoURL.FlowControls.Add(flowControl);


            activity.Acts.Add(actGotoURL);
            activity.Acts.Add(act2);

            act2.Description = "WaitForApp_Copy";

            //Act
            Activity copyActivity  = (Activity)activity.CreateInstance();
            Guid     newGuidOfAct2 = copyActivity.Acts.Where(x => x.ItemName == "WaitForApp_Copy").FirstOrDefault().Guid;

            //Assert
            Assert.AreEqual(copyActivity.Acts[0].FlowControls[0].GetGuidFromValue(), newGuidOfAct2);
        }
Ejemplo n.º 14
0
        private static void ComputeStackSize(Instruction instruction, ref int stack_size)
        {
            FlowControl flowControl = instruction.opcode.FlowControl;

            switch (flowControl)
            {
            case FlowControl.Branch:
            case FlowControl.Break:
                break;

            default:
                switch (flowControl)
                {
                case FlowControl.Return:
                case FlowControl.Throw:
                    break;

                default:
                    return;
                }
                break;
            }
            stack_size = 0;
        }
Ejemplo n.º 15
0
 internal OpCode(string stringname,
                 StackBehaviour pop,
                 StackBehaviour push,
                 OperandType operand,
                 OpCodeType type,
                 int size,
                 byte s1,
                 byte s2,
                 FlowControl ctrl,
                 bool endsjmpblk,
                 int stack)
 {
     m_stringname       = stringname;
     m_pop              = pop;
     m_push             = push;
     m_operand          = operand;
     m_type             = type;
     m_size             = size;
     m_s1               = s1;
     m_s2               = s2;
     m_ctrl             = ctrl;
     m_endsUncondJmpBlk = endsjmpblk;
     m_stackChange      = stack;
 }
Ejemplo n.º 16
0
 void Awake()
 {
     flowControl = GameObject.Find("GameController").GetComponent<FlowControl>();
 }
Ejemplo n.º 17
0
 public bool Open(int baudRate, FlowControl flowControl)
 {
     return(false);
 }
Ejemplo n.º 18
0
 public override sealed void Import(ConfigNode data)
 {
     _port = GUtil.ParseInt(data["port"], 1);
     _baudRate = GUtil.ParseInt(data["baud-rate"], 9600);
     _byteSize = GUtil.ParseByte(data["byte-size"], 8);
     _parity = (Parity)EnumDescAttribute.For(typeof(Parity)).FromName(data["parity"], Parity.NOPARITY);
     _stopBits = (StopBits)EnumDescAttribute.For(typeof(StopBits)).FromName(data["stop-bits"], StopBits.ONESTOPBIT);
     _flowControl = (FlowControl)EnumDescAttribute.For(typeof(FlowControl)).FromName(data["flow-control"], FlowControl.None);
     _transmitDelayPerChar = GUtil.ParseInt(data["delay-per-char"], 0);
     _transmitDelayPerLine = GUtil.ParseInt(data["delay-per-line"], 0);
     base.Import(data);
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Constructs an experimental opcode.
 /// </summary>
 public OpCode(string name, byte first, byte second, OperandType operandType, FlowControl flowControl, StackBehaviour push, StackBehaviour pop)
     : this(name, (Code)((first << 8) | second), operandType, flowControl, OpCodeType.Experimental, push, pop, true)
 {
 }
Ejemplo n.º 20
0
    private bool VerifyAllTheFileds(OpCode opCode, 
                                    String opCodeName, 
                                    StackBehaviour pop, 
                                    StackBehaviour push, 
                                    OperandType operandType, 
                                    OpCodeType type, 
                                    int size, 
                                    byte s1, byte s2, 
                                    FlowControl ctrl, 
                                    string errorNum)
    {
        bool retVal = true;
        string errorDesc;

        string actualName = opCode.Name;
        if (actualName != opCodeName)
        {
            errorDesc = "Actual name of the specified MSIL instruction: \"" + actualName +
                        "\" does not equal expected name: \"" + opCodeName + "\"";
            TestLibrary.TestFramework.LogError( errorNum + ".1", errorDesc);
            retVal = false;
        }

        StackBehaviour actualStackBehaviourPop = opCode.StackBehaviourPop;
        if (actualStackBehaviourPop != pop)
        {
            errorDesc = "Actual pop statck behaviour of the specified MSIL instruction: (" + actualStackBehaviourPop +
                        ") does not equal expected pop stack behaviour: (" + pop + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".2", errorDesc);
            retVal = false;
        }

        StackBehaviour actualStackBehaviourPush = opCode.StackBehaviourPush;
        if (actualStackBehaviourPush != push)
        {
            errorDesc = "Actual push statck behaviour of the specified MSIL instruction: (" + actualStackBehaviourPush +
                        ") does not equal expected push stack behaviour: (" + push + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".3", errorDesc);
            retVal = false;
        }


        OperandType actualOperandType = opCode.OperandType;
        if (actualOperandType != operandType)
        {
            errorDesc = "Actual operand type of the specified MSIL instruction: (" + actualOperandType +
                        ") does not equal expected operand type: (" + operandType + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".4", errorDesc);
            retVal = false;
        }

        OpCodeType actualOpCodeType = opCode.OpCodeType;
        if (actualOpCodeType != type)
        {
            errorDesc = "Actual OpCode type of the specified MSIL instruction: (" + actualOpCodeType +
                        ") does not equal expected OpCode type: (" + type + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".5", errorDesc);
            retVal = false;
        }

        int actualSize = opCode.Size;
        if (actualSize != size)
        {
            errorDesc = "Actual size of the specified MSIL instruction: (" + actualSize +
                        ") does not equal expected size: (" + size + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".6", errorDesc);
            retVal = false;
        }

        short actualValue = opCode.Value;
        short expectedValue = (2 == size) ? (short)(s1 << 8 | s2) : s2;
        if (actualValue != expectedValue)
        {
            errorDesc = "Actual immediate operand value of the specified MSIL instruction: (" + actualValue +
                        ") does not equal expected immediate operand value: (" + expectedValue + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".7", errorDesc);
            retVal = false;
        }

        FlowControl actualCtrl = opCode.FlowControl;
        if (actualCtrl != ctrl)
        {
            errorDesc = "Actual flow control of the specified MSIL instruction: (" + actualCtrl +
                        ") does not equal expected flow control: (" + ctrl + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".8", errorDesc);
            retVal = false;
        }

        return retVal;
    }
Ejemplo n.º 21
0
        public override void Import(ITerminalSettings src) {
            base.Import(src);
            SerialTerminalSettings p = src as SerialTerminalSettings;
            Debug.Assert(p != null);

            _baudRate = p._baudRate;
            _byteSize = p._byteSize;
            _parity = p._parity;
            _stopBits = p._stopBits;
            _flowControl = p._flowControl;
            _transmitDelayPerChar = p._transmitDelayPerChar;
            _transmitDelayPerLine = p._transmitDelayPerLine;
        }
Ejemplo n.º 22
0
 private ExecuteResult(FlowControl flowControl, object data)
     : this(flowControl)
 {
     Data = data;
 }
Ejemplo n.º 23
0
 // Use this for initialization
 void Start()
 {
     crt_state = 1;
     //main_cam = GameObject.Find("Main Camera").GetComponent<Camera>();
     Fc = GameObject.Find("Moniter").GetComponent <FlowControl>();
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Init with custom experiment design parameters
        /// </summary>
        /// <param name="extype"></param>
        /// <param name="expara"></param>
        /// <param name="cond"></param>
        /// <param name="block"></param>
        /// <param name="trial"></param>
        /// <param name="stimuli"></param>
        /// <param name="brestT"></param>
        /// <param name="trestT"></param>
        /// <param name="srestT"></param>
        /// <param name="preT"></param>
        /// <param name="durT"></param>
        /// <param name="posT"></param>
        /// <param name="bgcolor"></param>
        /// <param name="length"></param>
        public SLExperiment(ExType[] extype, ExPara[] expara, SLInterpolation[] cond, int block, int trial, int[] stimuli, float brestT, float trestT, float srestT, float preT, float durT, float posT, Color bgcolor, int length)
        {
            Extype = new List<KeyValuePair<string, int>>();
            Cond = new List<SLKeyValuePair<string, int, SLInterpolation>>();

            Exdesign = new ExDesign(extype, expara, cond, block, trial, stimuli, brestT, trestT, srestT, preT, durT, posT, bgcolor);
            Flow = new FlowControl();
            PPort = new ParallelPort();
            Rand = new SLRandom(length);
        }
 internal ControlOctet(MessageType type, FlowControl control)
 => value = (byte)((int)type | (int)control);
        public override async System.Threading.Tasks.Task GCode_CodeDom_GenerateCode(CodeTypeDeclaration codeClass, CodeStatementCollection codeStatementCollection, LinkPinControl element, GenerateCodeContext_Method context)
        {
            if (mLinkedNodesContainer == null)
            {
                var assist   = this.HostNodesContainer.HostControl as Macross.NodesControlAssist;
                var tempFile = assist.HostControl.GetGraphFileName(assist.LinkedCategoryItemName);
                await assist.LoadSubLinks(tempFile);

                var data = new SubNodesContainerData()
                {
                    ID    = Id,
                    Title = HostNodesContainer.TitleString + "/" + this.NodeName + "_CustomCondition" + ":" + this.Id.ToString(),
                };
                mLinkedNodesContainer = await assist.GetSubNodesContainer(data);

                if (data.IsCreated)
                {
                    CreateSubContainerDefaultNodes();
                }
            }
            foreach (var ctrl in mLinkedNodesContainer.CtrlNodeList)
            {
                ctrl.ReInitForGenericCode();
            }
            foreach (var ctrl in mLinkedNodesContainer.CtrlNodeList)
            {
                if (ctrl is CodeDomNode.MethodCustom)
                {
                    await ctrl.GCode_CodeDom_GenerateCode(codeClass, null, context.ClassContext);
                }
            }
            Type nodeType = typeof(EngineNS.Bricks.AI.BehaviorTree.Decorator.ConditionFuncDecorator);
            CodeVariableDeclarationStatement stateVarDeclaration = new CodeVariableDeclarationStatement(nodeType, ValidName, new CodeObjectCreateExpression(new CodeTypeReference(nodeType)));

            codeStatementCollection.Add(stateVarDeclaration);

            var flowAssign = new CodeAssignStatement();

            flowAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "FlowControl");
            flowAssign.Right = new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(typeof(FlowControlType)), FlowControl.ToString());
            codeStatementCollection.Add(flowAssign);


            var inverseAssign = new CodeAssignStatement();

            inverseAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "Inverse");
            inverseAssign.Right = new CodePrimitiveExpression(Inverse);
            codeStatementCollection.Add(inverseAssign);

            var actionAssign = new CodeAssignStatement();

            actionAssign.Left  = new CodeFieldReferenceExpression(new CodeVariableReferenceExpression(ValidName), "Func");
            actionAssign.Right = new CodeVariableReferenceExpression("CustomCondition_" + ValidName);
            codeStatementCollection.Add(actionAssign);
        }
Ejemplo n.º 27
0
        private void ProcessMove()
        {
            MoveListLabel.Content = InputBox.Text;
            GS.move = InputBox.Text;

            InputBox.Clear();
            InputBox.Focus();

            MoveListLabel.Content = MoveList;
            Valid.Content         = "";

            switch (GS.move.Length)
            {
            case 1:
                if (FlowControl.ProcessCommand(GS))
                {
                    Valid.Content = "Valid command : " + GS.move;
                }
                else
                {
                    Valid.Content = "Invalid command : " + GS.move;
                }
                break;

            case 2:
                if (GS.move.ToLower() == "s1")
                {
                    Utility.Setup1(this);
                }
                if (GS.move.ToLower() == "s2")
                {
                    Utility.Setup2(this);
                }
                break;

            case 4:
                if (CheckMoveRegExpression.CheckMoveRegEx(GS.move))
                {
                    GS.array = ConvertMove.ToInternalArray(GS.move);
                    if (GeneralValidations.ValidateMove(this, GS))
                    {
                        Utility.SetCastlingFlags(this, GS.array[0], GS.array[1], GS);
                        Utility.MovePiece(this, GS.array[0], GS.array[1], GS.array[2], GS.array[3]);
                        Utility.MoveCastleWhenCastling(this, GS);

                        MOVECOUNT++;
                        WHITESMOVE = (MOVECOUNT % 2 == 0);
                        MoveList.Append(GS.WM + "-" + GS.move + " ");
                        GS.WM             = WHITESMOVE ? "WHITE" : "BLACK";
                        WhoseMove.Content = GS.WM + " to move ...";
                        Valid.Content     = "Valid move : " + GS.move;
                    }
                    else
                    {
                        Valid.Content = "Invalid move : " + GS.move;
                    }
                }
                else
                {
                    Valid.Content = "Invalid move : " + GS.move;
                }
                break;
            }
        }
 public FlowControlReport(FlowControl ARV)
 {
     mFlowControl = ARV;
 }
Ejemplo n.º 29
0
 internal OpCode(OpCodeValues value, int flags)
 {
     m_stringname = null; // computed lazily
     m_pop = (StackBehaviour)((flags >> StackBehaviourPopShift) & StackBehaviourMask);
     m_push = (StackBehaviour)((flags >> StackBehaviourPushShift) & StackBehaviourMask);
     m_operand = (OperandType)(flags & OperandTypeMask);
     m_type = (OpCodeType)((flags >> OpCodeTypeShift) & OpCodeTypeMask);
     m_size = (flags >> SizeShift) & SizeMask;
     m_s1 = (byte)((int)value >> 8);
     m_s2 = (byte)(int)value;
     m_ctrl = (FlowControl)((flags >> FlowControlShift) & FlowControlMask);
     m_endsUncondJmpBlk = (flags & EndsUncondJmpBlkFlag) != 0;
     m_stackChange = (flags >> StackChangeShift);
 }
        public RuleResult CheckMethod(MethodDefinition method)
        {
            //Skip the test, instead of flooding messages
            //in stubs or empty setters.
            if (!method.HasBody)
            {
                return(RuleResult.DoesNotApply);
            }

            // rule applies to setters methods
            if (!method.IsSetter)
            {
                return(RuleResult.DoesNotApply);
            }

            // rule applies
            bool flow  = false;
            bool empty = true;

            foreach (Instruction instruction in method.Body.Instructions)
            {
                ParameterDefinition pd = instruction.GetParameter(method);
                if (pd != null)
                {
                    empty = false;
                    if (pd.Index == 0)                     // value
                    {
                        return(RuleResult.Success);
                    }
                    continue;
                }

                switch (instruction.OpCode.Code)
                {
                // check if the IL simply throws an exception
                case Code.Throw:
                    if (!flow)
                    {
                        return(RuleResult.Success);
                    }
                    empty = false;
                    break;

                case Code.Nop:
                    break;

                case Code.Ret:
                    flow = true;
                    break;

                default:
                    empty = false;
                    // lots of thing can occurs before the throw
                    // e.g. loading the string (ldstr)
                    //	or calling a method to translate this string
                    FlowControl fc = instruction.OpCode.FlowControl;
                    flow |= ((fc != FlowControl.Next) && (fc != FlowControl.Call));
                    // but as long as the flow continue uninterruped to the throw
                    // we consider this a simple throw
                    break;
                }
            }

            if (empty)
            {
                return(RuleResult.Success);
            }

            Runner.Report(method, Severity.High, Confidence.Total);
            return(RuleResult.Failure);
        }
Ejemplo n.º 31
0
 public bool SetPortSettings(uint baudrate, byte databits, StopBits stopbits, Parity parity, FlowControl flowcontrol)
 {
     unsafe {
         DCB dcb = new DCB();
         dcb.DCBlength = sizeof(DCB);
         dcb.BaudRate = baudrate;
         dcb.ByteSize = databits;
         dcb.StopBits = (byte)stopbits;
         dcb.Parity = (byte)parity;
         dcb.fParity = (parity > 0)? 1U : 0U;
         dcb.fBinary = dcb.fDtrControl = dcb.fTXContinueOnXoff = 1;
         dcb.fOutxCtsFlow = dcb.fAbortOnError = (flowcontrol == FlowControl.Hardware)? 1U : 0U;
         dcb.fOutX = dcb.fInX = (flowcontrol == FlowControl.XOnXOff)? 1U : 0U;
         dcb.fRtsControl = (flowcontrol == FlowControl.Hardware)? 2U : 1U;
         dcb.XonLim = 2048;
         dcb.XoffLim = 512;
         dcb.XonChar = 0x11; // Ctrl-Q
         dcb.XoffChar = 0x13; // Ctrl-S
         return SetCommState(m_hFile, &dcb);
     }
 }
Ejemplo n.º 32
0
 internal static int CreateFlag(byte size, FlowControl flow, ControlChain chain)
 => ((int)chain << 0xC) | 0x1F | ((int)flow << 0x11) | 0x1F | (size << 22) | 0x3;
Ejemplo n.º 33
0
        internal void InitializeCallibrations()
        {
            calibration = new Dictionary <string, object>();
            try
            {
                // to initialize a sensor measurement object, we pass it a calibration object
                // eventually, these will come from a specific Cosmos document that the app will passthru
                foreach (var c in Weight.GetDefaultCalibrationSettings())
                {
                    calibration[c.Key] = c.Value;
                }
                foreach (var c in FlowControl.GetDefaultCalibrationSettings())
                {
                    calibration[c.Key] = c.Value;
                }
                foreach (var c in Temperature.GetDefaultCalibrationSettings())
                {
                    calibration[c.Key] = c.Value;
                }
                foreach (var c in Flow.GetDefaultCalibrationSettings())
                {
                    calibration[c.Key] = c.Value;
                }

                calibration[Weight.AdjustWeightFactorSetting] = Common.KegSettings.WeightCalibrationFactor.ToString();
                calibration[Weight.AdjustWeightOffsetSetting] = Common.KegSettings.WeightCalibrationOffset.ToString();

                if (calibration.ContainsKey(Temperature.AdjustTemperatureSetting))
                {
                    calibration[Temperature.AdjustTemperatureSetting] = new Measurement(-2.0f, Measurement.UnitsOfMeasure.Fahrenheit);
                }
                else
                {
                    calibration.Add(Temperature.AdjustTemperatureSetting, new Measurement(-2.0f, Measurement.UnitsOfMeasure.Fahrenheit));
                }

                //Flow Calibration
                calibration[Flow.FlowCalibrationFactorSetting] = Common.KegSettings.FlowCalibrationFactor.ToString();
                calibration[Flow.FlowCalibrationOffsetSetting] = Common.KegSettings.FlowCalibrationOffset.ToString();

                App._flowControl = new FlowControl(App.calibration);
                App._flowControl.Initialize(1000, 1000);

                App._flow = new Flow(App.calibration);
                App._flow.Initialize(1000, 1000);

                //Objects Initializations
                App._temperature = new Temperature(App.calibration);
                //App._temperature.TemperatureChanged += OnTemperatureChange;
                App._temperature.Initialize(1000, 10000);

                App._weight = new Weight(App.calibration);
                //App._weight.WeightChanged += OnWeightChange;
                App._weight.Initialize();
                //App._weight.Initialize(1000, 50000);
                App._weight.Initialize(1000, 10000);

                KegLogger.KegLogTrace("Kegocnizer App Loaded", "AppLoad", Microsoft.ApplicationInsights.DataContracts.SeverityLevel.Information, null);
            }
            catch (Exception ex)
            {
                Dictionary <string, string> log = new Dictionary <string, string>();
                foreach (var item in calibration)
                {
                    log.Add(item.Key, item.Value.ToString());
                }
                KegLogger.KegLogTrace(ex.Message, "App:InitializeCallibrations", SeverityLevel.Critical, log);

                KegLogger.KegLogException(ex, "App:InitializeCallibrations", SeverityLevel.Critical);
#if !DEBUG
                throw;
#endif
            }
        }
Ejemplo n.º 34
0
 private void Model_FlowControl(object sender, FlowControlEventArgs e)
 {
     FlowControl?.Invoke(sender, e);
 }
        public void TestBulkPullPermanentExceptionSurrender() {
            if (!Boolean.Parse((string)GetProperty("replicationTestsEnabled")))
            {
                Assert.Inconclusive("Replication tests disabled.");
                return;
            }

            Log.Domains.Sync.Level = Log.LogLevel.Debug;
            var fakeFactory = new MockHttpClientFactory(false);
            FlowControl flow = new FlowControl(new FlowItem[]
            {
                new ExceptionThrower(new SocketException()) { ExecutionCount = -1 },
            });

            fakeFactory.HttpHandler.SetResponder("_bulk_get", (request) => 
                flow.ExecuteNext<HttpResponseMessage>());
            manager.DefaultHttpClientFactory = fakeFactory;

            using (var remoteDb = _sg.CreateDatabase(TempDbName())) {
                CreatePullAndTest(20, remoteDb, repl => Assert.IsTrue(database.GetDocumentCount() < 20, "Somehow got all the docs"));
            }
        }
        public void TestBulkPullTransientExceptionRecovery() {
            if (!Boolean.Parse((string)Runtime.Properties["replicationTestsEnabled"]))
            {
                Assert.Inconclusive("Replication tests disabled.");
                return;
            }

            var initialRowCount = SyncGatewayRowCount();
    
            var fakeFactory = new MockHttpClientFactory(false);
            FlowControl flow = new FlowControl(new FlowItem[]
            {
                new FunctionRunner<HttpResponseMessage>(() => {
                    Thread.Sleep(7000);
                    return new RequestCorrectHttpMessage();
                }) { ExecutionCount = 2 },
                new FunctionRunner<HttpResponseMessage>(() => {
                    fakeFactory.HttpHandler.ClearResponders();
                    return new RequestCorrectHttpMessage();
                }) { ExecutionCount = 1 }
            });

            fakeFactory.HttpHandler.SetResponder("_bulk_get", (request) =>
                flow.ExecuteNext<HttpResponseMessage>());
            manager.DefaultHttpClientFactory = fakeFactory;
            ManagerOptions.Default.RequestTimeout = TimeSpan.FromSeconds(5);

            CreatePullAndTest(20, (repl) => Assert.IsTrue(database.DocumentCount - initialRowCount == 20, "Didn't recover from the error"));
        }
Ejemplo n.º 37
0
		internal OpCode (byte op1, byte op2,
			Code code, FlowControl flowControl,
			OpCodeType opCodeType, OperandType operandType,
			StackBehaviour pop, StackBehaviour push)
		{
			m_value = (short) ((op1 << 8) | op2);
			m_code = (byte) code;
			m_flowControl = (byte) flowControl;
			m_opCodeType = (byte) opCodeType;
			m_operandType = (byte) operandType;
			m_stackBehaviourPop = (byte) pop;
			m_stackBehaviourPush = (byte) push;

			if (op1 == 0xff)
				OpCodes.OneByteOpCode [op2] = this;
			else
				OpCodes.TwoBytesOpCode [op2] = this;
		}
Ejemplo n.º 38
0
 public void Reset()
 {
     _flow = new FlowControl((uint)_initialWindowSize);
     _pendingUpdateSize     = 0;
     _windowUpdatesDisabled = false;
 }
Ejemplo n.º 39
0
    private bool VerificationHelper(OpCode code,
        string name,
        StackBehaviour pop,
        StackBehaviour push,
        OperandType oprandType,
        OpCodeType type,
        int size,
        byte s1,
        byte s2,
        FlowControl ctrl,
        string errorno,
        string errordesp)
    {
        bool retVal = true;

        string actualName = code.Name;
        if (actualName != name)
        {
            TestLibrary.TestFramework.LogError(errorno + ".0", "Name returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualName = " + actualName + ", name = " + name);
            retVal = false;
        }

        StackBehaviour actualPop = code.StackBehaviourPop;
        if (actualPop != pop)
        {
            TestLibrary.TestFramework.LogError(errorno + ".1", "StackBehaviourPop returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualPop = " + actualPop + ", pop = " + pop);
            retVal = false;
        }

        StackBehaviour actualPush = code.StackBehaviourPush;
        if (actualPush != push)
        {
            TestLibrary.TestFramework.LogError(errorno + ".2", "StackBehaviourPush returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualPush = " + actualPush + ", push = " + push);
            retVal = false;
        }

        OperandType actualOperandType = code.OperandType;
        if (actualOperandType != oprandType)
        {
            TestLibrary.TestFramework.LogError(errorno + ".3", "OperandType returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualOperandType = " + actualOperandType + ", oprandType = " + oprandType);
            retVal = false;
        }

        OpCodeType actualOpCodeType = code.OpCodeType;
        if (actualOpCodeType != type)
        {
            TestLibrary.TestFramework.LogError(errorno + ".4", "OpCodeType returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualOpCodeType = " + actualOpCodeType + ", type = " + type);
            retVal = false;
        }

        int actualSize = code.Size;
        if (actualSize != size)
        {
            TestLibrary.TestFramework.LogError(errorno + ".5", "Size returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualSize = " + actualSize + ", size = " + size);
            retVal = false;
        }

        short expectedValue = 0;
        if (size == 2)
            expectedValue = (short)(s1 << 8 | s2);
        else
            expectedValue = (short)s2;

        short actualValue = code.Value;
        if (actualValue != expectedValue)
        {
            TestLibrary.TestFramework.LogError(errorno + ".6", "Value returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualValue = " + actualValue + ", s1 = " + s1 + ", s2 = " + s2 + ", expectedValue = " + expectedValue);
            retVal = false;
        }

        FlowControl actualCtrl = code.FlowControl;
        if (actualCtrl != ctrl)
        {
            TestLibrary.TestFramework.LogError(errorno + ".7", "FlowControl returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualCtrl = " + actualCtrl + ", ctrl = " + ctrl);
            retVal = false;
        }
        return retVal;
    }
Ejemplo n.º 40
0
 public void SetFlowControl(FlowControl control, byte uXon, byte uXoff)
 {
     Internal.Constants.FT_STATUS status = Internal.Methods.FT_SetFlowControl(mvarHandle, control, uXon, uXoff);
     FT_StatusToException(status);
 }
Ejemplo n.º 41
0
 public CFGNode AddNode(IStatement statement, FlowControl flowControl)
 {
     CFGNode node = AddNode();
     node.BasicBlock.Statements.Add(statement);
     node.FlowControl = flowControl;
     return node;
 }
Ejemplo n.º 42
0
 internal SerialTerminalParam(SerialTerminalParam p)
     : base(p)
 {
     _port = p._port;
     _baudRate = p._baudRate;
     _byteSize = p._byteSize;
     _parity = p._parity;
     _stopBits = p._stopBits;
     _flowControl = p._flowControl;
     _transmitDelayPerChar = p._transmitDelayPerChar;
     _transmitDelayPerLine = p._transmitDelayPerLine;
 }
Ejemplo n.º 43
0
        public void FlowcontrolTest_WithBFCreateCopy()
        {
            //Arrange
            BusinessFlow bf = new BusinessFlow("Test");

            Activity activity = new Activity();

            activity.ActivityName = "Login";

            ActGotoURL actGotoURL = new ActGotoURL();

            actGotoURL.Description = "Launch";

            activity.Acts.Add(actGotoURL);

            Activity activity2 = new Activity();

            activity2.ActivityName = "Test";

            ActDummy act2 = new ActDummy();

            act2.Description = "WaitForApp";

            activity.Acts.Add(act2);

            FlowControl flowControl = new FlowControl();

            flowControl.Active            = true;
            flowControl.Condition         = "1=1";
            flowControl.FlowControlAction = eFlowControlAction.GoToActivity;
            flowControl.Value             = activity2.Guid + flowControl.GUID_NAME_SEPERATOR + activity2.ItemName;

            FlowControl flowControl2 = new FlowControl();

            flowControl2.Active            = true;
            flowControl2.Condition         = "2=2";
            flowControl2.FlowControlAction = eFlowControlAction.GoToAction;
            flowControl2.Value             = act2.Guid + flowControl.GUID_NAME_SEPERATOR + act2.ItemName;


            actGotoURL.FlowControls.Add(flowControl);
            actGotoURL.FlowControls.Add(flowControl2);

            bf.Activities.RemoveAt(0);
            bf.Activities.Add(activity);
            bf.Activities.Add(activity2);

            activity2.ActivityName = "Test_New";
            bf.RepositorySerializer.SaveToFile(bf, TestResources.GetTempFile("BF.xml"));

            //Act
            BusinessFlow bfCopy = (BusinessFlow)bf.CreateInstance();

            Guid newGuidOfActivity2 = bfCopy.Activities.Where(x => x.ItemName == "Test_New").FirstOrDefault().Guid;

            Guid newGuidOfAct2 = bfCopy.Activities[0].Acts.Where(x => x.ItemName == "WaitForApp").FirstOrDefault().Guid;


            //Assert
            Assert.AreEqual(bfCopy.Activities[0].Acts[0].FlowControls[1].GetGuidFromValue(), newGuidOfAct2);
            Assert.AreEqual(bfCopy.Activities[0].Acts[0].FlowControls[0].GetGuidFromValue(), newGuidOfActivity2);
        }
Ejemplo n.º 44
0
 public static bool TryFlowControl(string value, out FlowControl flowControl) => flowControlDict.TryGetValue(value, out flowControl);
 /// <summary>
 /// Initializes a new instance of the <see cref="ExternalDataConfigurationConnectionContext"/> class.
 /// </summary>
 /// <param name="name">
 /// The name.
 /// </param>
 /// <param name="systemName">
 /// The system Name.
 /// </param>
 /// <param name="portName">
 /// The port name.
 /// </param>
 /// <param name="baudRate">
 /// The baud rate.
 /// </param>
 /// <param name="parity">
 /// The parity.
 /// </param>
 /// <param name="dtr">
 /// The dtr.
 /// </param>
 /// <param name="flowControlHighSignal">
 /// The flow control high signal.
 /// </param>
 /// <param name="parityErrorChecking">
 /// The parity error checking.
 /// </param>
 /// <param name="flowControl">
 /// The flow control.
 /// </param>
 /// <param name="rts">
 /// The rts.
 /// </param>
 /// <param name="dataBits">
 /// The data bits.
 /// </param>
 /// <param name="connectionType">
 /// The connection type.
 /// </param>
 /// <param name="stopBits">
 /// The stop bits.
 /// </param>
 /// <param name="computerConnectionList">
 /// The computer connection list.
 /// </param>
 /// <param name="vid">
 /// The vid.
 /// </param>
 /// <param name="pid">
 /// The pid.
 /// </param>
 /// <param name="parentIdPrefix">
 /// The parent Id Prefix.
 /// </param>
 /// <param name="expression">
 /// </param>
 public ExternalDataConfigurationConnectionContext(
     string name,
     string systemName,
     string portName,
     string baudRate,
     SerialPortParity parity,
     bool dtr,
     int flowControlHighSignal,
     bool parityErrorChecking,
     FlowControl flowControl,
     bool rts,
     int dataBits,
     ConnectionType connectionType,
     StopBits stopBits,
     IEnumerable<ComputerConnectionContext> computerConnectionList, 
     string vid,
     string pid,
     string parentIdPrefix,
     string expression)
 {
     this._systemName = systemName;
     this._name = name;
     this._portName = portName;
     this._baudRate = baudRate;
     this._parity = parity;
     this._dtr = dtr;
     this._flowControlHighSignal = flowControlHighSignal;
     this._parityErrorChecking = parityErrorChecking;
     this._flowControl = flowControl;
     this._rts = rts;
     this._dataBits = dataBits;
     this._connectionType = connectionType;
     this._stopBits = stopBits;
     this._computerConnectionList = computerConnectionList;
     this._vid = vid;
     this._pid = pid;
     this._parentIdPrefix = parentIdPrefix;
     this._expresion = expression;
    
 }
Ejemplo n.º 46
0
    private bool VerifyAllTheFileds(OpCode opCode,
                                    String opCodeName,
                                    StackBehaviour pop,
                                    StackBehaviour push,
                                    OperandType operandType,
                                    OpCodeType type,
                                    int size,
                                    byte s1, byte s2,
                                    FlowControl ctrl,
                                    string errorNum)
    {
        bool   retVal = true;
        string errorDesc;

        string actualName = opCode.Name;

        if (actualName != opCodeName)
        {
            errorDesc = "Actual name of the specified MSIL instruction: \"" + actualName +
                        "\" does not equal expected name: \"" + opCodeName + "\"";
            TestLibrary.TestFramework.LogError(errorNum + ".1", errorDesc);
            retVal = false;
        }

        StackBehaviour actualStackBehaviourPop = opCode.StackBehaviourPop;

        if (actualStackBehaviourPop != pop)
        {
            errorDesc = "Actual pop statck behaviour of the specified MSIL instruction: (" + actualStackBehaviourPop +
                        ") does not equal expected pop stack behaviour: (" + pop + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".2", errorDesc);
            retVal = false;
        }

        StackBehaviour actualStackBehaviourPush = opCode.StackBehaviourPush;

        if (actualStackBehaviourPush != push)
        {
            errorDesc = "Actual push statck behaviour of the specified MSIL instruction: (" + actualStackBehaviourPush +
                        ") does not equal expected push stack behaviour: (" + push + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".3", errorDesc);
            retVal = false;
        }


        OperandType actualOperandType = opCode.OperandType;

        if (actualOperandType != operandType)
        {
            errorDesc = "Actual operand type of the specified MSIL instruction: (" + actualOperandType +
                        ") does not equal expected operand type: (" + operandType + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".4", errorDesc);
            retVal = false;
        }

        OpCodeType actualOpCodeType = opCode.OpCodeType;

        if (actualOpCodeType != type)
        {
            errorDesc = "Actual OpCode type of the specified MSIL instruction: (" + actualOpCodeType +
                        ") does not equal expected OpCode type: (" + type + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".5", errorDesc);
            retVal = false;
        }

        int actualSize = opCode.Size;

        if (actualSize != size)
        {
            errorDesc = "Actual size of the specified MSIL instruction: (" + actualSize +
                        ") does not equal expected size: (" + size + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".6", errorDesc);
            retVal = false;
        }

        short actualValue   = opCode.Value;
        short expectedValue = (2 == size) ? (short)(s1 << 8 | s2) : s2;

        if (actualValue != expectedValue)
        {
            errorDesc = "Actual immediate operand value of the specified MSIL instruction: (" + actualValue +
                        ") does not equal expected immediate operand value: (" + expectedValue + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".7", errorDesc);
            retVal = false;
        }

        FlowControl actualCtrl = opCode.FlowControl;

        if (actualCtrl != ctrl)
        {
            errorDesc = "Actual flow control of the specified MSIL instruction: (" + actualCtrl +
                        ") does not equal expected flow control: (" + ctrl + ")";
            TestLibrary.TestFramework.LogError(errorNum + ".8", errorDesc);
            retVal = false;
        }

        return(retVal);
    }
        private static void CreateNewDataReport(string filename)
        {
            using (FileStream fs = File.Create(filename))
            {
                DateTime now = DateTime.Now;

                IWorkbook workbook = new XSSFWorkbook();

                ISheet sheet = workbook.CreateSheet(SHEET_NAME);

                IFont boldFont = workbook.CreateFont();
                boldFont.IsBold = true;

                ICellStyle headStyle = workbook.CreateCellStyle();
                headStyle.SetFont(boldFont);
                headStyle.Alignment         = HorizontalAlignment.Center;
                headStyle.VerticalAlignment = VerticalAlignment.Center;
                headStyle.BorderLeft        = BorderStyle.Thin;
                headStyle.BorderTop         = BorderStyle.Thin;
                headStyle.BorderRight       = BorderStyle.Thin;
                headStyle.BorderBottom      = BorderStyle.Thin;

                IRow row0 = sheet.CreateRow(0);
                IRow row1 = sheet.CreateRow(1);
                IRow row2 = sheet.CreateRow(2);
                IRow row3 = sheet.CreateRow(3);

                ICell snHeadCell = row0.CreateCell(0);
                snHeadCell.SetCellValue("SN");
                snHeadCell.CellStyle         = headStyle;
                row1.CreateCell(0).CellStyle = headStyle;
                row2.CreateCell(1).CellStyle = headStyle;
                sheet.AddMergedRegion(new CellRangeAddress(0, 2, 0, 0));

                ICell snCell = row3.CreateCell(0);
                snCell.SetCellValue(AppInfo.PhoneInfo.SN);

                ICell timeHeadCell = row0.CreateCell(1);
                timeHeadCell.SetCellValue("时间");
                sheet.AddMergedRegion(new CellRangeAddress(0, 2, 1, 1));
                timeHeadCell.CellStyle = headStyle;

                ICell timeCell = row3.CreateCell(1);
                timeCell.SetCellValue(now.ToString("HH:mm:ss"));

                int         col         = 2;
                int         firstCol    = col;
                FlowControl flowControl = FlowControl.Instance;
                foreach (FlowItem flowItem in flowControl.FlowItemList)
                {
                    if (!flowItem.Item.Property.Disable && !flowItem.IsAuxiliaryItem() && flowItem.SpecValueList != null)
                    {
                        firstCol = col;
                        foreach (SpecValue specValue in flowItem.SpecValueList)
                        {
                            if (!specValue.Disable)
                            {
                                ICell specDescripCell = row1.CreateCell(col);
                                specDescripCell.SetCellValue(specValue.SpecDescription);
                                specDescripCell.CellStyle = headStyle;

                                ICell specCell = row2.CreateCell(col);
                                specCell.SetCellValue(specValue.Spec);
                                specCell.CellStyle = headStyle;

                                ICell valueCell = row3.CreateCell(col);
                                valueCell.SetCellValue(specValue.MeasuredValue);

                                col++;
                            }
                        }

                        ICell nameCell = row0.CreateCell(firstCol);
                        nameCell.SetCellValue(flowItem.Name);
                        nameCell.CellStyle = headStyle;
                        if (col - firstCol > 1)
                        {
                            sheet.AddMergedRegion(new CellRangeAddress(0, 0, firstCol, col - 1));
                        }
                    }
                }

                workbook.Write(fs);
            }
        }
        public void TestBulkPullPermanentExceptionSurrender() {
            if (!Boolean.Parse((string)Runtime.Properties["replicationTestsEnabled"]))
            {
                Assert.Inconclusive("Replication tests disabled.");
                return;
            }

            var fakeFactory = new MockHttpClientFactory(false);
            FlowControl flow = new FlowControl(new FlowItem[]
            {
                new ExceptionThrower(new TaskCanceledException()) { ExecutionCount = -1 },
            });

            fakeFactory.HttpHandler.SetResponder("_bulk_get", (request) => 
                flow.ExecuteNext<HttpResponseMessage>());
            manager.DefaultHttpClientFactory = fakeFactory;
            ManagerOptions.Default.RequestTimeout = TimeSpan.FromSeconds(5);

            using (var remoteDb = _sg.CreateDatabase(TempDbName())) {
                CreatePullAndTest(20, remoteDb, repl => Assert.IsTrue(database.GetDocumentCount() < 20, "Somehow got all the docs"));
            }
        }
        /// <summary>
        /// 将测试结果保存到excel文件中
        /// </summary>
        public static void Save()
        {
            DateTime now       = DateTime.Now;
            string   hostName  = Dns.GetHostName();
            string   directory = CreateDirectory();
            string   filename  = directory + now.ToString("yyyy_MM_dd") + "_" + hostName + ".xlsx";

            FlowControl flowControl = FlowControl.Instance;

            if (File.Exists(filename))
            {
                bool       conflict = false;
                FileStream fs       = File.OpenRead(filename);
                IWorkbook  workbook = new XSSFWorkbook(fs);
                fs.Close();

                ISheet sheet = workbook.GetSheet(SHEET_NAME);

                if (sheet != null)
                {
                    IRow row0 = sheet.GetRow(0);
                    IRow row1 = sheet.GetRow(1);
                    IRow row2 = sheet.GetRow(2);

                    if (row0 == null || row1 == null || row2 == null)
                    {
                        conflict = true;
                    }
                    else
                    {
                        int col = 2;

                        foreach (FlowItem flowItem in flowControl.FlowItemList)
                        {
                            if (!flowItem.Item.Property.Disable && !flowItem.IsAuxiliaryItem() && flowItem.SpecValueList != null)
                            {
                                ICell nameCell = row0.GetCell(col);

                                if (nameCell == null || !nameCell.StringCellValue.Equals(flowItem.Name))
                                {
                                    conflict = true;
                                    break;
                                }
                                foreach (SpecValue specValue in flowItem.SpecValueList)
                                {
                                    if (!specValue.Disable)
                                    {
                                        ICell specDescripCell = row1.GetCell(col);

                                        if (specDescripCell == null || !specDescripCell.StringCellValue.Equals(specValue.SpecDescription))
                                        {
                                            conflict = true;
                                            break;
                                        }

                                        ICell specCell = row2.GetCell(col);
                                        if (specCell == null || !specCell.StringCellValue.Equals(specValue.Spec))
                                        {
                                            conflict = true;
                                            break;
                                        }

                                        col++;
                                    }
                                }

                                if (conflict)
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    conflict = true;
                }

                if (!conflict)
                {
                    IRow row = sheet.CreateRow(sheet.LastRowNum + 1);

                    ICell snCell = row.CreateCell(0);
                    snCell.SetCellValue(AppInfo.PhoneInfo.SN);

                    ICell timeCell = row.CreateCell(1);
                    timeCell.SetCellValue(now.ToString("HH:mm:ss"));

                    int col = 2;
                    foreach (FlowItem flowItem in flowControl.FlowItemList)
                    {
                        if (!flowItem.Item.Property.Disable && !flowItem.IsAuxiliaryItem() && flowItem.SpecValueList != null)
                        {
                            foreach (SpecValue specValue in flowItem.SpecValueList)
                            {
                                if (!specValue.Disable)
                                {
                                    ICell valueCell = row.CreateCell(col);
                                    valueCell.SetCellValue(specValue.MeasuredValue);

                                    col++;
                                }
                            }
                        }
                    }

                    fs = File.OpenWrite(filename);
                    workbook.Write(fs);
                    fs.Close();
                }

                if (conflict)
                {
                    string renamefile = directory + now.ToString("yyyy_MM_dd_HH_mm_ss") + "_" + hostName + ".xlsx";
                    File.Move(filename, renamefile);
                    CreateNewDataReport(filename);
                }
            }
            else
            {
                CreateNewDataReport(filename);
            }
        }
Ejemplo n.º 50
0
 /// <summary>
 /// <ja>デフォルト設定で初期化します。</ja>
 /// <en>Initializes with default values.</en>
 /// <seealso cref="Poderosa.Macro.ConnectionList.Open"/>
 /// </summary>
 /// <remarks>
 /// <ja>パラメータは次のように初期化されます。</ja>
 /// <en>The parameters are set as following:</en>
 /// <list type="table">
 ///   <item><term><ja>エンコーディング</ja><en>Encoding</en></term><description><ja>EUC-JP</ja><en>iso-8859-1</en></description></item> 
 ///   <item><term><ja>ログ</ja><en>Log</en></term><description><ja>取得しない</ja><en>None</en></description></item>       
 ///   <item><term><ja>ローカルエコー</ja><en>Local echo</en></term><description><ja>しない</ja><en>Don't</en></description></item>  
 ///   <item><term><ja>送信時改行</ja><en>New line</en></term><description>CR</description></item>    
 ///   <item><term><ja>ボーレート</ja><en>Baud Rate</en></term><description>9600</description></item>
 ///   <item><term><ja>データ</ja><en>Data Bits</en></term><description><ja>8ビット</ja><en>8 bits</en></description></item>
 ///   <item><term><ja>パリティ</ja><en>Parity</en></term><description><ja>なし</ja><en>None</en></description></item>
 ///   <item><term><ja>ストップビット</ja><en>Stop Bits</en></term><description><ja>1ビット</ja><en>1 bit</en></description></item>
 ///   <item><term><ja>フローコントロール</ja><en>Flow Control</en></term><description><ja>なし</ja><en>None</en></description></item>
 /// </list>
 /// <ja>接続を開くには、<see cref="Poderosa.Macro.ConnectionList.Open"/>メソッドの引数としてSerialTerminalParamオブジェクトを渡します。</ja>
 /// <en>To open a new connection, pass the SerialTerminalParam object to the <see cref="Poderosa.Macro.ConnectionList.Open"/> method.</en>
 /// </remarks>
 public SerialTerminalSettings() {
     _baudRate = 9600;
     _byteSize = 8;
     _parity = Parity.NOPARITY;
     _stopBits = StopBits.ONESTOPBIT;
     _flowControl = FlowControl.None;
 }
Ejemplo n.º 51
0
 private ExecuteResult(FlowControl flowControl)
 {
     FlowControl = flowControl;
 }
        public void TestBulkPullTransientExceptionRecovery() {
            if (!Boolean.Parse((string)GetProperty("replicationTestsEnabled")))
            {
                Assert.Inconclusive("Replication tests disabled.");
                return;
            }

            var fakeFactory = new MockHttpClientFactory(false);
            FlowControl flow = new FlowControl(new FlowItem[]
            {
                new FunctionRunner<HttpResponseMessage>(() => {
                    Sleep(7000);
                    return new RequestCorrectHttpMessage();
                }) { ExecutionCount = 2 },
                new FunctionRunner<HttpResponseMessage>(() => {
                    fakeFactory.HttpHandler.ClearResponders();
                    return new RequestCorrectHttpMessage();
                }) { ExecutionCount = 1 }
            });

            fakeFactory.HttpHandler.SetResponder("_bulk_get", (request) =>
                flow.ExecuteNext<HttpResponseMessage>());
            manager.DefaultHttpClientFactory = fakeFactory;
#pragma warning disable 618
            ManagerOptions.Default.RequestTimeout = TimeSpan.FromSeconds(5);
#pragma warning restore 618

            using (var remoteDb = _sg.CreateDatabase(TempDbName())) {
                CreatePullAndTest(20, remoteDb, (repl) => Assert.AreEqual(20, database.GetDocumentCount(), "Didn't recover from the error"));
            }

            Thread.Sleep(1000);
        }
Ejemplo n.º 53
0
 internal PacketHeaders(MessageType type, FlowControl control)
 {
     this.control = new ControlOctet(type, control);
 }
Ejemplo n.º 54
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="port">port name, i.e. COM1</param>
 /// <param name="baud">Baud rate for the port. Allowed values depend on the specific port</param>
 /// <param name="dataBits">Number of data bits. Typically 8.</param>
 /// <param name="stopBits"> Stop bits, typically 1</param>
 /// <param name="parity"> Parity, typically none</param>
 /// <param name="flowControl">Flow control, typically none</param>
 public SerialSettings(String port, int baud, int dataBits, StopBits stopBits, Parity parity, FlowControl flowControl)
 {
     this.port        = port;
     this.baud        = baud;
     this.dataBits    = dataBits;
     this.stopBits    = stopBits;
     this.parity      = parity;
     this.flowControl = flowControl;
 }
Ejemplo n.º 55
0
 internal OneByteOpCode(
     Code code, OpCodeType opCodeType, OperandType operandType,
     FlowControl flowControl, StackBehaviour pop, StackBehaviour push)
     : base(code, opCodeType, operandType, flowControl, pop, push)
 {
 }
Ejemplo n.º 56
0
    private bool VerificationHelper(OpCode code,
                                    string name,
                                    StackBehaviour pop,
                                    StackBehaviour push,
                                    OperandType oprandType,
                                    OpCodeType type,
                                    int size,
                                    byte s1,
                                    byte s2,
                                    FlowControl ctrl,
                                    string errorno,
                                    string errordesp)
    {
        bool retVal = true;

        string actualName = code.Name;

        if (actualName != name)
        {
            TestLibrary.TestFramework.LogError(errorno + ".0", "Name returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualName = " + actualName + ", name = " + name);
            retVal = false;
        }

        StackBehaviour actualPop = code.StackBehaviourPop;

        if (actualPop != pop)
        {
            TestLibrary.TestFramework.LogError(errorno + ".1", "StackBehaviourPop returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualPop = " + actualPop + ", pop = " + pop);
            retVal = false;
        }

        StackBehaviour actualPush = code.StackBehaviourPush;

        if (actualPush != push)
        {
            TestLibrary.TestFramework.LogError(errorno + ".2", "StackBehaviourPush returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualPush = " + actualPush + ", push = " + push);
            retVal = false;
        }

        OperandType actualOperandType = code.OperandType;

        if (actualOperandType != oprandType)
        {
            TestLibrary.TestFramework.LogError(errorno + ".3", "OperandType returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualOperandType = " + actualOperandType + ", oprandType = " + oprandType);
            retVal = false;
        }

        OpCodeType actualOpCodeType = code.OpCodeType;

        if (actualOpCodeType != type)
        {
            TestLibrary.TestFramework.LogError(errorno + ".4", "OpCodeType returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualOpCodeType = " + actualOpCodeType + ", type = " + type);
            retVal = false;
        }

        int actualSize = code.Size;

        if (actualSize != size)
        {
            TestLibrary.TestFramework.LogError(errorno + ".5", "Size returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualSize = " + actualSize + ", size = " + size);
            retVal = false;
        }

        short expectedValue = 0;

        if (size == 2)
        {
            expectedValue = (short)(s1 << 8 | s2);
        }
        else
        {
            expectedValue = (short)s2;
        }

        short actualValue = code.Value;

        if (actualValue != expectedValue)
        {
            TestLibrary.TestFramework.LogError(errorno + ".6", "Value returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualValue = " + actualValue + ", s1 = " + s1 + ", s2 = " + s2 + ", expectedValue = " + expectedValue);
            retVal = false;
        }

        FlowControl actualCtrl = code.FlowControl;

        if (actualCtrl != ctrl)
        {
            TestLibrary.TestFramework.LogError(errorno + ".7", "FlowControl returns wrong value for OpCode " + errordesp);
            TestLibrary.TestFramework.LogInformation("WARNING [LOCAL VARIABLE] actualCtrl = " + actualCtrl + ", ctrl = " + ctrl);
            retVal = false;
        }
        return(retVal);
    }
Ejemplo n.º 57
0
    private bool VerifyFlowControl(OpCode op1, FlowControl fc, string errNum)
    {
        bool retVal = true;

        try
        {
            if (op1.FlowControl != fc)
            {
                TestLibrary.TestFramework.LogError(errNum, "Result is not the value as expected,FlowControl is: " + op1.FlowControl + ",Expected is: " + fc);
                retVal = false;
            }
        }
        catch (Exception e)
        {
            TestLibrary.TestFramework.LogError(errNum, "Unexpected exception: " + e);
            retVal = false;
        }
        return retVal;
    }
Ejemplo n.º 58
0
        /// <summary>
        /// Creates the branches.
        /// </summary>
        private void createBranches()
        {
            // Look for branching, create blocks for the branches.
            // Note: First, we search all the branches so we can later add them in the correct order.
            //       This is because we may not always have the branches in a chronological order.
            int[] refers = new int[Method.Body.CodeSize];
            Branches    = new Branch[Method.Body.CodeSize];
            Branches[0] = new Branch(this, 0);

            foreach (Instruction instruction in Method.Body.Instructions)
            {
                FlowControl flow = instruction.OpCode.FlowControl;

                // If this instruction branches to a destination, create that destination block.
                if (flow == FlowControl.Branch || flow == FlowControl.Cond_Branch)
                {
                    Instruction dest = (Instruction)instruction.Operand;
                    if (Branches[dest.Offset] == null)
                    {
                        Branches[dest.Offset] = new Branch(this, dest.Offset);
                    }
                    refers[dest.Offset]++;
                }

                if (instruction.Next != null)
                {
                    // If this instruction does branching by a conditional, we also need to have a block after this instruction,
                    // for if the conditional branch is not being executed.
                    if (flow == FlowControl.Cond_Branch)
                    {
                        if (Branches[instruction.Next.Offset] == null)
                        {
                            Branches[instruction.Next.Offset] = new Branch(this, instruction.Next.Offset);
                        }
                    }
                    else if (flow == FlowControl.Next)
                    {
                        refers[instruction.Next.Offset]++;
                    }
                }
            }

            // Now that we know the reference count and where to put branches, let's create them.
            // For more explanation: refer to the loop above.
            Branch current = Branches[0];

            foreach (Instruction instruction in Method.Body.Instructions)
            {
                FlowControl flow = instruction.OpCode.FlowControl;

                if (Branches[instruction.Offset] != null)
                {
                    current = Branches[instruction.Offset];
                }

                current.AddInstruction(instruction);

                if (flow == FlowControl.Branch || flow == FlowControl.Cond_Branch)
                {
                    Instruction dest       = (Instruction)instruction.Operand;
                    Branch      destBranch = Branches[dest.Offset];
                    destBranch.AddSource(current);
                }

                if (instruction.Next != null)
                {
                    Branch destBranch = Branches[instruction.Next.Offset];
                    if (flow == FlowControl.Cond_Branch || refers[instruction.Next.Offset] > 1)
                    {
                        destBranch.AddSource(current);
                    }
                }
            }
        }
Ejemplo n.º 59
0
 public void ScrollIntoView()
 {
     FlowControl.ScrollIntoView(this);
 }