示例#1
0
 public PersonManager(IFactory factory)
 {
     this.footballDBManager = factory.GetFootballDBManager();
     this.adaptor           = factory.GetAdaptor();
 }
示例#2
0
 public TimeKeeper.TasksDataTable GetTasksByProjectIDByUserIDByDate(int projectID, int userID, DateTime date)
 {
     return(Adaptor.GetTasksByProjectIDByUserID(projectID, userID));
 }
示例#3
0
 public MessageFormatCommand(Adaptor adaptor)
     : base(adaptor)
 {
 }
示例#4
0
 public TimeKeeper.TasksDataTable GetTaskByTaskID(int taskID)
 {
     return(Adaptor.GetTaskByTaskID(taskID));
 }
示例#5
0
 public TimeKeeper.TasksDataTable GetProjectsForUser(int userID)
 {
     return(Adaptor.GetProjectsForUser(userID));
 }
示例#6
0
 public decimal TotalTimeByUserIDByDateRange(int userID, DateTime start, DateTime end)
 {
     return(Convert.ToDecimal(Adaptor.TotalTimeByUserIDByDateRange(userID, start, end)));
 }
示例#7
0
 public decimal TotalTimeByUserIDByProjectID(int userID, int projectID)
 {
     return(Convert.ToDecimal(Adaptor.TotalTimeByUserIDByProjectID(userID, projectID)));
 }
示例#8
0
 public SignalQualityCommand(Adaptor adaptor)
     : base(adaptor)
 {
 }
示例#9
0
 /// <summary>
 /// Notifies adaptors on adding widget to this container
 /// </summary>
 /// <param name="o">
 /// Widget added to this container <see cref="System.Object"/>
 /// </param>
 /// <param name="a">
 /// Added arguments <see cref="AddedArgs"/>
 /// </param>
 private void NotifyAdaptorsOnAdd(object o, AddedArgs a)
 {
     Adaptor.SendAdaptorMessage((object)a.Widget, EActionType.RenewParents);
 }
示例#10
0
        protected override void startGame()
        {
            drawOnNextMove = false;
            gotResult      = false;
            forceMode      = false;
            nextMove       = null;

            //	send the "new" command
            Write("new");

            //	send the "variant" command?
            if (Game.Name != "Chess")
            {
                //	Inform the engine of the variant we are playing.  If we are using
                //	an EngineGameAdaptor, use the name specified in the adaptor
                //	(which is the game the engine thinks we are playing.)
                Write("variant " + (Adaptor != null ? Adaptor.XBoardName : Game.GameAttribute.XBoardName));
            }

            //	send the "setboard" command?
            if ((Game.GameAttribute.TagList != null && Game.GameAttribute.TagList.Contains("Random Array")) ||
                (Adaptor != null && Adaptor.IssueSetboard))                  //	||  board()->fenString() != board()->defaultFenString())
            {
                SetBoard(Adaptor != null ? Adaptor.TranslateFEN(Game.FENStart) : Game.FENStart);
            }

            //	send the time controls
            TimeControl myTc = TimeControl;

            if (myTc.Infinite)
            {
                if (myTc.PlyLimit == 0 && myTc.NodeLimit == 0)
                {
                    Write(string.Format("st {0}", infiniteSec));
                }
            }
            else if (myTc.TimePerMove > 0)
            {
                Write(string.Format("st {0}", myTc.TimePerMove / 1000));
            }
            else
            {
                Write(string.Format("level {0} {1} {2}", myTc.MovesPerTC, msToXboardTime(myTc.TimePerTC), (double)myTc.TimeIncrement / 1000.0));
            }

            if (myTc.PlyLimit > 0)
            {
                Write(string.Format("sd {0}", myTc.PlyLimit));
            }
            if (myTc.NodeLimit > 0)
            {
                if (ftNps)
                {
                    Write(string.Format("st 1\nnps {0}", myTc.NodeLimit));
                }
                else
                {
                    throw new Exception("Engine doesn't support the nps command");
                }
            }

            //	send the "post" command to show thinking
            Write("post");

            //	send the "easy" command to disable pondering
            Write("easy");
            setForceMode(true);

            //	inform the engine of the opponent's type and name
            if (ftName)
            {
                if (!Opponent.IsHuman)
                {
                    Write("computer");
                }
                Write("name " + Opponent.Name);
            }

            //	if the Game has any moves already played, send them
            //	now while we are in "force" mode
            List <Movement> moves = new List <Movement>();

            for (int nMove = 0; nMove < Game.GameMoveNumber; nMove++)
            {
                int      turnNumber;
                MoveInfo moveMade = Game.GetHistoricalMove(nMove, out turnNumber);
                //	we do not play the moves one-by-one but first accumulate all the
                //	moves by the same player to accomodate multi-move variants
                if (moves.Count > 0 && moves[0].Player != moveMade.Player)
                {
                    MakeMove(moves);
                    moves.Clear();
                }
                moves.Add(moveMade);
            }
            if (moves.Count > 0)
            {
                MakeMove(moves);
            }
        }
