Ejemplo n.º 1
0
 /// <summary>
 /// Добавить единицу учета
 /// </summary>
 /// <param name="ingot">Единица учета</param>
 public void AddIngot(Ingot ingot)
 {
     if (ingot != null)
     {
         _ingots.AddItem(ingot);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Добаввить единицу учета в список
 /// </summary>
 public void AddIngot(Ingot ingot)
 {
     if (ingot != null)
     {
         _ingotsList.Add(ingot);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Добавить единицу учета на рольганг
 /// </summary>
 /// <param name="ingot">Единица учета</param>
 public void Push(Ingot ingot)
 {
     if (ingot != null)
     {
         // DateTime current = DateTime.Now;
         // ingot.SetStartTime(current);
         _ingotsList.Add(ingot);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Получить единицу учета по ее номеру
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        public Ingot GetIngot(int num)
        {
            Ingot res = null;

            if (num > 0 && num < _ingots.GetItemsCount())
            {
                res = _ingots.GetItem(num);
            }
            return(res);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Получить единицу учета по ее номеру
        /// </summary>
        /// <param name="number">Номер единицы учета</param>
        /// <returns>Единица учета</returns>
        public Ingot GetIngot(int number)
        {
            Ingot result = null;

            if (number > 0 && number <= GetIngotsCount())
            {
                result = _ingotsList[number - 1];
            }

            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Получить единицу учета с рольганга
        /// </summary>
        /// <returns></returns>
        public Ingot Pop()
        {
            // List<Ingot> _ingots = new List<Ingot>();
            Ingot first = _ingotsList[0];

            _ingotsList.Remove(first);
            // DateTime current = DateTime.Now;
            // first.SetFinishTime(current);

            return(first);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Доставить материал через рольганг
        /// </summary>
        /// <param name="ingot">Доставляемый материал</param>
        public async Task Delivering(Ingot ingot)
        {
            // Установка изображения единицы учета в соотвествии с типом рольганга
            AddIngot(ingot);
            string color;

            if (Type == RollgangTypes.Horizontal)
            {
                color = "img/colors/";
            }
            else
            {
                color = "img/colors/v";
            }

            color += ingot.Color + ".png";
            ingot.VisualParameters.FileName = color;

            // Расчитываем время движения единицы учета по рольгангу
            // _deliveringTime - время полного перемещения единицы учета по рольгангу
            DateTime startDelivering = ingot.GetAccessTime();

            if (startDelivering == default)
            {
                startDelivering = DateTime.Now;
                ingot.SetAccessTime(startDelivering);
            }

            // Расчитать время, прошедшее с начала транспортировки материала
            TimeSpan movingTime = DateTime.Now - startDelivering;

            // Пока время перемещения не достигнуто
            double deliveringTime = GetDeliveringTime();

            while (movingTime.TotalSeconds < deliveringTime)
            {
                // Расчитываем новые координаты для единицы учета и выводим ее позицию
                Coords newCoords = GetIngotPosition(movingTime);
                ingot.VisualParameters.XPos = newCoords.PosX + "px";
                ingot.VisualParameters.YPos = newCoords.PosY + "px";

                // Ждем одну секунду
                await Task.Delay(TimeSpan.FromSeconds(1));

                movingTime = DateTime.Now - startDelivering;
                Moved?.Invoke(ingot);
            }

            // Сообщаем о завершении доставки материала
            ingot.SetAccessTime(default);
Ejemplo n.º 8
0
        /// <summary>
        /// Удалить единицу учета с рольганга
        /// </summary>
        /// <param name="ingot"></param>
        /// <returns>Удаленная с рольганга единица учета</returns>
        public Ingot RemoveIngot(Ingot ingot)
        {
            Ingot res = null;

            for (int i = 0; i < _ingotsList.Count; i++)
            {
                if (_ingotsList[i].Uid == ingot.Uid)
                {
                    res = _ingotsList[i];
                    _ingotsList.RemoveAt(i);
                }
            }

            return(res);
        }