Esempio n. 1
0
        private void ProcessDemand(
            XmlElement element,
            DiplomacyActionWeights.DiplomacyActionWeight weight)
        {
            DemandType demandType = (DemandType)Enum.Parse(typeof(DemandType), element.GetAttribute("type"));

            weight.Type = (object)demandType;
        }
 /// <summary>
 /// Marks a public property on an RDMP plugin class as editable by the user.  The user can pick a value at design time for use with the plugin e.g. in
 /// a <see cref="Pipeline"/> then when the pipeline is run your class will be instantiated and all properties will be
 /// hydrated from the corresponding <see cref="IArgument"/>s.
 /// </summary>
 /// <param name="description"></param>
 /// <param name="demandType"></param>
 /// <param name="defaultValue"></param>
 /// <param name="typeOf"></param>
 /// <param name="mandatory"></param>
 public DemandsInitializationAttribute(string description, DemandType demandType = DemandType.Unspecified, object defaultValue = null, Type typeOf = null, bool mandatory = false)
 {
     Description  = description;
     DemandType   = demandType;
     DefaultValue = defaultValue;
     TypeOf       = typeOf;
     Mandatory    = mandatory;
 }
Esempio n. 3
0
        public override IModel Factory(object obj)
        {
            try
            {
                Demand     demand = (Demand)obj;
                DemandType type   = DemandType.house;
                int        rid    = 0;

                if (demand.Lands.Count != 0)
                {
                    rid  = demand.Lands.First().Id;
                    type = DemandType.land;
                }


                if (demand.Flats.Count != 0)
                {
                    rid  = demand.Flats.First().Id;
                    type = DemandType.flat;
                }


                if (demand.Houses.Count != 0)
                {
                    rid  = demand.Houses.First().Id;
                    type = DemandType.house;
                }


                return(new DemandModel()
                {
                    Id = demand.Id,
                    db = db,
                    Longtitude = demand.Longutude,
                    Lantitude = demand.Latitude,
                    City = demand.City,
                    Street = demand.Street,
                    Adress = demand.Adress,
                    FlatNumber = demand.Flatnumber,
                    demandType = type,
                    FlatFloors = demand.Flats.Count == 0 ? null : demand.Flats.First().Floor,
                    FlatRooms = demand.Flats.Count == 0 ? null : demand.Flats.First().Roomscount,
                    FlatArea = demand.Flats.Count == 0 ? null : demand.Flats.First().Area,
                    LandArea = demand.Lands.Count == 0 ? null : demand.Lands.First().Area,
                    HouseFloors = demand.Houses.Count == 0 ? null : demand.Houses.First().Floorscount,
                    HouseRooms = demand.Houses.Count == 0 ? null : demand.Houses.First().Roomscount,
                    HouseArea = demand.Houses.Count == 0 ? null : demand.Houses.First().Area,
                    referenceId = rid
                });
            }
            catch (Exception)
            {
                return(CreateInstance());

                throw;
            }
        }
Esempio n. 4
0
        //------ Set output routines. ----------//

        /** Sets the motor output and takes inversion into account */
        public virtual void Set(ControlMode controlMode, float output0, DemandType demand1Type = DemandType.Neutral, float output1 = 0)
        {
            _motor.Set(controlMode, output0, demand1Type, output1);

            foreach (var follower in _followers)
            {
                follower.ValueUpdated();
            }
        }
Esempio n. 5
0
 public DemandScalarDialog(App game, DemandType type, int otherPlayer, string template = "dialogRequestScalar")
     : base(game, template)
 {
     this._otherPlayer             = otherPlayer;
     this._type                    = type;
     this._demand                  = new DemandInfo();
     this._demand.InitiatingPlayer = game.LocalPlayer.ID;
     this._demand.ReceivingPlayer  = this._otherPlayer;
     this._demand.State            = AgreementState.Unrequested;
     this._demand.Type             = type;
 }
Esempio n. 6
0
 public ComparedCommodity(string commodity, int amount, CommodityPrice ourPrice, CommodityPrice theirPrice)
 {
     this.commodity = commodity;
     if (ourPrice != null)
     {
         priceBuy  = ourPrice.priceBuy;
         priceSell = ourPrice.priceSell;
         demand    = ourPrice.demandType;
         if (theirPrice != null && theirPrice.priceSell > 0 && ourPrice.priceBuy > 0)
         {
             profitPer = theirPrice.priceSell - ourPrice.priceBuy;
         }
     }
     profit = profitPer * amount;
 }