示例#11
0
        protected override void parseLine(string line)
        {
            int cursor;

            if (line.IndexOf("pong") > 0)
            {
                char a0 = line[0];
                char a1 = line[1];
                char a2 = line[2];
                char a3 = line[3];
                char a4 = line[4];
                char a5 = line[5];
                char a6 = line[6];
                int  q  = 0;
            }
            string command = firstToken(line, out cursor);

            if (command.Trim() == "")
            {
                return;
            }

            //	check for game ending commands
            if (command == "1-0" || command == "0-1" || command == "*" || command == "1/2-1/2" || command == "resign")
            {
                if ((State != PlayerState.Thinking && State != PlayerState.Observing) || Game.Result.IsNone)
                {
                    finishGame();
                    return;
                }

                string description = nextToken(command, ref cursor, true);
                if (description != null)
                {
                    if (description.Length >= 1 && description[0] == '{')
                    {
                        description = description.Substring(1);
                    }
                    if (description.Length >= 1 && description[description.Length - 1] == '}')
                    {
                        description = description.Substring(0, description.Length - 1);
                    }
                }

                if (command == "*")
                {
                    claimResult(new Result(ResultType.NoResult, -1, description));
                }
                else if (command == "1/2-1/2")
                {
                    if (State == PlayerState.Thinking && false /* && ClaimsValidated */)
                    {
                        // The engine claims that its next move will draw the game
                        drawOnNextMove = true;
                    }
                    else
                    {
                        claimResult(new Result(ResultType.Draw, -1, description));
                    }
                }
                else if ((command == "1-0" && Side == 0) || (command == "0-1" && Side == 1))
                {
                    claimResult(new Result(ResultType.Win, Side, description));
                }
                else
                {
                    forfeit(ResultType.Resignation);
                }

                return;
            }
            else if (Char.IsDigit(command[0]))                // principal variation
            {
                bool ok  = false;
                int  val = 0;

                Dictionary <string, string> thinking = new Dictionary <string, string>();

                // Search depth
                ok = Int32.TryParse(command, out val);
                if (!ok)
                {
                    return;
                }
                Evaluation.Depth = val;
                thinking.Add("Depth", command);

                // Evaluation
                if ((command = nextToken(line, ref cursor)) == null)
                {
                    return;
                }
                ok = Int32.TryParse(command, out val);
                if (ok)
                {
                    if (WhiteEvalPov && Side == 1)
                    {
                        val = -val;
                    }
                    Evaluation.Score = val;
                }
                thinking.Add("Score", xboardScoreToString(val));

                // Search time
                if ((command = nextToken(line, ref cursor)) == null)
                {
                    return;
                }
                ok = Int32.TryParse(command, out val);
                if (ok)
                {
                    Evaluation.Time = val * 10;
                }
                thinking.Add("Time", xboardTimeToString(val * 10));

                // Node count
                if ((command = nextToken(line, ref cursor)) == null)
                {
                    return;
                }
                ok = Int32.TryParse(command, out val);
                if (ok)
                {
                    Evaluation.NodeCount = val;
                }
                thinking.Add("Nodes", xboardNodesToString(val));

                // Principal variation
                if ((command = nextToken(line, ref cursor, true)) == null)
                {
                    return;
                }
                string pv = TranslatePVString(command);
                if (Adaptor != null)
                {
                    command = Adaptor.TranslatePV(pv, false);
                }
                Evaluation.PV = pv;
                thinking.Add("PV", pv);

                Game.ThinkingCallback(thinking);

                return;
            }

            string args = nextToken(line, ref cursor, true);

            if (command == "move")
            {
                if (State != PlayerState.Thinking)
                {
                    if (State == PlayerState.FinishingGame)
                    {
                        finishGame();
                    }
                    else
                    {
                        ;                        //qDebug("Unexpected move from %s", qPrintable(name()));
                    }
                    return;
                }

                if (Adaptor != null)
                {
                    args = Adaptor.TranslateMove(args, false);
                }
                Movement move = Game.MoveFromDescription(args, MoveNotation.XBoard);
                if (move == null)
                {
                    forfeit(ResultType.IllegalMove, args);
                    return;
                }

                if (drawOnNextMove)
                {
                    drawOnNextMove = false;
                    Result boardResult;
                    Game.MakeMove(move, true);
                    boardResult = Game.Result;
                    Game.UndoMove();

                    //	If the engine claimed a draw before this move, the
                    //	game must have ended in a draw by now
                    if (!boardResult.IsDraw)
                    {
                        claimResult(new Result(ResultType.Draw));
                        return;
                    }
                }

                emitMove(new List <Movement>()
                {
                    move
                });
            }
            else if (command == "pong")
            {
                int pingarg;
                if (Int32.TryParse(args, out pingarg))
                {
                    if (pingarg == lastPing)
                    {
                        pong(null, null);
                    }
                }
            }
            else if (command == "feature")
            {
                MatchCollection matches = Regex.Matches(args, "\\w+\\s*=\\s*(\"[^\"]*\"|\\d+)");
                foreach (System.Text.RegularExpressions.Match match in matches)
                {
                    string[] split = match.Value.Split('=');
                    if (split.Length != 2)
                    {
                        continue;
                    }
                    string feature = split[0].Trim();
                    string val     = split[1].Trim();
                    val = val.Replace("\"", "");
                    setFeature(feature, val);
                }
            }
            else if (command == "Error")
            {
                // If the engine complains about an unknown result command,
                // we can assume that it's safe to finish the game.
                if (args.IndexOf(':') >= 0)
                {
                    string str = args.Substring(args.IndexOf(':') + 1).Trim();
                    if (str.Length >= 6 && str.Substring(0, 6) == "result")
                    {
                        finishGame();
                    }
                }
            }
        }
 /// <summary>
 /// Gets the nullable yes no.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 protected static string getNullableYesNo(bool?value)
 {
     return((value.HasValue) ? Adaptor.toYesNo(value.Value) : PROGRAM_DETERMINED);
 }
 public ReadMessageCommand(Adaptor adaptor, int index, MessageFormatType messageFormatType)
     : base(adaptor)
 {
     _Index             = index;
     _MessageFormatType = messageFormatType;
 }
 public ReadMessageCommand(Adaptor adaptor, int index)
     : base(adaptor)
 {
     _Index = index;
 }
