Esempio n. 1
0
        public object Execute(Schema schema, string query, object root = null,
            Inputs inputs = null, string operationName = "")
        {
            var source = new Source(query ?? "", "GraphQL Request");

            return string.Empty;
        }
        public ExecutionContext BuildExecutionContext(
            Schema schema,
            object root,
            Document document,
            string operationName,
            Inputs inputs)
        {
            var context = new ExecutionContext();
            context.Schema = schema;
            context.RootObject = root;

            var operation = !string.IsNullOrWhiteSpace(operationName)
                ? document.Operations.WithName(operationName)
                : document.Operations.FirstOrDefault();

            if (operation == null)
            {
                context.Errors.Add(new ExecutionError("Unknown operation name: {0}".ToFormat(operationName)));
                return context;
            }

            context.Operation = operation;
            context.Variables = GetVariableValues(schema, operation.Variables, inputs);
            context.Fragments = document.Fragments;

            return context;
        }
Esempio n. 3
0
    // // // UnityEngine magic methods
    // Do not define Awake, Start, Update or FixedUpdate in subclasses of NetworkedTimestepMovement.

    // // // Parent class override methods
    public override void GetInputs (ref Inputs inputs) {
        inputs.sides = RoundToLargest( Input.GetAxis("Horizontal" ) );
        inputs.forward = RoundToLargest( Input.GetAxis("Vertical" ) );
        inputs.yaw = -Input.GetAxis( "Mouse Y" ) * m_mouseSense * Time.fixedDeltaTime / Time.deltaTime;
        inputs.pitch = Input.GetAxis( "Mouse X" ) * m_mouseSense * Time.fixedDeltaTime / Time.deltaTime;
        inputs.sprint = Input.GetButton( "Sprint" );
        inputs.crouch = Input.GetButton( "Crouch" );

        float verticalTarget = -1;
        if ( router.characterController.isGrounded ) {
            if( Input.GetButton( "Jump" ) ) {
                m_jump = true;
            }
            inputs.vertical = 0;
            verticalTarget = 0;
        }
        if ( m_jump ) {
            verticalTarget = 1;
            if( inputs.vertical >= 0.9f ) {
                m_jump = false;
            }
        }
        inputs.vertical = Mathf.Lerp( inputs.vertical, verticalTarget, 20 * Time.deltaTime );

        if( Input.GetKeyDown (KeyCode.Escape) )
        {
            if (m_pausedPanel != null) { m_pausedPanel.SetActive(true); } // Enable the paused panel
            // lock the controls
            InputsSetLock(true);
        }
    }
        public List<Station> getStations(Inputs input)
        {
            List<Station> ret = new List<Station>();

            RegistryManager registry = new RegistryManager();
            byte[] value = registry.getStations(input);

            int segmentLength = 40;
            int stationEndpoint = segmentLength * registry.getStationCount(input);
            for (int i = 8; i < stationEndpoint; i += segmentLength)
            {
                ArraySegment<byte> segment = new ArraySegment<byte>(value, i, segmentLength);

                Station s = new Station();
                s.Input = input;
                s.PhysicalChannel = BitConverter.ToInt16(segment.Array, segment.Offset + (int)StationBytePositions.PhysicalChannel);
                s.VirtualChannel = BitConverter.ToInt16(segment.Array, segment.Offset + (int)StationBytePositions.VirtualChannel);
                s.SubChannel = segment.Array[segment.Offset + (int)StationBytePositions.SubChannel];

                // TODO: (KJM 02/21/06) Figure out how to treat 0xFF as -1 rather than 255.
                int minorChannel = segment.Array[segment.Offset + (int)StationBytePositions.MinorChannel];
                if (255 == minorChannel)
                {
                    minorChannel = -1;
                }
                s.MinorChannel = minorChannel;

                // TODO: (KJM 02/21/06) Figure out a way of actually reading in the name without dying on channels without names.
                //s.Name = System.Text.Encoding.ASCII.GetString(segment.Array, segment.Offset + 16, 5);

                ret.Add(s);
            }

            return ret;
        }
Esempio n. 5
0
 public Outputs Create(Inputs inputs)
 {
     Keypad ke = new Keypad(inputs.SKeypad, Stream.Never<Unit>());
     return new Outputs()
         .SetPresetLcd(ke.Value.Map(Formatters.FormatPresetAmount))
         .SetBeep(ke.SBeep);
 }
Esempio n. 6
0
 public static Cell<string> PriceLcd(
     Cell<IMaybe<Fuel>> fillActive,
     Cell<double> fillPrice,
     Fuel fuel,
     Inputs inputs)
 {
     Cell<double> idlePrice;
     switch (fuel)
     {
         case Fuel.One:
             idlePrice = inputs.Price1;
             break;
         case Fuel.Two:
             idlePrice = inputs.Price2;
             break;
         case Fuel.Three:
             idlePrice = inputs.Price3;
             break;
         default:
             idlePrice = null;
             break;
     }
     return fillActive.Lift(fillPrice, idlePrice,
         (fuelSelectedMaybe, fillPriceLocal, idlePriceLocal) =>
             fuelSelectedMaybe.Match(f => f == fuel ? Formatters.FormatPrice(fillPriceLocal, 4) : string.Empty, () => Formatters.FormatPrice(idlePriceLocal, 4)));
 }
