Ejemplo n.º 1
0
 List <double> IScopeElement.GetReading(TransientState solution)
 {
     return(new List <double> {
         solution.GetValue(in_pin.V),
         solution.GetValue(I)
     });
 }
Ejemplo n.º 2
0
        void photoChooseTask_Completed(object sender, PhotoResult e)
        {
            var capturedPicture = new CapturedPictureViewModel(e.OriginalFileName, e.ChosenPhoto);

            //set mode for camera
            TransientState.Set("CapturedPictureViewModel", capturedPicture);
        }
Ejemplo n.º 3
0
        public override bool Execute(TransientState transientState)
        {
            bool prevState = recloser.State;
            bool newState  = recloser.GetNewState(transientState, Time);

            recloser.State = newState;
            return(prevState != newState);
        }
Ejemplo n.º 4
0
 private void cameraTask_Completed(object sender, PhotoResult e)
 {
     if (e.TaskResult == TaskResult.OK)
     {
         // Get the image temp file from e.OriginalFileName.
         // Get the image temp stream from e.ChosenPhoto.
         // Don't keep either the temp stream or file name.
         var capturedPicture = new CapturedPictureViewModel(e.OriginalFileName, e.ChosenPhoto);
         //set mode for camera
         TransientState.Set("CapturedPictureViewModel", capturedPicture);
     }
 }
Ejemplo n.º 5
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            var capturedPicture = TransientState.Get <CapturedPictureViewModel>("CapturedPictureViewModel");

            if (capturedPicture != null)
            {
                TransientState.Set <CapturedPictureViewModel>(CapturePicturePage.ModelStateKey, capturedPicture);
                //NavigationService.Navigate<CapturePicturePage>();
                this.NavigationService.Navigate(new Uri("/Views/Capture/CapturePicturePage.xaml", UriKind.Relative));
            }

            base.OnNavigatedTo(e);
        }
Ejemplo n.º 6
0
        public bool GetNewState(TransientState transientState, double time)
        {
            RecloserState recloserState = new RecloserState(
                transientState.GetValue(IA),
                transientState.GetValue(IB),
                transientState.GetValue(IC),
                transientState.GetValue(in_pin.VA),
                transientState.GetValue(in_pin.VB),
                transientState.GetValue(in_pin.VC),
                time,
                State);

            return(program.Execute(recloserState));
        }
Ejemplo n.º 7
0
        public async Task <string> PostEventIfUseful(string journalEntry, TransientState transientState = null)
        {
            // inject transient properties into event
            var eventBody = JsonSerializer.Deserialize <Dictionary <string, object> >(journalEntry);

            if (transientState != null)
            {
                eventBody.Add("_shipId", transientState._shipId);
                eventBody.Add("_systemName", transientState._systemName);
                eventBody.Add("_systemAddress", transientState._systemAddress);
                eventBody.Add("_systemCoordinates", transientState._systemCoordinates);
            }

            var entryWithTransientState = JsonSerializer.Serialize(eventBody);

            System.Diagnostics.Debug.WriteLine($"Event with transients: {entryWithTransientState}");

            // compose body as formparts and post
            var content = new FormUrlEncodedContent(new Dictionary <string, string>()
            {
                ["commanderName"]       = CmdrName,
                ["apiKey"]              = ApiKey,
                ["fromSoftware"]        = AppName,
                ["fromSoftwareVersion"] = AppVersion,
                ["message"]             = entryWithTransientState
            });

            HttpResponseMessage response = await client.PostAsync("api-journal-v1", content);

            if (response.IsSuccessStatusCode)
            {
                string r = await response.Content.ReadAsStringAsync();

                System.Diagnostics.Debug.WriteLine($"Posted event to EDSM - StatusCode: {response.StatusCode}\nResponse: {r}");
                return(r);
            }
            else
            {
                System.Diagnostics.Debug.Write($"Error posting event - StatusCode: {response.StatusCode}");
                return(String.Empty);
            }
        }
Ejemplo n.º 8
0
    public static void LoadTransientState(string player,
                                          TransientState transientState)
    {
        // TODO we need to make the server use POST instead of GET

        /*var json = JsonUtility.ToJson(playerState);
         * var data = System.Text.Encoding.UTF8.GetBytes(json);*/
        var operation = new UnityWebRequest
        {
            url    = GetReportURL(player),
            method = UnityWebRequest.kHttpVerbGET, // TODO
            //uploadHandler = new UploadHandlerRaw(data),
            downloadHandler = new DownloadHandlerBuffer()
        }.SendWebRequest();

        operation.completed += delegate(AsyncOperation asyncOperation)
        {
            OnLoadCompleted(asyncOperation, transientState);
        };
    }
Ejemplo n.º 9
0
 public override bool Execute(TransientState x)
 {
     return(true);
 }