示例#15
0
 public TimeKeeper.TasksDataTable GetTasksByUserIDByDateRange(int userID, DateTime start, DateTime end)
 {
     return(Adaptor.GetTasksByUserIDByDateRange(userID, start, end));
 }
示例#16
0
        public virtual ValidationResult ValidateExpression(int frameIndex, string expression, EvaluationOptions options)
        {
            var ctx = GetEvaluationContext(frameIndex, options);

            return(Adaptor.ValidateExpression(ctx, expression));
        }
示例#17
0
 public decimal TotalTimeByUserIDByDate(int userID, DateTime date)
 {
     return(Convert.ToDecimal(Adaptor.TotalTimeByUserIDByDate(userID, date)));
 }
示例#18
0
 public AttentionCommand(Adaptor adaptor)
     : base(adaptor)
 {
 }
示例#19
0
 public decimal TotalTimeByProjectID(int projectID)
 {
     return(Convert.ToDecimal(Adaptor.TotalTimeByProjectID(projectID)));
 }
示例#20
0
 public ServiceCentreAddress(Adaptor adaptor)
     : base(adaptor)
 {
 }
示例#21
0
 public TimeKeeper.TasksDataTable GetTasks()
 {
     return(Adaptor.GetTasks());
 }
        protected override ObjectValue[] GetChildrenSafe(ObjectPath path, int index, int count,
                                                         IEvaluationOptions options)
        {
            var allocatorTempObject     = Evaluate("global::Unity.Collections.Allocator.Temp");
            var componentDataType       = GetType("Unity.Entities.IComponentData").NotNull();
            var sharedComponentDataType = GetType("Unity.Entities.ISharedComponentData").NotNull();

            var entityManagerGetComponentTypesMethod      = myEntityManagerType.GetMethod("GetComponentTypes");
            var entityManagerGetSharedComponentDataMethod = myEntityManagerType.GetMethod("GetSharedComponentData");
            var entityManagerGetComponentDataMethod       = myEntityManagerType.GetMethod("GetComponentData");

            var componentTypesArray = Invoke(entityManagerGetComponentTypesMethod, myEntityManagerType,
                                             myEntityManagerObject, myEntityObject, allocatorTempObject.Value).NotNull();
            var componentTypesArrayLength =
                (PrimitiveValue)Adaptor.GetMember(Context, null, componentTypesArray, "Length").Value;

            var numberOfComponentTypes = (int)componentTypesArrayLength.Value;

            var objectValues = new List <ObjectValue>();

            for (var currentIndex = 0; currentIndex < numberOfComponentTypes; currentIndex++)
            {
                try
                {
                    var currentIndexValue = Adaptor.CreateValue(Context, currentIndex);
                    var currentComponent  = Adaptor
                                            .GetIndexerReference(Context, componentTypesArray, new[] { currentIndexValue }).Value;
                    var currentComponentType = currentComponent.Type;

                    var getManagedTypeMethod    = currentComponentType.GetMethod("GetManagedType");
                    var dataManagedType         = Invoke(getManagedTypeMethod, currentComponentType, currentComponent);
                    var dataManagedTypeFullName =
                        ((StringMirror)Adaptor.GetMember(Context, null, dataManagedType, "FullName").Value).Value;
                    var dataManagedTypeShortName =
                        ((StringMirror)Adaptor.GetMember(Context, null, dataManagedType, "Name").Value).Value;
                    var dataType = GetType(dataManagedTypeFullName);

                    MethodMirror getComponentDataMethod;
                    if (componentDataType.IsAssignableFrom(dataType))
                    {
                        getComponentDataMethod = entityManagerGetComponentDataMethod;
                    }
                    else if (sharedComponentDataType.IsAssignableFrom(dataType))
                    {
                        getComponentDataMethod = entityManagerGetSharedComponentDataMethod;
                    }
                    else
                    {
                        ourLogger.Warn("Unknown type of component data: {0}", dataManagedTypeFullName);
                        continue;
                    }

                    var getComponentDataMethodWithTypeArgs =
                        getComponentDataMethod.MakeGenericMethod(new[] { dataType });
                    var result = Invoke(getComponentDataMethodWithTypeArgs, myEntityManagerType,
                                        myEntityManagerObject, myEntityObject);
                    objectValues.Add(LiteralValueReference
                                     .CreateTargetObjectLiteral(Adaptor, Context, dataManagedTypeShortName, result)
                                     .CreateObjectValue(options));
                }
                catch (Exception e)
                {
                    ourLogger.Error(e, "Failed to fetch parameter {0} of entity {1}", currentIndex, myEntityObject);
                }
            }

            return(objectValues.ToArray());
        }