Esempio n. 7
0
 public Outputs Create(Inputs inputs)
 {
     StreamLoop<Fuel> sStart = new StreamLoop<Fuel>();
     Fill fi = new Fill(
         inputs.SClearSale,
         inputs.SFuelPulses, inputs.Calibration,
         inputs.Price1, inputs.Price2, inputs.Price3,
         sStart);
     NotifyPointOfSale np = new NotifyPointOfSale(
         new LifeCycle(inputs.SNozzle1,
             inputs.SNozzle2,
             inputs.SNozzle3),
         inputs.SClearSale,
         fi);
     sStart.Loop(np.SStart);
     return new Outputs()
         .SetDelivery(np.FuelFlowing.Map(
             m =>
                 m.Equals(Maybe.Just(Fuel.One)) ? Delivery.Fast1 :
                     m.Equals(Maybe.Just(Fuel.Two)) ? Delivery.Fast2 :
                         m.Equals(Maybe.Just(Fuel.Three)) ? Delivery.Fast3 :
                             Delivery.Off))
         .SetSaleCostLcd(fi.DollarsDelivered.Map(Formatters.FormatSaleCost))
         .SetSaleQuantityLcd(fi.LitersDelivered.Map(Formatters.FormatSaleQuantity))
         .SetPriceLcd1(ShowDollarsPump.PriceLcd(np.FillActive, fi.Price, Fuel.One, inputs))
         .SetPriceLcd2(ShowDollarsPump.PriceLcd(np.FillActive, fi.Price, Fuel.Two, inputs))
         .SetPriceLcd3(ShowDollarsPump.PriceLcd(np.FillActive, fi.Price, Fuel.Three, inputs))
         .SetBeep(np.SBeep)
         .SetSaleComplete(np.SSaleComplete);
 }
        public async Task<ExecutionResult> ExecuteAsync(Schema schema, object root, string query, string operationName, Inputs inputs = null)
        {
            var document = _documentBuilder.Build(query);
            var result = new ExecutionResult();

            var validationResult = _documentValidator.IsValid(schema, document, operationName);

            if (validationResult.IsValid)
            {
                var context = BuildExecutionContext(schema, root, document, operationName, inputs);

                if (context.Errors.Any())
                {
                    result.Errors = context.Errors;
                    return result;
                }

                result.Data = await ExecuteOperation(context);
                result.Errors = context.Errors;
            }
            else
            {
                result.Data = null;
                result.Errors = validationResult.Errors;
            }

            return result;
        }
Esempio n. 9
0
 public Outputs Create(Inputs inputs)
 {
     StreamLoop<Fuel> sStart = new StreamLoop<Fuel>();
     Fill fi = new Fill(inputs.SClearSale,
         inputs.SFuelPulses, inputs.Calibration,
         inputs.Price1, inputs.Price2, inputs.Price3,
         sStart);
     NotifyPointOfSale np = new NotifyPointOfSale(
         new LifeCycle(inputs.SNozzle1,
             inputs.SNozzle2,
             inputs.SNozzle3),
         inputs.SClearSale,
         fi);
     sStart.Loop(np.SStart);
     CellLoop<bool> keypadActive = new CellLoop<bool>();
     Keypad ke = new Keypad(inputs.SKeypad,
         inputs.SClearSale,
         keypadActive);
     Preset pr = new Preset(ke.Value, fi, np.FuelFlowing);
     keypadActive.Loop(pr.KeypadActive);
     return new Outputs()
         .SetDelivery(pr.Delivery)
         .SetSaleCostLcd(fi.DollarsDelivered.Map(Formatters.FormatSaleCost))
         .SetSaleQuantityLcd(fi.LitersDelivered.Map(Formatters.FormatSaleQuantity))
         .SetPriceLcd1(ShowDollarsPump.PriceLcd(np.FillActive, fi.Price, Fuel.One, inputs))
         .SetPriceLcd2(ShowDollarsPump.PriceLcd(np.FillActive, fi.Price, Fuel.Two, inputs))
         .SetPriceLcd3(ShowDollarsPump.PriceLcd(np.FillActive, fi.Price, Fuel.Three, inputs))
         .SetSaleComplete(np.SSaleComplete)
         .SetPresetLcd(ke.Value.Map(Formatters.FormatPresetAmount))
         .SetBeep(np.SBeep.OrElse(ke.SBeep));
 }
