private async Task <Observed> UpdateFlightData(Observed observedData, Commanded commandedData) { // Initialize Variables Observed observedDataServerResponse = observedData; Commanded commandedDataServerResponse = commandedData; try { // Get New Observed Flight Data from Server observedDataServerResponse = await GetObservedDataAsync($"/observed").ConfigureAwait(false); // Update Server with Commanded Flight Data commandedDataServerResponse = await UpdateFlightDataAsync(commandedData).ConfigureAwait(false); } catch (Exception e) { // Clear Commanded Data Exit because we have disconnected commandedData.Exit = false; // Write log message Console.WriteLine(e.Message); } // return final response return(observedDataServerResponse); }
public SelfEvaluation GenerateByYear(Observed observed, int contextoAno) { var sql = "INSERT INTO CTJ_SELFEVALUATION (CHAPA, ANO) VALUES(@Chapa, @Ano)"; Db.Database.ExecuteSqlCommand(sql, new[] { new SqlParameter("@Chapa", observed.ObservedId), new SqlParameter("@Ano", contextoAno) }); return(Get(observed, contextoAno)); }
public void Apply_NotACharacter_Test() { var entity = Mock.Of <IEntity>(); var observed = new Observed(); observed.Apply(entity); Assert.IsTrue(true); // If we made it here without exception then the test passed }
public HMM() { State = new State(); Observed = new Observed(); InitialState = new InitialStateProbability(); Transition = new Transition(); Complex = new Complex(); }
public FlightStateDataViewModel(FlightStates controlledState, Commanded commanded, Observed observed) { State = controlledState; ObservedData = observed; CommandedData = commanded; }
public static void Main(String[] args) { Observed o = new Observed("Initial string"); o.Click += new Handler(MyHandler); o.s = "new string"; o.s = "new string 2"; }
public HMM() { State = new State(); Observed = new Observed(); InitialState = new InitialStateProbability(); Transition = new Transition(); Complex = new Complex(); }
public override void AddParents(int numberOfEntries) { Observed = Variable.Array <int>(N).Named(node.name); Observed.SetValueRange(node.states); Range parentRange = new Range(node.parents.Count - 1); Range parentStates = null; foreach (var parent in node.parents) { if (parent.distributionType == DistributionType.Categorical) { parentStates = parent.states; } } x = Variable.Array <Vector>(N).Named("x" + node.name); for (int ii = 0; ii < numberOfEntries; ii++) { VariableArray <double> row = Variable <double> .Array(parentRange).Named(node.name + "row" + ii); int offset = 0; for (int jj = 0; jj < node.parents.Count; jj++) { if (node.parents[jj].distributionType == DistributionType.Categorical) { offset = -1; } else { row[jj + offset] = Variable.GaussianFromMeanAndPrecision((node.parents[jj].distributions.ObservedNumerical[ii]), 1); } } x[ii] = Variable.Vector(row); } var g = Variable.Array(Variable.Array(Variable.Array <double>(node.states), N), parentStates).Named("g" + node.name); g[parentStates][N][node.states] = Variable.InnerProduct(B[node.states][parentStates], (x[N])) + m[node.states][parentStates]; var p = Variable.Array(Variable.Array <Vector>(N), parentStates).Named("p" + node.name); p[parentStates][N] = Variable.Softmax(g[parentStates][N]); if (node.name == "doorGoTo") { bool stophere = true; } VariableArray <int> parentObserved = null; foreach (var parent in node.parents) { if (parent.distributionType == DistributionType.Categorical) { parentObserved = parent.distributions.Observed; } } using (Variable.ForEach(N)) using (Variable.Switch(parentObserved[N])) Observed[N] = Variable.Discrete(p[parentObserved[N]][N]); }
public Task ApplyAsync(IDocumentSession session, EventPage page, CancellationToken token) { foreach (var pageEvent in page.Events) { Observed.Add(pageEvent.Sequence); } return(Task.CompletedTask); }
public Task ApplyAsync(IDocumentSession session, IReadOnlyList <StreamAction> streams, CancellationToken cancellation) { foreach (var pageEvent in streams.SelectMany(x => x.Events)) { Observed.Add(pageEvent.Sequence); } return(Task.CompletedTask); }
public static IObservedValue <T> AsObservedValue <T>(this T obj) { var instance = new Observed <T> { Value = obj }; return(instance); }
public void Apply_Character_WithExistingObservedCondition_Test() { var character = CreateMockCharacter(); character.Conditions.Add(new Observed()); var observed = new Observed(); observed.Apply(character); }
public void Remove_NoConditions_Test() { var character = CreateMockCharacter(); var observed = new Observed(); observed.Apply(character); observed.Remove(character); Assert.AreEqual(0, character.Conditions.Count); }
public void Apply_Character_NoConditions_Test() { var character = CreateMockCharacter(); var observed = new Observed(); observed.Apply(character); Assert.AreEqual(EntityIds.OBSERVED_CONDITION_ID, character.Conditions[0].Id); Assert.AreSame(observed, character.Conditions[0]); Assert.AreEqual(ConditionGroup.DegreesOfDetection, character.Conditions[0].Group); }
private void lstObserved_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (lstObserved.SelectedIndex != -1) { Observed obs = (Observed)lstObserved.SelectedItem; // id txtObservedId.Text = obs.Id.ToString(); // name txtObservedName.Text = obs.Name; // nationality txtObservedNationality.Text = obs.Nationality; // cpr txtObservedCPR.Text = obs.CPR; // tags txtObservedTags.Text = obs.Tags; // Check for existence of appearance, and insert if it exists Appearance obsapp = InfoWrapper.GetAppearance(obs.Id); if (obsapp.Id != -1) { txtObservedHeight.Text = obsapp.Height.ToString(); txtObservedEyecolor.Text = obsapp.Eyecolor; txtObservedHaircolor.Text = obsapp.Haircolor; } Address obsadd = InfoWrapper.GetAddress(obs.Id); // Check for existence of address, and insert if it exists if (obsadd.Id != -1) { txtObservedStreet.Text = obsadd.Street; txtObservedAreacode.Text = obsadd.AreaCode.ToString(); } Database.Entities.Image obsimg = InfoWrapper.GetImage(obs.Id); // Check for existence of image, and insert if it exists if (obsimg.Id != -1) { try { MemoryStream ms = new MemoryStream(obsimg.Data); BitmapImage bimg = new BitmapImage(); bimg.BeginInit(); bimg.StreamSource = ms; bimg.EndInit(); imgObserved.Source = bimg; } catch (Exception ex) { MessageBox.Show($"Billedformatet er ikke understøttet.\n\n{ex.Message}"); } } } }
public void Observe() { var observed = new Observed(); var observer = new Observer(); observed.Observers.Add(observer.ProcessAlert); observed.Alert(); Assert.True(observer.Processed); observed.Observers.Remove(observer.ProcessAlert); Assert.True(true); }
private async Task <Observed> GetObservedDataAsync(string path) { string flightDataAsString; Observed flightData = null; HttpResponseMessage response = await _client.GetAsync(path).ConfigureAwait(false); if (response.IsSuccessStatusCode) { // Get Flight Data as string flightDataAsString = await response.Content.ReadAsStringAsync().ConfigureAwait(false); // Deserialize flightData = JsonConvert.DeserializeObject <Observed>(flightDataAsString); } return(flightData); }
public IEnumerable <Course> GetCourseParticipated(int[] coursesList, Observed observed, int contextoAno) { var courses = new List <Course>(); for (int i = 0; i < coursesList.Length; i++) { var sql = "SELECT DISTINCT A.CODCURSO AS 'ID', A.NOMECURSO AS 'NAME' FROM VCURSOS A (NOLOCK) JOIN VTURMAS B (NOLOCK) ON B.CODCOLIGADA=A.CODCOLIGADA AND B.CODCURSO=A.CODCURSO AND YEAR(B.DTINICIO)=@ContextoAno JOIN VTURMA C (NOLOCK) ON C.CODCOLIGADA=B.CODCOLIGADA AND C.CODTURMA=B.CODTURMA JOIN PFUNC D (NOLOCK) ON D.CODCOLIGADA=C.CODCOLIGADA AND D.CODPESSOA=C.CODPESSOA WHERE A.CODCOLIGADA=1 AND A.CODCURSO=@courseId AND D.CHAPA=@Chapa"; var c = Db.Course.SqlQuery(sql, new[] { new SqlParameter("@CourseId", coursesList[i]), new SqlParameter("@Chapa", observed.ObservedId), new SqlParameter("@ContextoAno", contextoAno) }).FirstOrDefault(); if (c != null) { courses.Add(c); } } return(courses); }
public void TestDelegate() { var observed = new Observed(); var observer = new Observer(); // setup observer.RegisterDelegate(observed); // verify that nothing processed Assert.False(observer.Processed); // execute delegate observed.RunDelegate(); // verify that event processed Assert.True(observer.Processed); Assert.True(true); }
private void CascadingInvalidate(EventExecution evex) { // Get all instances ExecutionsToEvents.TryGetValue(evex, out List <Tuple <Uid, int> > instances); foreach (var i in instances) { var ev = Observed.First(o => o.Item1.Equals(i.Item1)); // Find event which observed invalidated for (int j = i.Item2; j < ev.Item2.Length; j++) // For invalidated and all following, set invalid and cascade { ev.Item2[j].Valid = false; if (i.Item2 != j) { CascadingInvalidate(ev.Item2[j]); } } } }
public static void SaveObserved(Observed observed) { DBConnection db = new DBConnection(DB.connString); List <SqlParameter> parameters = obsparam(observed); if (observed.Id == -1) { foreach (SqlParameter s in obsparam(observed)) { Console.WriteLine(s.ParameterName); } var parameterArray = parameters.Where(x => x.ParameterName != "id").ToArray(); db.ExecuteStoredProcedure("CreateObserved", parameterArray); } else { db.ExecuteStoredProcedure("UpdateObserved", parameters.ToArray()); } }
public MainPageViewModel() { // Set Gather Message Frequency (ms) _maxNumberOfPoints = 100; _gatherMessageFrequencyMs = 50; _frequencyOfChartUpdateMs = 500; _numberOfPointsAddedToChart = 0; _timeSinceLastChartUpdateMs = 0; _timeSinceLastServerUpdateMs = 0; _frequencyToUpdateServerWithNewFlighDataMs = 250; // Create Flight Data _observedData = new Observed(); _commandedData = new Commanded(); FlightStateDataViewModels = new List <FlightStateDataViewModel>() { new FlightStateDataViewModel(FlightStates.Roll, _commandedData, _observedData) { cKp = 0.001, cKi = 0.0001, cKd = 0.00005 }, new FlightStateDataViewModel(FlightStates.Pitch, _commandedData, _observedData) { cKp = 0.001, cKi = 0.0001, cKd = 0.00005 }, new FlightStateDataViewModel(FlightStates.Yaw, _commandedData, _observedData) { cKp = 0.001, cKi = 0.0001, cKd = 0.00005 }, new FlightStateDataViewModel(FlightStates.Throttle, _commandedData, _observedData) { cKp = 0.1, cKi = 0.2, cKd = 0.0 } }; // Set Initial PID Constants // Create Rest Client _myRestClient = new MyRestClient(); // Start Listening StartListening(); }
public void Observe() { var loggingObserver = new GenLib.Observer.LoggingObserver(); Assert.False((loggingObserver.Alert(null, null))); var observed = new Observed(); observed.Observers.Add(loggingObserver.Alert); // clear out old test loggingObserver.CreateDefaultFilename(); new DirectoryFile().DeleteDirectoryWithFiles( new DirectoryFile().GetFullyQualifiedDirectory(loggingObserver.Filename)); loggingObserver.Open(); Assert.True((loggingObserver.Alert(this, new ObserverEventArgs { Arg = string.Empty }))); Console.WriteLine(loggingObserver.Filename); const string testMsg = "testMsg"; observed.Alert(testMsg); loggingObserver.Close(); var sr = new StreamReader(loggingObserver.Filename); var contents = sr.ReadLine(); sr.Close(); Assert.Equal(testMsg, contents); observed.Observers.Remove(loggingObserver.Alert); Assert.True(true); }
private void btnSaveObserved_Click(object sender, RoutedEventArgs e) { try { Observed observed = new Observed(); observed.Id = int.Parse(txtObservedId.Text); observed.Name = txtObservedName.Text; observed.Nationality = txtObservedNationality.Text; observed.CPR = txtObservedCPR.Text; observed.Tags = txtObservedTags.Text; ObservedWrapper.SaveObserved(observed); // Try to save appearance if (txtObservedHeight.Text != "" || txtObservedEyecolor.Text != "" || txtObservedHaircolor.Text != "") { Appearance appearance; if (observed.Id == -1) { appearance = new Appearance(int.Parse(txtObservedHeight.Text), txtObservedEyecolor.Text, txtObservedHaircolor.Text, InfoWrapper.GetLastPersonId()); } else { appearance = new Appearance(int.Parse(txtObservedHeight.Text), txtObservedEyecolor.Text, txtObservedHaircolor.Text, observed.Id); } InfoWrapper.SaveAppearence(appearance); } // Try to save address if (txtObservedStreet.Text != "" || txtObservedAreacode.Text != "") { Address address; // Check if it's a new observed if (observed.Id == -1) { address = new Address(txtObservedStreet.Text, int.Parse(txtObservedAreacode.Text), InfoWrapper.GetLastPersonId()); } else { address = new Address(txtObservedStreet.Text, int.Parse(txtObservedAreacode.Text), observed.Id); } InfoWrapper.SaveAddress(address); } // Try to save image if (txtObservedImagePath.Text != "") { if (File.Exists(txtObservedImagePath.Text)) { FileStream fs = new FileStream(txtObservedImagePath.Text, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); Database.Entities.Image img; // if new observed if (observed.Id == -1) { img = new Database.Entities.Image(br.ReadBytes(Convert.ToInt32(fs.Length)), InfoWrapper.GetLastPersonId()); } else { img = new Database.Entities.Image(br.ReadBytes(Convert.ToInt32(fs.Length)), observed.Id); } InfoWrapper.SaveImage(img); } } } catch (Exception ex) { MessageBox.Show($"Der er sket en fejl. Er alle felterne korrekt udfyldt?\n\n{ex.Message}"); } }
public IEnumerable <Class> GetClassesParticipatedByCourseId(int CourseId, Observed observed, int contextoAno) { var sql = "SELECT A.CODCURSO + B.CODTURMA AS 'ID', B.NOME AS 'NAME' FROM VCURSOS A (NOLOCK) JOIN VTURMAS B (NOLOCK) ON B.CODCOLIGADA=A.CODCOLIGADA AND B.CODCURSO=A.CODCURSO AND YEAR(B.DTINICIO)=@ContextoAno JOIN VTURMA C (NOLOCK) ON C.CODCOLIGADA=B.CODCOLIGADA AND C.CODTURMA=B.CODTURMA JOIN PFUNC D (NOLOCK) ON D.CODCOLIGADA=C.CODCOLIGADA AND D.CODPESSOA=C.CODPESSOA WHERE A.CODCOLIGADA=1 AND A.CODCURSO=@CourseId AND D.CHAPA=@Chapa AND ISNULL(C.FALTAS, 0)=0"; return(Db.Classes.SqlQuery(sql, new[] { new SqlParameter("@CourseId", CourseId), new SqlParameter("@Chapa", observed.ObservedId), new SqlParameter("@ContextoAno", contextoAno) }).ToList()); }
public IEnumerable <ProjectActivity> GetProjectActivityByAnoAndChapa(Observed observed, int contextoAno) { var sql = "SELECT @Ano AS 'ANO', B.CHAPA, A.CODCLIENTE AS 'CTJEVALID', A.DESCRICAO AS 'CTJEVALNAME', C.DETAILS, CASE WHEN C.ANO IS NULL THEN 0 ELSE 1 END AS 'ISCHECKED' FROM GCONSIST A (NOLOCK) LEFT JOIN CTJ_SELFEVALUATION B (NOLOCK) ON B.CHAPA=@Chapa AND B.ANO=@Ano LEFT JOIN CTJ_SELFEVALUATIONPROJECTSACTIVITIES C (NOLOCK) ON C.ANO=B.ANO AND C.CHAPA=B.CHAPA AND C.CTJEVALID=A.CODCLIENTE WHERE A.APLICACAO='V' AND A.CODTABELA='CTJEVAL001'"; return(Db.Database.SqlQuery <ProjectActivity>(sql, new[] { new SqlParameter("@Ano", contextoAno), new SqlParameter("@Chapa", observed.ObservedId) }).ToList()); }
public IEnumerable <DigitalLiteracy> GetDigitalLiteracyByAnoAndChapa(Observed observed, int contextoAno) { var sql = "SELECT A.* FROM CTJ_DIGITALLITERACY A (NOLOCK) WHERE A.ANO=@Ano AND A.CHAPA=@Chapa"; return(Db.DigitalLiteracies.SqlQuery(sql, new[] { new SqlParameter("@Ano", contextoAno), new SqlParameter("@Chapa", observed.ObservedId) }).ToList()); }
public IEnumerable <ProfessionalDevelopment> GetProfessionalDevelopmentByAnoAndChapa(Observed observed, int contextoAno) { List <ProfessionalDevelopment> itens = new List <ProfessionalDevelopment>(); var sql = "SELECT A.CHAPA, A.ANO, A.TIPO, A.NSEQ, A.DATA, A.DESCRIPTION, A.DETAILS, A.IMAGEMID FROM CTJ_PROFESSIONALDEVELOPMENT A (NOLOCK) WHERE A.ANO=@Ano AND A.CHAPA=@Chapa"; return(Db.Database.SqlQuery <ProfessionalDevelopment>(sql, new[] { new SqlParameter("@Ano", contextoAno), new SqlParameter("@Chapa", observed.ObservedId) }).ToList()); }
public SelfEvaluation Get(Observed observed, int contextoAno) { var selfEvaluation = _selfEvaluationRepository.Get(observed, contextoAno); if (selfEvaluation == null) { return(null); } /*if (selfEvaluation == null && contextoAno == Convert.ToInt32(DateTime.Now.Year.ToString())) * { * selfEvaluation = _selfEvaluationRepository.GenerateByYear(observed, contextoAno); * } * else if (selfEvaluation == null && contextoAno != Convert.ToInt32(DateTime.Now.Year.ToString())) * { * return null; * }*/ selfEvaluation.DegreeImage = _selfFileUploadRepository.GetById(selfEvaluation.DegreeImageId); // Question1 var coursesQ1 = _selfEvaluationRepository.GetCourseParticipated(new int[] { 2, 3, 4 }, observed, contextoAno); foreach (var c in coursesQ1) { c.Classes = _selfEvaluationRepository.GetClassesParticipatedByCourseId(int.Parse(c.Id), observed, contextoAno); } var ctjEventsQ1 = new CTJEvents(); ctjEventsQ1.Courses = coursesQ1; selfEvaluation.Question1 = ctjEventsQ1; // Question2 var coursesQ2 = _selfEvaluationRepository.GetCourseParticipated(new int[] { 5, 6 }, observed, contextoAno); foreach (var c in coursesQ2) { c.Classes = _selfEvaluationRepository.GetClassesParticipatedByCourseId(int.Parse(c.Id), observed, contextoAno); } var ctjEventsQ2 = new CTJEvents(); ctjEventsQ2.Courses = coursesQ2; selfEvaluation.Question2 = ctjEventsQ2; // Question2A var coursesQ2A = _selfEvaluationRepository.GetCourseParticipated(new int[] { 7 }, observed, contextoAno); foreach (var c in coursesQ2A) { c.Classes = _selfEvaluationRepository.GetClassesParticipatedByCourseId(int.Parse(c.Id), observed, contextoAno); } var ctjEventsQ2A = new CTJEvents(); ctjEventsQ2A.Courses = coursesQ2A; selfEvaluation.Question2A = ctjEventsQ2A; selfEvaluation.ProfessionalDevelopments = _selfEvaluationRepository.GetProfessionalDevelopmentByAnoAndChapa(observed, contextoAno); foreach (var item in selfEvaluation.ProfessionalDevelopments) { item.Imagem = _selfFileUploadRepository.GetById(item.ImagemId); } selfEvaluation.DigitalLiteracies = _selfEvaluationRepository.GetDigitalLiteracyByAnoAndChapa(observed, contextoAno); selfEvaluation.ProjectActivities = _selfEvaluationRepository.GetProjectActivityByAnoAndChapa(observed, contextoAno); selfEvaluation.DegreeComplete = 0; var person = _selfEmployeeRepository.GetPersonByChapa(observed.ObservedId); List <string> options = new List <string>(new string[] { "9", "A", "B", "C", "D", "E", "F", "G", "H" }); foreach (var item in options) { if (person.GrauInstrucao.ToUpper() == item.ToUpper()) { selfEvaluation.DegreeComplete = 1; selfEvaluation.Degree = 1; break; } } return(selfEvaluation); }
IEnumerator GetStars() { UnityWebRequest www = UnityWebRequest.Get("https://exoplanetarchive.ipac.caltech.edu/cgi-bin/nstedAPI/nph-nstedAPI?table=exoplanets&select=pl_hostname,st_rad,st_teff,ra,dec,st_dist&order=pl_disc&format=json"); yield return(www.SendWebRequest()); if (www.isDone) { if (www.isNetworkError) { Debug.Log("Network Error: " + www.error); } if (www.isHttpError) { Debug.Log("HTTP Error: " + www.error); } else { Debug.Log("download size: " + www.downloadHandler.data.Length); celestialData = JsonUtility.FromJson <Observed>("{\"rawData\":" + www.downloadHandler.text + "}"); var rawData = new List <RawData>(celestialData.rawData); Debug.Log("Total number of planets: " + rawData.Count); foreach (RawData r in rawData) { Exoplanet ep = new Exoplanet(); ep.name = r.pl_name; ep.inclination = r.pl_orbincl; ep.period = r.pl_orbper; ep.eccentricity = r.pl_orbseccen; ep.smAxis = r.pl_orbsmax; if (Systems.stars.FindIndex(star => star.name == r.pl_hostname) < 0) { Star s = new Star(); s.name = r.pl_hostname; s.distance = r.st_dist; s.temperature = r.st_teff; if (r.st_rad > 0) { var log = Mathf.Log(r.st_rad, 10); s.size = log >= 0.5f ? log : 0.5f; } else { s.size = 1; } float x = Mathf.Cos(r.ra) * Mathf.Cos(r.dec); float y = Mathf.Sin(r.ra) * Mathf.Cos(r.dec); float z = Mathf.Sin(r.dec); s.startingPosition = new Vector3(x, y, z); if (s.distance > 0) { s.location = Mathf.Log(s.distance, 10) * s.startingPosition; } else { s.location = s.startingPosition; } s.planets = new List <Exoplanet>(); Systems.stars.Add(s); } Systems.stars.Find(star => star.name == r.pl_hostname).planets.Add(ep); } Debug.Log("Total number of stars: " + Systems.stars.Count); } } }
public SelfEvaluation Get(Observed observed, int contextoAno) { var sql = "SELECT CONVERT(VARCHAR(6), A.CHAPA)+CONVERT(VARCHAR(4), A.ANO) AS 'ID', B.NOME AS NAME, A.* FROM CTJ_SELFEVALUATION A (NOLOCK) INNER JOIN PFUNC B (NOLOCK) ON B.CHAPA=A.CHAPA WHERE A.ANO=@Ano AND A.CHAPA=@Chapa"; return(Db.Database.SqlQuery <SelfEvaluation>(sql, new[] { new SqlParameter("@Ano", contextoAno), new SqlParameter("@Chapa", observed.ObservedId) }).FirstOrDefault()); }