Пример #1
0
        public override void OnDraw(Semaphore start, VKImage image)
        {
            if (AnyUpdatedInstanceLists)
            {
                UpdateLists();
                RecreateInstanceBuffers();
                RecreateAnimations();
                RecreateDescriptorSets();
                FinishUpdateLists();
                Refresh();
            }
            unsafe
            {
                var nonEmpty = InstanceLists.Values.Where(e => e.Count > 0);
                var ptr      = TimeUniform.Map(0, nonEmpty.Count());
                foreach (var list in nonEmpty)
                {
                    *(ptr++) = new ListTime
                    {
                        Time = (float)list.TimeSinceLastUpdate
                    };
                }
                TimeUniform.Unmap();
            }
            var graphicsCommandBuffer = GetCommandBuffer(image);

            Graphics.ComputeQueueFamily.First.Submit(
                start, PipelineStages.ComputeShader, ComputeCommandBuffers[image], ComputeSemaphore
                );
            Graphics.GraphicsQueueFamily.First.Submit(
                ComputeSemaphore, PipelineStages.ColorAttachmentOutput, graphicsCommandBuffer, FinishedSemaphore
                );
        }
 public PoEJsonConverter(ItemViewModel vm,
                         double lowerBound = 90,
                         double upperBound = 110,
                         ListTime time     = ListTime.OneWeek)
 {
     _vm = vm;
     _lowerPercentage = lowerBound / 100.0;
     _upperPercentage = upperBound / 100.0;
     _listTime        = time;
 }
        private void Draw_Click(object sender, RoutedEventArgs e)
        {
            DateTime dateTimeStart = DateTime.ParseExact(textBoxStart2.Text, "dd-MMM-yy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None);
            DateTime dateTimeEnd   = DateTime.ParseExact(textBoxEnd2.Text, "dd-MMM-yy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None);

            string path = "../../../AMS/bin/Debug/Controllers/ams.xml";

            XDocument doc = XDocument.Load(path);
            IEnumerable <XElement> elements = (from el in doc.Descendants("device") where (string)el.Attribute("code").Value == textBoxLD2.Text.ToString() select el); //ovde su svi device
            IEnumerable <XElement> values   = (from el in elements.Descendants("value") select el);                                                                    //ovde su sve vrednosti


            foreach (XElement xe in values)
            {
                if (DateTime.ParseExact(xe.FirstAttribute.Value, "dd-MMM-yy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None) >= dateTimeStart && DateTime.ParseExact(xe.FirstAttribute.Value, "dd-MMM-yy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None) <= dateTimeEnd)
                {
                    ListValue.Add(Int32.Parse(xe.Value)); //ovde ubacujemo one vrednosti koje upadaju u vreme izmedju
                    ListTime.Add(DateTime.ParseExact(xe.FirstAttribute.Value, "dd-MMM-yy HH:mm:ss", new CultureInfo("en-US"), DateTimeStyles.None));
                }
            }

            int countTemp = ListValue.Count;
            int countTime = ListTime.Count;

            List <KeyValuePair <DateTime, int> > data1 = new List <KeyValuePair <DateTime, int> >();

            if (countTemp == countTime)
            {
                for (int i = 0; i < countTemp; i++)
                {
                    KeyValuePair <DateTime, int> dt = new KeyValuePair <DateTime, int>(ListTime[i], ListValue[i]);
                    data1.Add(dt);
                }
            }

            if (data1[0].Value == 0 || data1[0].Value == 1)
            {
                MessageBox.Show("This graph works only for analog local devices!", "", MessageBoxButton.OK, MessageBoxImage.Error);
                ListValue.Clear();
                ListTime.Clear();
                doc.Save(path);
            }
            else
            {
                series.ItemsSource = data1;
                ListValue.Clear();
                ListTime.Clear();
                doc.Save(path);
            }
        }
#pragma warning disable CS1998
            public async Task <string> SearchAsync(string league, ItemViewModel vm, double lowerBound, double upperBound, ListTime timeWindow)
#pragma warning restore CS1998
            {
                if (SearchThrowInvalidOperationException)
                {
                    throw new InvalidOperationException();
                }

                if (SearchThrowHttpException)
                {
                    throw new HttpRequestException();
                }

                return(CreateSearchJsonReturn(SearchTotal));
            }
        public async Task <string> SearchAsync(string league, ItemViewModel vm, double lowerBound, double upperBound, ListTime timeWindow)
        {
            var    converter = new PoEJsonConverter(vm, lowerBound, upperBound, timeWindow);
            string endpoint  = URL_TRADE + league;
            var    payload   = new StringContent(converter.SerializeSearchParameters(),
                                                 Encoding.UTF8, "application/json");

            var response = await _httpClient.PostAsync(endpoint, payload);

            if (!response.IsSuccessStatusCode)
            {
                throw new InvalidOperationException("Response status code: " + response.StatusCode);
            }

            return(await response.Content.ReadAsStringAsync());
        }