Esempio n. 10
0
 public void Apply(string msg, Inputs.InputListener listener)
 {
     JObject json = new JObject();
     listener.AddDefaultFields(json);
     json["message"] = ExpandField(msg, json);
     listener.ProcessJson(json);
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Echo"/> class.
 /// </summary>
 public Echo()
 {
     if (_isLoaded)
     {
         UnLoad();
     }
     _isLoaded = false;
     _inputs = null;
 }
Esempio n. 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HelloWorld"/> class.
 /// </summary>
 public HelloWorld()
 {
     if (_isLoaded)
     {
         UnLoad();
     }
     _isLoaded = false;
     _inputs = null;
 }
Esempio n. 13
0
 public static bool GetButton(int player, Inputs.Button button)
 {
     switch(button) {
         case Inputs.Button.Fire1: return Input.GetButton("Fire1" + PLAYER_SUFFIX[player]);
         case Inputs.Button.Fire2: return Input.GetButton("Fire2" + PLAYER_SUFFIX[player]);
         case Inputs.Button.Start: return Input.GetButton("Start");
     }
     return false;
 }
        public KinectDeviceSettingsViewModel( Inputs.Kinect.KinectSensorController controller )
        {
            this._controller = controller;
            this.MinimumElevationAngle = this._controller.Sensor.MinElevationAngle;
            this.MaximumElevationAngle = this._controller.Sensor.MaxElevationAngle;

            int angle = this._controller.Sensor.ElevationAngle;

            if ( angle > MaximumElevationAngle )
            {
                this.CurrentElevationAngle = MaximumElevationAngle;
            }
            else if ( angle < MinimumElevationAngle )
            {
                this.CurrentElevationAngle = MinimumElevationAngle;
            }
            else
            {
                this.CurrentElevationAngle = this._controller.Sensor.ElevationAngle;
            }

            if ( this._controller.Sensor.DepthStream.Range == Microsoft.Kinect.DepthRange.Near )
            {
                this.NearModeIsEnabled = true;
            }
            else
            {
                this.NearModeIsEnabled = false;
            }

            if ( this._controller.Sensor.SkeletonStream.TrackingMode == Microsoft.Kinect.SkeletonTrackingMode.Seated )
            {
                this.SeatingModeIsEnabled = true;
            }
            else
            {
                this.SeatingModeIsEnabled = false;
            }

            if ( this._controller.Sensor.SkeletonStream.IsSmoothingEnabled )
            {
                this.SkeletonSmoothingIsEnabled = true;
            }
            else
            {
                this.SkeletonSmoothingIsEnabled = false;
            }

            if ( this._controller.DepthImageEnabled )
            {
                this.DepthImageIsDisabled = false;
            }
            else
            {
                this.DepthImageIsDisabled = true;
            }
        }
 public async Task<ExecutionResult> Execute(
   ISchema schema,
   object rootObject,
   string query,
   string operationName = null,
   Inputs inputs = null)
 {
     return await _executer.ExecuteAsync(schema, rootObject, query, operationName);
 }
Esempio n. 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BadStart"/> class.
 /// </summary>
 public BadStart()
 {
     if (_isLoaded)
     {
         UnLoad();
     }
     _isLoaded = false;
     _inputs = null;
 }
 public bool Equals(Inputs other)
 {
     return this.Language.Equals(other.Language) &&
            this.AnalyzerReferencesCount == other.AnalyzerReferencesCount &&
            this.ProjectReferencesCount == other.ProjectReferencesCount &&
            this.MetadataReferencesCount == other.MetadataReferencesCount &&
            this.DocumentsCount == other.DocumentsCount &&
            this.AdditionalDocumentsCount == other.AdditionalDocumentsCount;
 }
 public ExecutionResult Execute(
   Schema schema,
   object rootObject,
   string query,
   string operationName = null,
   Inputs inputs = null)
 {
     var executer = new DocumentExecuter();
     return executer.Execute(schema, rootObject, query, operationName);
 }
 public async Task<ExecutionResult> Execute(
   Schema schema,
   object rootObject,
   string query,
   string operationName = null,
   Inputs inputs = null)
 {
     var executer = new DocumentExecuter();
     return await executer.ExecuteAsync(schema, rootObject, query, operationName);
 }
 public ExecutionResult AssertQuerySuccess(
     ISchema schema,
     string query,
     string expected,
     Inputs inputs = null,
     object root = null,
     object userContext = null,
     CancellationToken cancellationToken = default(CancellationToken),
     IEnumerable<IValidationRule> rules = null)
 {
     var queryResult = CreateQueryResult(expected);
     return AssertQuery(schema, query, queryResult, inputs, root, userContext, cancellationToken, rules);
 }
Esempio n. 21
0
	public override Quaternion Rotate (Inputs inputs, Results current)
	{
		pawn.rotation = current.rotation;
		float mHor = current.rotation.eulerAngles.y + inputs.pitch * Time.fixedDeltaTime;
		float mVert = current.rotation.eulerAngles.x + inputs.yaw * Time.fixedDeltaTime;
		
		if (mVert > 180)
			mVert -= 360;
		mVert = Mathf.Clamp (mVert, -verticalMouseLookLimit * 0.5f, verticalMouseLookLimit * 0.5f);
		pawn.rotation = Quaternion.Euler (0, mHor, 0);
		pawnRotation = Quaternion.Euler (mVert, mHor, 0);
		return pawnRotation;
	}
Esempio n. 22
0
        public async Task<ExecutionResult> ExecuteAsync(
            ISchema schema,
            object root,
            string query,
            string operationName,
            Inputs inputs = null,
            CancellationToken cancellationToken = default(CancellationToken),
            IEnumerable<IValidationRule> rules = null)
        {
            var result = new ExecutionResult();
            try
            {
                var document = _documentBuilder.Build(query);
                var validationResult = _documentValidator.Validate(query, schema, document, rules);

                if (validationResult.IsValid)
                {
                    var context = BuildExecutionContext(schema, root, document, operationName, inputs, cancellationToken);

                    if (context.Errors.Any())
                    {
                        result.Errors = context.Errors;
                        return result;
                    }

                    result.Data = await ExecuteOperationAsync(context).ConfigureAwait(false);
                    if (context.Errors.Any())
                    {
                        result.Errors = context.Errors;
                    }
                }
                else
                {
                    result.Data = null;
                    result.Errors = validationResult.Errors;
                }

                return result;
            }
            catch (Exception exc)
            {
                if (result.Errors == null)
                {
                    result.Errors = new ExecutionErrors();
                }

                result.Data = null;
                result.Errors.Add(new ExecutionError(exc.Message, exc));
                return result;
            }
        }
Esempio n. 23
0
 public Outputs Create(Inputs inputs)
 {
     LifeCycle lc = new LifeCycle(inputs.SNozzle1, inputs.SNozzle2, inputs.SNozzle3);
     return new Outputs()
         .SetDelivery(lc.FillActive.Map(m =>
             m.Equals(Maybe.Just(Fuel.One)) ? Delivery.Fast1 :
                 m.Equals(Maybe.Just(Fuel.Two)) ? Delivery.Fast2 :
                     m.Equals(Maybe.Just(Fuel.Three)) ? Delivery.Fast3 :
                         Delivery.Off))
         .SetSaleQuantityLcd(lc.FillActive.Map(m =>
             m.Equals(Maybe.Just(Fuel.One)) ? "1" :
                 m.Equals(Maybe.Just(Fuel.Two)) ? "2" :
                     m.Equals(Maybe.Just(Fuel.Three)) ? "3" :
                         string.Empty));
 }
Esempio n. 24
0
 public override Quaternion Rotate (Inputs inputs, Results current) {
     m_observer.rotation = current.rotation;
     float mHor = current.rotation.eulerAngles.y + inputs.pitch * Time.fixedDeltaTime;
     float mVert = current.rotation.eulerAngles.x + inputs.yaw * Time.fixedDeltaTime;
     
     if (mVert > 180) mVert -= 360;
     mVert = Mathf.Clamp (mVert, -m_verticalMouseLookLimit * 0.5f, m_verticalMouseLookLimit * 0.5f);
     m_observer.rotation = Quaternion.Euler (0, mHor, 0);
     m_observerRotation = Quaternion.Euler (mVert, mHor, 0);
     // These three are to show the values in the inspector.
     m_observerRotationEuler = m_observerRotation.eulerAngles;
     m_viewPitch = mHor;
     m_viewYaw = mVert;
     return m_observerRotation;
 }
        public Station getStation(Inputs input, int virtualChannel)
        {
            List<Station> stations = getStations(input);

            // Go through each station until we find one with the same virutal channel number -- return that station.
            foreach (Station s in stations)
            {
                if (s.VirtualChannel == virtualChannel)
                {
                    return s;
                }
            }

            // If no station exists with the given virtual channel number, return null.
            return null;
        }
Esempio n. 26
0
        private Tuple<ExecutionContext, IEnumerable<ExecutionError>>  BuildExecutionContext(
            ISchema schema,
            object root,
            Document document,
            string operationName,
            Inputs inputs,
            CancellationToken cancellationToken,
            object userContext)
        {
            Operation operation = !string.IsNullOrWhiteSpace( operationName )
                ? document.Operations.WithName( operationName )
                : document.Operations.FirstOrDefault();

            ExecutionContext executionContext;
            if (operation == null)
            {
                IEnumerable<ExecutionError> executionErrors = new List<ExecutionError>
                {
                    new ExecutionError( string.Format( "Unknown operation name: {0}", operationName ) )
                };
                
                executionContext = new ExecutionContext(
                    schema,
                    root,
                    cancellationToken,
                    userContext);

                return new Tuple<ExecutionContext, IEnumerable<ExecutionError>>(
                    executionContext,
                    executionErrors );
            }

            executionContext = new ExecutionContext(
                schema,
                root,
                operation,
                document.Fragments,
                GetVariableValues(schema, operation.Variables, inputs),
                cancellationToken,
                userContext);

            return new Tuple<ExecutionContext, IEnumerable<ExecutionError>>(
                executionContext,
                null );
        }
Esempio n. 27
0
 public Outputs Create(Inputs inputs)
 {
     LifeCycle lc = new LifeCycle(inputs.SNozzle1,
         inputs.SNozzle2,
         inputs.SNozzle3);
     Cell<double> litersDelivered =
         Accumulate(lc.SStart.Map(_ => Unit.Value),
             inputs.SFuelPulses,
             inputs.Calibration);
     return new Outputs()
         .SetDelivery(lc.FillActive.Map(
             m =>
                 m.Equals(Maybe.Just(Fuel.One)) ? Delivery.Fast1 :
                     m.Equals(Maybe.Just(Fuel.Two)) ? Delivery.Fast2 :
                         m.Equals(Maybe.Just(Fuel.Three)) ? Delivery.Fast3 :
                             Delivery.Off))
         .SetSaleQuantityLcd(litersDelivered.Map(Formatters.FormatSaleQuantity));
 }
Esempio n. 28
0
    // Move, Rotate, UpdatePosition, and UpdateRotation.
    public override Vector3 Move (Inputs inputs, Results current) {
        m_observer.position = current.position;
        float speed = 2;
        if (current.crouching) {
            speed = 1.5f;
        }
        if (current.sprinting) {
            speed = 3;
        }
        if (inputs.vertical > 0) {
            m_verticalSpeed = inputs.vertical * m_jumpHeight;
        } else {
            m_verticalSpeed = inputs.vertical * Physics.gravity.magnitude;
        }
        router.characterController.Move (m_observer.TransformDirection((Vector3.ClampMagnitude(new Vector3(inputs.sides,0,inputs.forward),1) * speed) + new Vector3(0,m_verticalSpeed,0) ) * Time.fixedDeltaTime);
        return m_observer.position;

    }
        public ExecutionResult AssertQuery(
            ISchema schema,
            string query,
            ExecutionResult expectedExecutionResult,
            Inputs inputs,
            object root,
            object userContext = null,
            CancellationToken cancellationToken = default(CancellationToken),
            IEnumerable<IValidationRule> rules = null)
        {
            var runResult = Executer.ExecuteAsync(
                schema,
                root,
                query,
                null,
                inputs,
                userContext,
                cancellationToken,
                rules
                ).Result;

            var writtenResult = Writer.Write(runResult);
            var expectedResult = Writer.Write(expectedExecutionResult);

            #if DEBUG
            Console.WriteLine(writtenResult);
            #endif

            string additionalInfo = null;

            if (runResult.Errors?.Any() == true)
            {
                additionalInfo = string.Join(Environment.NewLine, runResult.Errors
                    .Where(x => x.InnerException is GraphQLSyntaxErrorException)
                    .Select(x => x.InnerException.Message));
            }

            writtenResult.ShouldBe(expectedResult, additionalInfo);

            return runResult;
        }
Esempio n. 30
0
        public async Task<ExecutionResult> ExecuteAsync(
            ISchema schema,
            object root,
            string query,
            string operationName,
            Inputs inputs = null,
            CancellationToken cancellationToken = default( CancellationToken ),
            object userContext = null)
        {
            Document document = _documentBuilder.Build(query);

            ValidationResult validationResult = _documentValidator.IsValid(schema, document, operationName);

            if (!validationResult.IsValid)
            {
                return new ExecutionResult(
                    validationResult.Errors );
            }
            
            Tuple<ExecutionContext, IEnumerable<ExecutionError>> buildResults = BuildExecutionContext( schema, root, document, operationName, inputs, cancellationToken, userContext );
            if( buildResults.Item2 != null )
            {
                return new ExecutionResult(
                    buildResults.Item2 );
            }

            // -------------------------------------------------------------------------------------------------------------------------------------
            // HACK - Need to figure out a way to get rid of this variable and instead return the errors collection during the processing operations...
            // -------------------------------------------------------------------------------------------------------------------------------------
            List<ExecutionError> executionErrors = new List<ExecutionError>();
            IReadOnlyDictionary<string, object> data = await ExecuteOperation( buildResults.Item1, executionErrors );
            if( executionErrors.Count > 0 )
            {
                return new ExecutionResult(
                    data,
                    executionErrors );
            }

            return new ExecutionResult(
                data );
        }
Esempio n. 31
0
        internal static Output Execute(Inputs inputData, _InputsMeta inputMeta)
        {
            Output output = Output.CreateNew();

            try
            {
                // TODO: Implement your algorithm here...
                // You can also write messages to the main window:

                //Inputs m_input = inputData;
                InputDataAdapter m_input = new InputDataAdapter();
                m_input.ReadFromInputData(inputData);

                output.OutputData.P1 = 3 * m_input.VAYPM * m_input.IAWPM * Math.Cos((m_input.VAYPA - m_input.IAWPA) / 180 * Math.PI);
                output.OutputData.Q1 = 3 * m_input.VAYPM * m_input.IAWPM * Math.Sin((m_input.VAYPA - m_input.IAWPA) / 180 * Math.PI);

                output.OutputData.P2 = 3 * m_input.VBYPM * m_input.IBWPM * Math.Cos((m_input.VBYPA - m_input.IBWPA) / 180 * Math.PI);
                output.OutputData.Q2 = 3 * m_input.VBYPM * m_input.IBWPM * Math.Sin((m_input.VBYPA - m_input.IBWPA) / 180 * Math.PI);

                output.OutputData.P3 = 3 * m_input.VAZPM * m_input.ICWPM * Math.Cos((m_input.VAZPA - m_input.ICWPA) / 180 * Math.PI);
                output.OutputData.Q3 = 3 * m_input.VAZPM * m_input.ICWPM * Math.Sin((m_input.VAZPA - m_input.ICWPA) / 180 * Math.PI);

                output.OutputData.P4 = 3 * m_input.VBZPM * m_input.IAXPM * Math.Cos((m_input.VBZPA - m_input.IAXPA) / 180 * Math.PI);
                output.OutputData.Q4 = 3 * m_input.VBZPM * m_input.IAXPM * Math.Sin((m_input.VBZPA - m_input.IAXPA) / 180 * Math.PI);

                //output.OutputData.P5 = 3 * m_input.VAYPM * m_input.IAWPM * Math.Cos((m_input.VAYPA - m_input.IAWPA) / 180 * Math.PI);
                //output.OutputData.Q5 = 3 * m_input.VAYPM * m_input.IAWPM * Math.Sin((m_input.VAYPA - m_input.IAWPA) / 180 * Math.PI);

                //output.OutputData.P6 = 3 * m_input.VAYPM * m_input.IAWPM * Math.Cos((m_input.VAYPA - m_input.IAWPA) / 180 * Math.PI);
                //output.OutputData.Q6 = 3 * m_input.VAYPM * m_input.IAWPM * Math.Sin((m_input.VAYPA - m_input.IAWPA) / 180 * Math.PI);

                StringBuilder _msg = new StringBuilder();
                _msg.AppendLine($" ================ SEL421_PowerCalculator ================");
                _msg.AppendLine($"                 VAY         VBY         VCY");
                _msg.AppendLine($"MAG(kV)  |  {inputData.VAYPM: 000.000}    {inputData.VBYPM: 000.000}    {inputData.VCYPM: 000.000} ");
                _msg.AppendLine($"ANG(deg) |  {inputData.VAYPA: 000.00}    {inputData.VBYPA: 000.00}    {inputData.VCYPA: 000.00} ");
                _msg.AppendLine($"         |       VAZ         VBZ         VCZ");
                _msg.AppendLine($"MAG(kV)  |  {inputData.VAZPM: 000.000}    {inputData.VBZPM: 000.000}    {inputData.VCZPM: 000.000} ");
                _msg.AppendLine($"ANG(deg) |  {inputData.VAZPA: 000.00}    {inputData.VBZPA: 000.00}    {inputData.VCZPA: 000.00} ");
                _msg.AppendLine($"         |       IAW         IBW         ICW");
                _msg.AppendLine($"MAG(kV)  |  {inputData.IAWPM: 000.000}    {inputData.IBWPM: 000.000}    {inputData.ICWPM: 000.000} ");
                _msg.AppendLine($"ANG(deg) |  {inputData.IAWPA: 000.00}    {inputData.IBWPA: 000.00}    {inputData.ICWPA: 000.00} ");
                _msg.AppendLine($"         |       IAX         IBX         ICX");
                _msg.AppendLine($"MAG(kV)  |  {inputData.IAXPM: 000.000}    {inputData.IBXPM: 000.000}    {inputData.ICXPM: 000.000} ");
                _msg.AppendLine($"ANG(deg) |  {inputData.IAXPA: 000.00}    {inputData.IBXPA: 000.00}    {inputData.ICXPA: 000.00} ");

                _msg.AppendLine($"                  MW        MVAR");
                _msg.AppendLine($"PQ1      | {output.OutputData.P1: 000.000}    {output.OutputData.Q1: 000.000}");
                _msg.AppendLine($"PQ2      | {output.OutputData.P2: 000.000}    {output.OutputData.Q2: 000.000}");
                _msg.AppendLine($"PQ3      | {output.OutputData.P3: 000.000}    {output.OutputData.Q3: 000.000}");
                _msg.AppendLine($"PQ4      | {output.OutputData.P4: 000.000}    {output.OutputData.Q4: 000.000}");
                _msg.AppendLine($"PQ5      | {output.OutputData.P5: 000.000}    {output.OutputData.Q5: 000.000}");
                _msg.AppendLine($"PQ6      | {output.OutputData.P6: 000.000}    {output.OutputData.Q6: 000.000}");

                //MainWindow.WriteMessage(_msg.ToString());
            }
            catch (Exception ex)
            {
                // Display exceptions to the main window
                MainWindow.WriteError(new InvalidOperationException($"Algorithm exception: {ex.Message}", ex));
            }

            return(output);
        }
Esempio n. 32
0
 public HWDLineFailReport()
 {
     Inputs.Add(startTime);
     Inputs.Add(endTime);
 }
Esempio n. 33
0
 internal static string key_name(Inputs input)
 {
     return(InputConfig.KeyName(input));
 }
Esempio n. 34
0
 public ObservableInput this[string name]
 {
     get { return(Inputs.FirstOrDefault(g => g.Name == name)); }
 }
Esempio n. 35
0
    // Use this for initialization

    // Update is called once per frame
    void Update()
    {
        if (deactivated && !Player.disabled)
        {
            Player.disabled = true;
        }
        buycoinstext [0].text = GameData.instance.money.ToString();
        buycoinstext [1].text = GameData.instance.coins.ToString();
        if (!finishedThePrompt)
        {
            if (Inputs.pressed("a"))
            {
                finishedThePrompt = true;
                StopAllCoroutines();
                Inputs.dialogueCheck = false;
                dialoguetext.text    = "";
                cursor.SetActive(false);
            }
            if (Inputs.pressed("b"))
            {
                switch (taskType)
                {
                case 0:
                    selectedOption = 1;
                    break;

                case 1:
                    selectedOption = 3;
                    break;
                }
                StopAllCoroutines();
                Inputs.dialogueCheck = false;
                dialoguetext.text    = "";
                cursor.SetActive(false);
                finishedThePrompt = true;
            }



            if (Inputs.pressed("down"))
            {
                selectedOption++;
                switch (taskType)
                {
                case 0:
                    MathE.Clamp(ref selectedOption, 0, 1);
                    cursor.SetPosition(120, 72 - 16 * selectedOption);
                    break;

                case 1:
                    MathE.Clamp(ref selectedOption, 0, 2);
                    cursor.SetPosition(120, 40 - 16 * selectedOption);
                    break;
                }
            }
            if (Inputs.pressed("up"))
            {
                selectedOption--;
                switch (taskType)
                {
                case 0:
                    MathE.Clamp(ref selectedOption, 0, 1);
                    cursor.SetPosition(120, 72 - 16 * selectedOption);
                    break;

                case 1:
                    MathE.Clamp(ref selectedOption, 0, 2);
                    cursor.SetPosition(120, 40 - 16 * selectedOption);
                    break;
                }
            }
        }

        if (GameData.instance.textChoice == 2)
        {
            scrollequation = 3 * 0.016f;
        }
        if (GameData.instance.textChoice == 1)
        {
            scrollequation = 2f * 0.016f;
        }
        if (GameData.instance.textChoice == 0)
        {
            scrollequation = 1f * 0.016f;
        }
    }
Esempio n. 36
0
 void Awake()
 {
     controls = new Inputs();
     UIManager.onChangeValues += uiUpdate;
     UIManager.onStartValues  += uiStart;
 }
Esempio n. 37
0
 public override void InitSequence()
 {
     Outputs.Clear();
     Inputs.Clear();
 }
Esempio n. 38
0
 internal static void lock_repeat(Inputs input_name)
 {
     Input.PlayerOneInputs.LockRepeat(input_name);
 }
Esempio n. 39
0
 private static int held_time(Inputs input_name)
 {
     return(Input.PlayerOneInputs.HeldTime(input_name));
 }
Esempio n. 40
0
 private static bool repeated(Inputs input_name)
 {
     return(Input.PlayerOneInputs.Repeated(input_name));
 }
Esempio n. 41
0
 private static bool pressed(Inputs input_name)
 {
     return(Input.PlayerOneInputs.Pressed(input_name));
 }
Esempio n. 42
0
 private static bool triggered(Inputs input_name)
 {
     return(Input.PlayerOneInputs.Triggered(input_name));
 }
Esempio n. 43
0
        internal async Task <ExecutionResult> Execute(
            object rootObject,
            string query,
            string operationName,
            Inputs inputs,
            IUserContext userContext,
            IDependencyInjector dependencyInjector,
            ComplexityConfiguration complexityConfiguration,
            bool enableValidation = true,
            bool enableProfiling  = false,
            IEnumerable <IValidationRule> rules = null,
            CancellationToken cancellationToken = default,
            IEnumerable <IDocumentExecutionListener> listeners = null)
        {
            if (!enableValidation)
            {
                rules = new[] { new NoopValidationRule() };
            }
            var configuration = new ExecutionOptions
            {
                Schema                  = _schema,
                Root                    = rootObject,
                Query                   = query,
                OperationName           = operationName,
                Inputs                  = inputs,
                UserContext             = UserContextWrapper.Create(userContext, dependencyInjector ?? new WrappedDependencyInjector(_constructor.TypeResolutionDelegate)),
                ValidationRules         = rules != null && rules.Any() ? rules : null,
                ComplexityConfiguration = complexityConfiguration,
                CancellationToken       = cancellationToken,
                ExposeExceptions        = _exposeExceptions
            };

            if (listeners != null && listeners.Any())
            {
                foreach (var listener in listeners)
                {
                    configuration.Listeners.Add(listener);
                }
            }

            if (userContext is IDataLoaderContextProvider)
            {
                configuration.Listeners.Add(new DataLoaderListener());
            }

            if (enableProfiling)
            {
                configuration.FieldMiddleware.Use <InstrumentFieldsMiddleware>();
            }

            foreach (var middleware in _middleware)
            {
                configuration.FieldMiddleware.Use(middleware);
            }

            var result = await _documentExecutor.ExecuteAsync(configuration).ConfigureAwait(false);

            if (result.Errors != null && _errorTransformation != null)
            {
                result.Errors = _errorTransformation.Transform(result.Errors);
            }

            return(result);
        }
        protected override ExecutionOptions GetOptions(string operationName, string query, Inputs variables, IDictionary <string, object> context, CancellationToken cancellationToken)
        {
            var options = base.GetOptions(operationName, query, variables, context, cancellationToken);

            foreach (var configHandler in _configureHandlers)
            {
                configHandler.Configure(options);
            }

            return(options);
        }
Esempio n. 45
0
 public bool Contains(Input input) => Inputs.Contains(input);
Esempio n. 46
0
 /// <summary>
 /// Gets whether an input was pressed on this tick.
 /// </summary>
 public bool Triggered(Inputs inputName)
 {
     return(InputsHeldTime[(int)inputName] == 1);
 }
Esempio n. 47
0
 public ulong CalculateCoinJoinEquality() => CalculateEquality(Inputs.Select(x => x.PrevOutput.Value)) + CalculateEquality(Outputs.Select(x => x.Value));
Esempio n. 48
0
 /// <summary>
 /// Gets whether an input is being held down.
 /// </summary>
 public bool Pressed(Inputs inputName)
 {
     return(InputsHeldTime[(int)inputName] >= 1);
 }
Esempio n. 49
0
    IEnumerator AnimateText(string strComplete)
    {
        Inputs.dialogueCheck = true;
        box.enabled          = true;
        dialoguetext.enabled = true;
        dialoguetext.text    = "";
        dialoguetext.gameObject.SetActive(true);
        indicator.SetActive(false);

        strComplete = strComplete.Replace("<player>", GameData.instance.playerName).Replace("<rival>", GameData.instance.rivalName).Replace("#MON", "POKéMON").Replace("//", "\n").Replace("\n", "\n\n");
        int i = 0;

        if (currentDialogueType != DialogueType.Done)
        {
            str = "";
        }
        else
        {
            str = stringToReveal;
        }
        if (currentDialogueType == DialogueType.Continue)
        {
            str = laststring + "\n\n";
        }
        if (currentDialogueType != DialogueType.Done)
        {
            laststring = strComplete.Substring(strComplete.IndexOf("\n\n") + 2);
        }


        dialoguetext.text = str;

        if (currentDialogueType != DialogueType.Done)
        {
            if (fastText)
            {
                str += strComplete;
                dialoguetext.text = str;
                i = strComplete.Length;
            }
            while (i < strComplete.Length)
            {
                yield return(new WaitForEndOfFrame());

                if (i < strComplete.Length - 1 && strComplete.Substring(i, 2) == "\n\n")        //are we at a double line break?
                {
                    str += strComplete.Substring(i, 2);
                    i   += 2;
                }
                else if (i < strComplete.Length - 1 && strComplete[i] == '<') //is the current character a left bracket?
                {
                    foreach (BracketChar bracketChar in fontAtlas.bracketChars)
                    {
                        string currentBracketChar = "<" + bracketChar.name + ">";
                        if (strComplete.Substring(i).IndexOf(currentBracketChar) == 0) //is the current bracket expression detected the current entry?
                        {
                            str += strComplete.Substring(i, currentBracketChar.Length);
                            i   += currentBracketChar.Length;
                            break;
                        }
                    }
                }
                else
                {
                    str += strComplete[i++];          //if not just add the current character
                }
                dialoguetext.text = str;
                if (!fastText)
                {
                    yield return(new WaitForSeconds(scrollequation));
                }
            }
        }

        if (currentDialogueType == DialogueType.Done)
        {
            indicator.SetActive(true);
            while (!Inputs.pressed("a"))
            {
                yield return(new WaitForSeconds(0.001f));

                if (Inputs.pressed("a"))
                {
                    SoundManager.instance.PlayABSound();
                    break;
                }
            }
            Inputs.dialogueCheck = false;

            if (!keepTextOnScreen)
            {
                box.enabled          = false;
                dialoguetext.text    = "";
                dialoguetext.enabled = false;
                dialoguetext.gameObject.SetActive(false);
            }
            keepTextOnScreen = false;
            indicator.SetActive(false);
            finishedText   = true;
            stringToReveal = "";
        }

        stringToReveal = str;
    }
Esempio n. 50
0
        /* Some noteworthy observations:
         *
         * Output Directory structure:
         * protoc seems designed so that you invoke it once with a list of all .proto source files, but it provides
         * no mechanisms for configuring the structure of the output directory.  The only option you have is to
         * specify base_namespace, in which case the output directory structure is based on the "package" line
         * within the .proto files, or to not specify base_namespace in which case the output directory is flat with
         * no structure at all.  Neither of these options lends itself to allowing protoc to be used in a make-like
         * system which expects to know where to find inputs and outputs so that it can tell when they are out of
         * date.  In order to have msbuild be able to determine the output, given the input, we'd either need to
         * create a task to parse the file (thus eliminating much of the benefit of change-detection in the build
         * system) or have it dump everything in the same directory.  Both options prevent using "DependentUpon"
         * in visual studio which requires that source and target be in the same directory.  In order to mirror
         * the directory structure of the source in the output, we will need to invoke protoc at least once for
         * every unique source path.  Furthermore, even if we used the whole output folder as the output, this
         * will cause problems when .proto files are deleted but their previously-generated .cs files are still
         * around.  Normally we'd instruct msbuild not to compile only the .cs files associated with an extant .proto
         * file but we must know how to map the one to the other in order to do this.
         */
        public override bool Execute()
        {
            OutputFiles = Inputs.Select(inc => new TaskItem
            {
                ItemSpec = inc.GetMetadata("OutputSpec") ?? Path.Combine(Path.GetDirectoryName(inc.ItemSpec), Path.GetFileNameWithoutExtension(inc.ItemSpec).SnakeToPascalCase() + Path.GetExtension(inc.ItemSpec) + ".cs"),
            })
                          .ToArray();

            var    arch        = (RuntimeInformation.ProcessArchitecture.HasFlag(Architecture.X64) ? "x64" : "x86");
            string environment = $"windows_{arch}";
            string executable  = "protoc.exe";

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                environment = $"macosx_{arch}";
                executable  = "protoc";
            }
            else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                environment = $"linux_{arch}";
                executable  = "protoc";
            }

            var protocPath    = Path.Combine(ProtoToolsPath, "tools", environment, executable);
            var protocInclude = Path.Combine(ProtoToolsPath, "tools");

            Log.LogMessage("ProtoToolsPath: {0}", protocPath);

            // We want to mirror the input directory structure to the output directory structure
            // see note above about why we need this and how protoc doesn't support it
            // to do this we must find the distinct list of directories
            var directories = new Directories();

            foreach (var item in Inputs)
            {
                directories.Add(item);
            }

            foreach (var entry in directories)
            {
                var dirPair   = entry.Key;
                var files     = entry.Value;
                var inputs    = string.Join(" ", files.Select(file => $"\"{Path.Combine(dirPair.InputDir, file)}\""));
                var outputDir = Path.Combine(OutputFolder, dirPair.OutputDir);
                var arguments = $" --error_format=msvs -I\"{protocInclude}\" {string.Join(" ", Includes.Split(';').Select(path => $"-I\"{path}\""))} --csharp_out={outputDir} --csharp_opt=file_extension=.proto.cs {inputs}";
                var cmdLine   = $"\"{protocPath}\" {arguments}";
                Log.LogCommandLine(cmdLine);

                if (!Directory.Exists(outputDir))
                {
                    Directory.CreateDirectory(outputDir);
                }

                var psi = new ProcessStartInfo
                {
                    FileName               = protocPath,
                    Arguments              = arguments,
                    CreateNoWindow         = true,
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true,
                    UseShellExecute        = false,
                };
                var proc = Process.Start(psi);
                //gcc error format
                var errorPattern     = new Regex("^(?<file>.*)\\((?<line>[0-9]+)\\) : error in column=(?<column>[0-9]+): (?<message>.*)$|^(?<file>.*):(?<line>[0-9]+):(?<column>[0-9]+): (?<message>.*)$|^(?<option>.*): (?<file>.*): (?<message>.*)$", RegexOptions.Compiled);
                var noLinePattern    = new Regex("^(?<file>[^:]+): (?<message>.*)$", RegexOptions.Compiled);
                var warnPattern      = new Regex("^\\[(?<sourcemodule>.*) (?<level>.*) (?<sourcefile>.*):(?<sourceline>[0-9]+)\\] (?<message>.*)", RegexOptions.Compiled);
                var protoFilePattern = new Regex("proto file: (?<filename>.*\\.proto)", RegexOptions.Compiled);
                var errors           = 0;
                var stdErrTask       = System.Threading.Tasks.Task.Run(() =>
                {
                    string line;
                    while (null != (line = proc.StandardError.ReadLine()))
                    {
                        var match = errorPattern.Match(line);
                        if (match.Success)
                        {
                            var filename  = match.Groups["file"].Value;
                            var lineNum   = ParseInt(match.Groups["line"].Value, 0);
                            var columnNum = ParseInt(match.Groups["column"].Value, 0);
                            var message   = match.Groups["message"].Value;
                            errors++;
                            Log.LogError("protobuf", null, null, filename, lineNum, columnNum, lineNum, columnNum, message, messageArgs: new string[0]);
                            continue;
                        }
                        match = warnPattern.Match(line);
                        if (match.Success)
                        {
                            var message  = match.Groups["message"].Value;
                            var filename = protoFilePattern.Match(message).Groups["filename"].Value;
                            if (filename != null)
                            {
                                Log.LogWarning("protobuf", null, null, filename, 0, 0, 0, 0, "{0}", message);
                            }
                            else
                            {
                                Log.LogWarning("{0}", message);
                            }
                            continue;
                        }
                        match = noLinePattern.Match(line);
                        if (match.Success)
                        {
                            var filename = match.Groups["file"].Value;
                            var message  = match.Groups["message"].Value;
                            errors++;
                            Log.LogError("protobuf", null, null, filename, 0, 0, 0, 0, message, messageArgs: new string[0]);
                            continue;
                        }
                        Log.LogMessageFromText(line, MessageImportance.High);
                    }
                });
                var stdInTask = System.Threading.Tasks.Task.Run(() =>
                {
                    Log.LogMessagesFromStream(proc.StandardOutput, MessageImportance.High);
                });
                proc.WaitForExit();
                System.Threading.Tasks.Task.WaitAll(stdErrTask, stdInTask);
                var exitCode = proc.ExitCode;
                if (exitCode != 0)
                {
                    // if we didn't catch any errors being logged from the output
                    // then just explain that protoc returned a non-zero exit code without telling us anything
                    if (errors == 0)
                    {
                        Log.LogError("protoc returned {0}", exitCode);
                    }
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 51
0
 void Start()
 {
     Inputs.InitHttpReader();
 }
Esempio n. 52
0
 public virtual IEnumerable <TType> InputsFrom <TType>()
 {
     return(Inputs.Select(p => p.GetOutput(this.Node as IConnectableProvider)).OfType <TType>());
 }
Esempio n. 53
0
 public void GpuTransferInput()
 {
     Inputs.ForEach(input => input.Write());
 }
Esempio n. 54
0
 /// <summary>
 /// Samples from model.
 /// </summary>
 /// <param name="inputs">The inputs.</param>
 /// <param name="numberOfSamples">The number of samples.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>The inputs</returns>
 public abstract Inputs SampleFromModel(Inputs inputs, int numberOfSamples, params object[] parameters);
Esempio n. 55
0
 /// <summary>
 /// Gets whether an input was released on this tick.
 /// </summary>
 public bool Released(Inputs inputName)
 {
     return(InputsReleased[(int)inputName] && InputsHeldTime[(int)inputName] == 0);
 }
Esempio n. 56
0
 public virtual TType InputFrom <TType>()
 {
     return(Inputs.Select(p => p.GetOutput(this.Node as IConnectableProvider)).OfType <TType>().FirstOrDefault());
 }
Esempio n. 57
0
 /// <summary>
 /// Gets the time an input has been held down.
 /// </summary>
 public int HeldTime(Inputs inputName)
 {
     return(InputsHeldTime[(int)inputName]);
 }
Esempio n. 58
0
 protected override void CalculateResult()
 {
     Result = !Inputs.First();
 }
Esempio n. 59
0
 internal static Buttons PadRedirect(Inputs input)
 {
     return(InputConfig.PadRedirect[input]);
 }
Esempio n. 60
0
        public double[] calculateOutput(bool isTraining, bool probValue = false)
        {
            if (Factory.ProgresReport.BestSolution == null)
            {
                return(null);
            }
            //
            var ch  = Factory.ProgresReport.BestSolution;//.expressionTree;
            var par = Factory.Parameters;

            if (par.RootFunctionNode == null)
            {
                setLearningType(par);
            }
            double[] yc = null;
            if (ch != null)
            {
                yc = Inputs.CalculateOutput(ch, par, isTraining);//gp

                //no testing data set
                if (yc == null)
                {
                    return(null);
                }

                //de normalize output
                double[] output = yc;
                for (int i = 0; i < yc.Length; i++)
                {
                    //calculate de normalization
                    if (ExpData.GetOutputColumnType() == ColumnType.Numeric)
                    {
                        double[] normRow = new double[1] {
                            yc[i]
                        };
                        output[i] = ExpData.GetDecodedOutputRow(normRow)[0];
                    }
                    else
                    {
                        if (par.RootFunctionNode.Id == 2048) //sigmoid
                        {
                            if (probValue)                   //when model is evaluate we need probability f event in order to optimize threshold value
                            {
                                output[i] = yc[i];
                            }
                            else
                            {
                                output[i] = yc[i] > par.RootFunctionNode.Parameter ? 1 : 0;
                            }
                        }
                        else if (par.RootFunctionNode.Id == 2050)//step
                        {
                            output[i] = Math.Truncate(yc[i]);
                        }
                        else
                        {
                            output[i] = Math.Truncate(yc[i]);
                        }
                    }
                }
                return(output);
            }
            return(null);//no solution yet
        }