Beispiel #1
0
        /// <summary>
        /// Creates the proxy parameters. This struct is created only if the proxy is required.
        /// </summary>
        /// <returns>The struct containing the proxy parameters.</returns>
        private BasicParameters CreateProxyParameters()
        {
            try
            {
                var ub = new UriBuilder(this.DataManager.Configuration.ProxySettings.InternetAddress.Url)
                {
                    Port =
                        (int)
                        this
                        .DataManager
                        .Configuration
                        .ProxySettings
                        .InternetAddress
                        .Port
                };

                var proxyParameters = new BasicParameters(
                    ub.Uri.ToString(),
                    this.DataManager.Configuration.ProxySettings.Authentication.Active,
                    this.DataManager.Configuration.ProxySettings.Authentication.User,
                    this.DataManager.Configuration.ProxySettings.Authentication.Password);

                return(proxyParameters);
            }
            catch (Exception exception)
            {
                Logger.ErrorException(this, "CreateProxyParameters: error creating proxy parameters.", exception);
                DiagnosticsCollection.Instance.AddMessage("CreateProxyParameters: error creating proxy parameters.");
                DiagnosticsCollection.Instance.AddMessage(exception);
                throw;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Get device status register and system basic configuration parameters.
        /// </summary>
        /// <returns>Return a BasicParameters object that consist system parameters and registers</returns>
        public async Task <BasicParameters> ReadSystemParameter()
        {
            try
            {
                var packet = new Packet(_deviceAddress, PacketSizes.ReadSystemParameterLen);
                packet.Write(0x01);
                packet.Write(0x00);
                packet.Write(0x03);
                packet.Write(InstructionCodes.ReadSysParameter);
                packet.Write(packet.CalculateCheckSum());

                var result = await _packageManager.SendPacket(packet);

                var resultOfMethod = new BasicParameters
                {
                    StatusRegister       = TypeConverter.ToUnInt16(result.ReadBytes(10, 2)),
                    SystemIdentifierCode = TypeConverter.ToUnInt16(result.ReadBytes(12, 2)).ToString(),
                    FingerLibrarySize    = TypeConverter.ToUnInt16(result.ReadBytes(14, 2)),
                    DeviceAddress        = TypeConverter.ToUnInt32(result.ReadBytes(18, 4)).ToString(),
                    DevicePacketSize     = TypeConverter.ToUnInt16(result.ReadBytes(22, 2)),
                    BaudSetting          = TypeConverter.ToUnInt16(result.ReadBytes(24, 2))
                };

                if (result.Read(9) == ReturnCode.Ok)
                {
                    return(resultOfMethod);
                }
                throw new Exception("[Error] when receiving package -->[FingerPrint_ReadSystemParameter]");
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + "-->[FingerPrint_ReadSystemParameter]", ex.InnerException);
            }
        }
        public async Task <BaseResponse> GetBasicListAsync(BasicParameters parameters)
        {
            BaseServiceRequest <BaseResponse> baseService = new BaseServiceRequest <BaseResponse>();
            var r = await baseService.GetRequest(new BasicQueryRequest()
            {
                parameters = parameters
            }, Method.GET);

            return(r);
        }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RequestParameters" /> struct.
 /// </summary>
 /// <param name="basicParameters">The basic parameters.</param>
 /// <param name="proxyRequired">if set to <c>true</c> [proxy required].</param>
 /// <param name="proxyParameters">The proxy parameters.</param>
 /// <param name="method">The method.</param>
 /// <param name="contentType">Type of the content.</param>
 /// <param name="webTimeout">The web timeout.</param>
 /// <param name="body">The body.</param>
 public RequestParameters(BasicParameters basicParameters, bool proxyRequired, BasicParameters proxyParameters, string method, string contentType, int webTimeout, string body)
     : this()
 {
     this.basicParameters = basicParameters;
     this.proxyRequired   = proxyRequired;
     this.proxyParameters = proxyParameters;
     this.method          = method;
     this.contentType     = contentType;
     this.webTimeout      = webTimeout;
     this.body            = body;
 }
Beispiel #5
0
        /// 描画処理
        public override bool DoDraw(DemoGame.GraphicsDevice graphDev)
        {
            GameCtrlManager ctrlResMgr = GameCtrlManager.GetInstance();

            Matrix4 worldMatrix = baseMtx * Matrix4.Scale(new Vector3(0.85f, 0.85f, 0.85f));

            worldMatrix.M42 -= objWidth;

            Vector3 EmitColor     = new Vector3(1.0f, 1.0f, 1.0f);
            Vector3 litDirection  = new Vector3(1.0f, -1.0f, -1.0f).Normalize();
            Vector3 litDirection2 = new Vector3(0.0f, 1.0f, 0.0f).Normalize();
            Vector3 litColor      = new Vector3(1.0f, 1.0f, 1.0f);
            Vector3 litColor2     = new Vector3(1.0f, 0.0f, 0.0f);
            Vector3 litAmbient    = new Vector3(0.0f, 0.0f, 0.0f);
            Vector3 fogColor      = new Vector3(0.0f, 0.5f, 1.0f);

            BasicParameters parameters = program.Parameters;

            parameters.Enable(BasicEnableMode.Lighting, true);
            parameters.Enable(BasicEnableMode.Fog, false);
            parameters.SetProjectionMatrix(ref ctrlResMgr.CtrlCam.GetCurrentCameraCore().Projection);
            parameters.SetViewMatrix(ref ctrlResMgr.CtrlCam.GetCurrentCameraCore().View);

            parameters.SetLightCount(1);
            parameters.SetLightDirection(0, ref litDirection);
            parameters.SetLightDiffuse(0, ref litColor);
            parameters.SetLightSpecular(0, ref litColor);
            parameters.SetLightAmbient(ref litAmbient);
            parameters.SetMaterialEmission(ref EmitColor);

            graphDev.Graphics.Enable(EnableMode.Blend);
            graphDev.Graphics.SetBlendFunc(BlendFuncMode.Add, BlendFuncFactor.SrcAlpha, BlendFuncFactor.OneMinusSrcAlpha);
            graphDev.Graphics.Enable(EnableMode.CullFace);
            graphDev.Graphics.SetCullFace(CullFaceMode.Back, CullFaceDirection.Ccw);
            graphDev.Graphics.Enable(EnableMode.DepthTest);
            graphDev.Graphics.SetDepthFunc(DepthFuncMode.LEqual, true);

            /*
             * titanModel.SetWorldMatrix( ref worldMatrix ) ;
             * titanModel.Update();
             * titanModel.Draw(graphDev.Graphics , program);
             */


//        Matrix4 mtx = GetBoneMatrix( 1 );
//        Common.VectorUtil.Set( ref BodyPos, mtx.M41, mtx.M42, mtx.M43 );

            return(true);
        }
Beispiel #6
0
        /// <summary>
        /// Creates the parameters for the FIS request.
        /// </summary>
        /// <param name="parameters">The parameters.</param>
        /// <param name="uriSpecific">The URI specific part, registration or data send.</param>
        /// <param name="body">The body of the HTTP request.</param>
        /// <param name="firstRegistration">if set to <c>true</c> [first registration].</param>
        /// <param name="exception">The exception.</param>
        /// <returns><c>true</c> if the parameters could be created, <c>false</c> otherwise. In case of false an additional exception is returned.</returns>
        private bool CreateFisRequestParameters(out FisCommunication.Http.RequestParameters parameters, string uriSpecific, string body, out bool firstRegistration, out Exception exception)
        {
            bool result;

            parameters = default(FisCommunication.Http.RequestParameters);
            var uri      = this.DataManager.Configuration.FisSettings.InternetAddress.Url;
            var user     = this.DataManager.Configuration.FisSettings.Authentication.User;
            var password = this.DataManager.Configuration.FisSettings.Authentication.Password;

            // It must be checked here whether we are requesting a first registration or not.
            firstRegistration = this.FisFirstRegistrationRequired(ref user, ref password);

            if (string.IsNullOrEmpty(uri) || string.IsNullOrEmpty(user) || string.IsNullOrEmpty(password))
            {
                exception =
                    new Exception(
                        "Cannot register Gateway to FIS. Missing FIS internet address, User or Password.");
                parameters = default(FisCommunication.Http.RequestParameters);

                Logger.ErrorException(this, "Error during Gateway registration to FIS.", exception);
                DiagnosticsCollection.Instance.AddMessage("Error during Gateway registration to FIS.");
                DiagnosticsCollection.Instance.AddMessage(exception);

                result = false;
            }
            else
            {
                exception = null;
                var completeUri = uri + uriSpecific;

                var basicParameters = new BasicParameters(completeUri, true, user, password);
                var proxyParameters = default(BasicParameters);

                if (this.DataManager.Configuration.ProxySettings.Enabled)
                {
                    try
                    {
                        proxyParameters = this.CreateProxyParameters();
                    }
                    catch (Exception ex)
                    {
                        exception = ex;
                        Logger.ErrorException(this, "CreateFisRegistrationParameters: error creating proxy parameters.", exception);
                        DiagnosticsCollection.Instance.AddMessage("CreateFisRegistrationParameters: error creating proxy parameters.");
                        DiagnosticsCollection.Instance.AddMessage(exception);
                        return(false);
                    }
                }

                parameters =
                    new FisCommunication.Http.RequestParameters(
                        basicParameters,
                        this.DataManager.Configuration.ProxySettings.Enabled,
                        proxyParameters,
                        CommonFormat.FisRegistrationMethod,
                        CommonFormat.FisRegistrationContentType,
                        CommonFormat.FisRegistrationWebTimeout,
                        body);
                result = true;
            }

            return(result);
        }
            public void Boarding(Vessel enemy)
            {
                int ourPower   = BasicParameters.BoardingPower(this);
                int enemyPower = BasicParameters.BoardingPower(enemy);

                int    winnerPower;
                int    winnerPowerStart;
                Vessel winner;
                Vessel looser;

                int[] winningCrew;

                if (ourPower != enemyPower)
                {
                    if (ourPower > enemyPower)
                    {
                        winnerPower      = ourPower - enemyPower;
                        winnerPowerStart = ourPower;
                        winner           = this;
                        looser           = enemy;
                    }
                    else
                    {
                        winnerPower      = enemyPower - ourPower;
                        winnerPowerStart = enemyPower;
                        winner           = enemy;
                        looser           = this;
                    }

                    winningCrew = BasicParameters.CrewRest(winnerPowerStart, winnerPower, winner.CrewTypes, winner.Crew);

                    for (var i = 0; i < winner.CrewTypes.Length; i++)
                    {
                        winner.GetCrew(winner.CrewTypes[i], -(winner.CrewMax[i]));
                        winner.GetCrew(winner.CrewTypes[i], winningCrew[i]);
                    }
                }
                else
                {
                    if (this == enemy)
                    {
                        looser = this;
                    }
                    else
                    {
                        Random randomizer = new Random();

                        if (randomizer.Next(0, 1) == 0)
                        {
                            winner = this;
                            looser = enemy;
                        }
                        else
                        {
                            winner = enemy;
                            looser = this;
                        }

                        winningCrew = BasicParameters.CrewRest(45, winner.CrewTypes, winner.Crew);

                        for (var i = 0; i < winner.CrewTypes.Length; i++)
                        {
                            winner.GetCrew(winner.CrewTypes[i], -(winner.CrewMax[i]));
                            winner.GetCrew(winner.CrewTypes[i], winningCrew[i]);
                        }
                    }
                }

                for (var i = 0; i < looser.CrewTypes.Length; i++)
                {
                    looser.GetCrew(looser.CrewTypes[i], -(looser.CrewMax[i]));
                }
            }
Beispiel #8
0
 public static DomRobotResult Execute(DomrobotClient drc, BasicParameters parameters)
 {
     return(drc.Do(parameters));
 }
Beispiel #9
0
 public DomRobot(BasicParameters parameters)
 {
     Parameter = parameters;
 }