Esempio n. 7
0
        /**
         * @param mode Sets the appropriate output on the talon, depending on the mode.
         * @param demand0 The output value to apply.
         *  such as advanced feed forward and/or auxiliary close-looping in firmware.
         * In PercentOutput, the output is between -1.0 and 1.0, with 0.0 as stopped.
         * In Current mode, output value is in amperes.
         * In Velocity mode, output value is in position change / 100ms.
         * In Position mode, output value is in encoder ticks or an analog value,
         *   depending on the sensor. See
         * In Follower mode, the output value is the integer device ID of the talon to
         * duplicate.
         *
         * @param demand1Type The demand type for demand1.
         * Neutral: Ignore demand1 and apply no change to the demand0 output.
         * AuxPID: Use demand1 to set the target for the auxiliary PID 1.
         * ArbitraryFeedForward: Use demand1 as an arbitrary additive value to the
         *	 demand0 output.  In PercentOutput the demand0 output is the motor output,
         *   and in closed-loop modes the demand0 output is the output of PID0.
         * @param demand1 Supplmental output value.  Units match the set mode.
         *
         *
         *  Arcade Drive Example:
         *		_talonLeft.set(ControlMode.PercentOutput, joyForward, DemandType.ArbitraryFeedForward, +joyTurn);
         *		_talonRght.set(ControlMode.PercentOutput, joyForward, DemandType.ArbitraryFeedForward, -joyTurn);
         *
         *	Drive Straight Example:
         *	Note: Selected Sensor Configuration is necessary for both PID0 and PID1.
         *		_talonLeft.follow(_talonRght, FollwerType.AuxOutput1);
         *		_talonRght.set(ControlMode.PercentOutput, joyForward, DemandType.AuxPID, desiredRobotHeading);
         *
         *	Drive Straight to a Distance Example:
         *	Note: Other configurations (sensor selection, PID gains, etc.) need to be set.
         *		_talonLeft.follow(_talonRght, FollwerType.AuxOutput1);
         *		_talonRght.set(ControlMode.MotionMagic, targetDistance, DemandType.AuxPID, desiredRobotHeading);
         */
        public void Set(ControlMode mode, double demand0, DemandType demand1Type, double demand1)
        {
            m_controlMode = mode;
            m_sendMode    = mode;
            int work;

            switch (m_controlMode)
            {
            case ControlMode.PercentOutput:
                // case TimedPercentOutput:
                _ll.Set(m_sendMode, demand0, demand1, (int)demand1Type);
                break;

            case ControlMode.Follower:
                /* did caller specify device ID */
                if ((0 <= demand0) && (demand0 <= 62))
                {     // [0,62]
                    work   = GetBaseID();
                    work >>= 16;
                    work <<= 8;
                    work  |= ((int)demand0) & 0xFF;
                }
                else
                {
                    work = (int)demand0;
                }

                /* single precision guarantees 16bits of integral precision,
                 * so float/double cast on work is safe */
                _ll.Set(m_sendMode, (double)work, demand1, (int)demand1Type);
                break;

            case ControlMode.Velocity:
            case ControlMode.Position:
            case ControlMode.MotionMagic:
            case ControlMode.MotionProfile:
            case ControlMode.MotionProfileArc:
                _ll.Set(m_sendMode, demand0, demand1, (int)demand1Type);
                break;

            case ControlMode.Disabled:
            /* fall thru... */
            default:
                _ll.SetDemand(m_sendMode, 0, 0);
                break;
            }
        }
 public DemandSystemSelectDialog(App game, DemandType type, int otherPlayer, string template = "dialogRequestSystemSelect")
     : base(game, template)
 {
     this._otherPlayer             = otherPlayer;
     this._type                    = type;
     this._demand                  = new DemandInfo();
     this._demand.InitiatingPlayer = game.LocalPlayer.ID;
     this._demand.ReceivingPlayer  = this._otherPlayer;
     this._demand.State            = AgreementState.Unrequested;
     this._demand.Type             = type;
     this._crits                   = new GameObjectSet(game);
     this._sky = new Sky(game, SkyUsage.StarMap, 0);
     this._crits.Add((IGameObject)this._sky);
     this._starmap = new StarMap(game, game.Game, this._sky);
     this._crits.Add((IGameObject)this._starmap);
     this._starmap.SetCamera(game.Game.StarMapCamera);
 }