示例#23
0
 public TimeKeeper.TasksDataTable GetTasksByProjectID(int projectID)
 {
     return(Adaptor.GetTasksByProjectID(projectID));
 }
        /// <summary>
        /// Sets the material properties 02 basic mechanical properties.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="table">The table.</param>
        private static void setMATERIAL_PROPERTIES_02_BASIC_MECHANICAL_PROPERTIES(Model model, List <Dictionary <string, string> > table)
        {
            foreach (Material material in model.Components.Materials)
            {
                foreach (MaterialByTemperature materialByTemperature in material.PropertiesByTemperature)
                {
                    Dictionary <string, string> tableRow = tableRowMaterialNameAndTemperature(materialByTemperature);
                    tableRow["UnitWeight"] = Adaptor.fromDouble(materialByTemperature.WeightPerVolume);
                    tableRow["UnitMass"]   = Adaptor.fromDouble(materialByTemperature.MassPerVolume);

                    switch (materialByTemperature.Mechanics)
                    {
                    case MaterialMechanicsAnisotropic anisotropic:
                        tableRow["E1"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.ModulusOfElasticity.E1);
                        tableRow["E2"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.ModulusOfElasticity.E2);
                        tableRow["E3"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.ModulusOfElasticity.E3);

                        tableRow["G12"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.ShearModulus.G12);
                        tableRow["G13"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.ShearModulus.G13);
                        tableRow["G23"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.ShearModulus.G23);

                        tableRow["U12"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U12);
                        tableRow["U13"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U13);
                        tableRow["U23"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U23);
                        tableRow["U14"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U14);
                        tableRow["U24"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U24);
                        tableRow["U34"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U34);
                        tableRow["U15"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U15);
                        tableRow["U25"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U25);
                        tableRow["U35"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U35);
                        tableRow["U45"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U45);
                        tableRow["U16"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U16);
                        tableRow["U26"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U26);
                        tableRow["U36"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U36);
                        tableRow["U46"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U46);
                        tableRow["U56"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.PoissonsRatio.U56);

                        tableRow["A1"]  = Adaptor.fromDouble(anisotropic.AnisotropicProperties.ThermalCoefficient.A1);
                        tableRow["A2"]  = Adaptor.fromDouble(anisotropic.AnisotropicProperties.ThermalCoefficient.A2);
                        tableRow["A3"]  = Adaptor.fromDouble(anisotropic.AnisotropicProperties.ThermalCoefficient.A3);
                        tableRow["A12"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.ThermalCoefficient.A12);
                        tableRow["A13"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.ThermalCoefficient.A13);
                        tableRow["A23"] = Adaptor.fromDouble(anisotropic.AnisotropicProperties.ThermalCoefficient.A23);
                        break;

                    case MaterialMechanicsIsotropic isotropic:
                        tableRow["E1"]  = Adaptor.fromDouble(isotropic.IsotropicProperties.ModulusOfElasticity);
                        tableRow["G12"] = Adaptor.fromDouble(isotropic.IsotropicProperties.ShearModulus);
                        tableRow["U12"] = Adaptor.fromDouble(isotropic.IsotropicProperties.PoissonsRatio);
                        tableRow["A1"]  = Adaptor.fromDouble(isotropic.IsotropicProperties.ThermalCoefficient);
                        break;

                    case MaterialMechanicsOrthotropic orthotropic:
                        tableRow["E1"] = Adaptor.fromDouble(orthotropic.OrthotropicProperties.ModulusOfElasticity.E1);
                        tableRow["E2"] = Adaptor.fromDouble(orthotropic.OrthotropicProperties.ModulusOfElasticity.E2);
                        tableRow["E3"] = Adaptor.fromDouble(orthotropic.OrthotropicProperties.ModulusOfElasticity.E3);

                        tableRow["G12"] = Adaptor.fromDouble(orthotropic.OrthotropicProperties.ShearModulus.G12);
                        tableRow["G13"] = Adaptor.fromDouble(orthotropic.OrthotropicProperties.ShearModulus.G13);
                        tableRow["G23"] = Adaptor.fromDouble(orthotropic.OrthotropicProperties.ShearModulus.G23);

                        tableRow["U12"] = Adaptor.fromDouble(orthotropic.OrthotropicProperties.PoissonsRatio.U12);
                        tableRow["U13"] = Adaptor.fromDouble(orthotropic.OrthotropicProperties.PoissonsRatio.U13);
                        tableRow["U23"] = Adaptor.fromDouble(orthotropic.OrthotropicProperties.PoissonsRatio.U23);

                        tableRow["A1"] = Adaptor.fromDouble(orthotropic.OrthotropicProperties.ThermalCoefficient.A1);
                        tableRow["A2"] = Adaptor.fromDouble(orthotropic.OrthotropicProperties.ThermalCoefficient.A2);
                        tableRow["A3"] = Adaptor.fromDouble(orthotropic.OrthotropicProperties.ThermalCoefficient.A3);
                        break;

                    case MaterialMechanicsUniaxial uniaxial:
                        tableRow["E1"] = Adaptor.fromDouble(uniaxial.UniaxialProperties.ModulusOfElasticity);
                        tableRow["A1"] = Adaptor.fromDouble(uniaxial.UniaxialProperties.ThermalCoefficient);
                        break;
                    }

                    table.Add(tableRow);
                }
            }
        }
示例#25
0
 public TimeKeeper.TasksDataTable GetTasksByServiceIDByUserID(int serviceID, int userID)
 {
     return(Adaptor.GetTasksByServiceIDByUserID(serviceID, userID));
 }
示例#26
0
 public ResponseFormatCommand(Adaptor adaptor)
     : base(adaptor)
 {
 }
示例#27
0
 public TimeKeeper.TasksDataTable GetTasksByUserID(int userID)
 {
     return(Adaptor.GetTasksByUserID(userID));
 }
示例#28
0
 public TimeKeeper.TasksDataTable GetTasksByUserIDByDate(int userID, DateTime date)
 {
     return(Adaptor.GetTasksByUserIDByDate(userID, date));
 }
示例#29
0
 /// <summary>
 /// Calls ControlAdaptors method to transfer data, so it can be wrapped
 /// into widget specific things and all checkups
 /// </summary>
 /// <param name="aSender">
 /// Sender object <see cref="System.Object"/>
 /// </param>
 public void CallAdaptorGetData(object aSender)
 {
     Adaptor.InvokeAdapteeDataChange(this, aSender);
 }
示例#30
0
 public ReportMEErrorCommand(Adaptor adaptor)
     : base(adaptor)
 {
 }