private void DrawLearningDataSetButton_Click(object sender, RoutedEventArgs e) { if (data != null) { ValuesA.Clear(); ValuesB.Clear(); ValuesC.Clear(); ValuesD.Clear(); data.ForEach(i => { switch (i.ObjClass) { case 0: ValuesA.Add(new ObservablePoint(i.Attributes[0], i.Attributes[1])); break; case 1: ValuesB.Add(new ObservablePoint(i.Attributes[0], i.Attributes[1])); break; } }); stolp.stolp(data, int.Parse(deltaTextBox.Text), int.Parse(l0TextBox.Text)).ForEach(i => { ValuesC.Add(new ObservablePoint(i.Attributes[0], i.Attributes[1])); }); List <Data> standarts = new List <Data>(); standarts.AddRange(stolp.findStandard(stolp.emissionСutOff(data, int.Parse(deltaTextBox.Text)))); //standarts.AddRange(stolp.findStandard(data)); standarts.ForEach(i => { ValuesD.Add(new ObservablePoint(i.Attributes[0], i.Attributes[1])); }); } }
private void Read() { //var r = new Random(); while (IsReading) { Thread.Sleep(150); var now = DateTime.Now; //_trend += r.Next(-8, 10); ValuesA.Add(new ObservablePoint(Globals.COGx, Globals.COGy)); if (ValuesA.Count > 50) { ValuesA.RemoveAt(0); } //ValuesA[0].X = Globals.COPx; //ValuesA[0].Y = Globals.COPy; ValuesB[0].X = Globals.COGx; ValuesB[0].Y = Globals.COGy; ValuesB[0].Weight = 1; //lets only use the last 150 values //if (ChartValues.Count > 150) ChartValues.RemoveAt(0); } }
public void Autoscale() { AxisX.MinValue = ValuesA.Select(x => x.X).Min(); AxisX.MaxValue = ValuesA.Select(x => x.X).Max(); AxisY.MinValue = ValuesA.Select(x => x.Y).Min(); AxisY.MaxValue = ValuesA.Select(x => x.Y).Max(); }
private void LocaleRecette() { foreach (Registre registre in Registres) { switch ((REGISTRE)Enum.Parse(typeof(REGISTRE), registre.Nom)) { case REGISTRE.ConsigneA: { ushort[] readConsigneA = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), Cst_NbRedresseurs); ConsigneA = readConsigneA[0]; } break; case REGISTRE.ConsigneV: { ushort[] readConsigneV = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), Cst_NbRedresseurs); ConsigneV = readConsigneV[0]; if (ValuesA.Count < 500) { ValuesA.Add(ConsigneV); } else { for (int i = 0; i < ValuesA.Count - 1; i++) { ValuesA[i] = ValuesA[i + 1]; } ValuesA[ValuesA.Count - 1] = ConsigneV; } } break; case REGISTRE.LectureA: { ushort[] readLectureA = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), Cst_NbRedresseurs); LectureA = readLectureA[0]; if (ValuesB.Count < 500) { ValuesB.Add(ConsigneA); } else { for (int i = 0; i < ValuesA.Count - 1; i++) { ValuesB[i] = ValuesB[i + 1]; } ValuesB[ValuesA.Count - 1] = ConsigneA; } } break; case REGISTRE.LectureV: { ushort[] readLectureV = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), Cst_NbRedresseurs); LectureV = readLectureV[0]; } break; } } }
private void ClassificateButton_Click(object sender, RoutedEventArgs e) { if (data != null) { ValuesA.Clear(); ValuesB.Clear(); ValuesC.Clear(); ValuesD.Clear(); List <Data> newData = new List <Data>(); List <Data> omega = stolp.stolp(data, int.Parse(deltaTextBox.Text), int.Parse(l0TextBox.Text)); int maxItemCount = int.Parse(count.Text); for (int i = 0; i < maxItemCount; i++) { for (int j = 0; j < maxItemCount; j++) { Data obj = new Data(new double[] { i / (double)maxItemCount, j / (double)maxItemCount }, -1); obj.ObjClass = stolp.classifier(omega, obj); switch (obj.ObjClass) { case 0: ValuesA.Add(new ObservablePoint(obj.Attributes[0], obj.Attributes[1])); break; case 1: ValuesB.Add(new ObservablePoint(obj.Attributes[0], obj.Attributes[1])); break; } newData.Add(obj); } } stolp.stolp(data, int.Parse(deltaTextBox.Text), int.Parse(l0TextBox.Text)).ForEach(i => { ValuesC.Add(new ObservablePoint(i.Attributes[0], i.Attributes[1])); }); List <Data> standarts = new List <Data>(); //standarts.AddRange(stolp.findStandard(data)); standarts.AddRange(stolp.findStandard(stolp.emissionСutOff(data, int.Parse(deltaTextBox.Text)))); standarts.ForEach(i => { ValuesD.Add(new ObservablePoint(i.Attributes[0], i.Attributes[1])); }); } else { MessageBox.Show("Сперва Выберите Файл c обучающей выборкой"); } /*data.ForEach(i => * { * switch (i.ObjClass) * { * case 0: ValuesA.Add(new ObservablePoint(i.Attributes[0], i.Attributes[1])); break; * case 1: ValuesB.Add(new ObservablePoint(i.Attributes[0], i.Attributes[1])); break; * } * }); * */ }
private void RemoteRecette() { if (SelectedRecette != null) //Consigne = coefDirect*t + consigneD { if (SelectedRecette.TempsDebut.Add(SelectedRecette.TempsRestant) >= DateTime.Now) { if (SelectedRecette.TempsDebut.Add(SelectedRecette.Segments[SelectedRecette.SegCours].Duree) >= DateTime.Now) { TimeSpan t = DateTime.Now - SelectedRecette.TempsDebut; float coefDirectA = (SelectedRecette.Segments[SelectedRecette.SegCours].ConsigneArriveeA - SelectedRecette.Segments[SelectedRecette.SegCours].ConsigneDepartA) / (float)SelectedRecette.Segments[SelectedRecette.SegCours].Duree.TotalSeconds; float coefDirectV = (SelectedRecette.Segments[SelectedRecette.SegCours].ConsigneArriveeV - SelectedRecette.Segments[SelectedRecette.SegCours].ConsigneDepartV) / (float)SelectedRecette.Segments[SelectedRecette.SegCours].Duree.TotalSeconds; ConsigneA = (int)(coefDirectA * (float)t.TotalSeconds + SelectedRecette.Segments[SelectedRecette.SegCours].ConsigneDepartA); ConsigneV = (int)(coefDirectV * (float)t.TotalSeconds + SelectedRecette.Segments[SelectedRecette.SegCours].ConsigneDepartV); if (ValuesA.Count < 500) { ValuesA.Add(ConsigneV); ValuesB.Add(ConsigneA); } else { for (int i = 0; i < ValuesA.Count - 1; i++) { ValuesA[i] = ValuesA[i + 1]; ValuesB[i] = ValuesB[i + 1]; ValuesA[ValuesA.Count - 1] = ConsigneV; ValuesB[ValuesA.Count - 1] = ConsigneA; } } } else { SelectedRecette.SegCours++; if (SelectedRecette.SegCours >= SelectedRecette.Segments.Count) { SelectedRecette.SegCours--; OnOff = false; Messenger.Default.Send(SelectedRecette); } } } WriteModbus(); } }
public void Update() { /*for(var i = 0; i < 100; i++) * { * ValuesA[i].X = Globals.COGxArray[500 + i]; * ValuesA[i].Y = Globals.COGyArray[500 + i]; * ValuesA[i].Weight = 0.0001; * }*/ ValuesA.Add(new ObservablePoint(Globals.COGx, Globals.COGy)); if (ValuesA.Count > 50) { ValuesA.RemoveAt(0); } //ValuesA[0].X = Globals.COPx; //ValuesA[0].Y = Globals.COPy; ValuesB[0].X = Globals.COGx; ValuesB[0].Y = Globals.COGy; ValuesB[0].Weight = 1; }
static void GetPeriod(ValuesA a, ValuesC c, ValuesM m, ValuesX0 x0) { var generator = new RandomSequenceGenerator ( EnumValuesParser.GetValueA(a), EnumValuesParser.GetValueC(c), EnumValuesParser.GetValueM(m), EnumValuesParser.GetValueX0(x0) ); //FileWriter.WritePartOfSequenceToFile(filePath, generator.GetNextSequencePart()); while (!generator.IsEnded) { generator.GetNextSequencePart(); } Console.WriteLine($"{count++}) Period: {generator.Period}"); Console.WriteLine(); }
public static long GetValueA(ValuesA val) { switch (val) { case ValuesA.Pow2to5: { return((long)Math.Pow(2, 5)); } case ValuesA.Pow3to5: { return((long)Math.Pow(3, 5)); } case ValuesA.Pow4to5: { return((long)Math.Pow(4, 5)); } case ValuesA.Pow5to5: { return((long)Math.Pow(5, 5)); } case ValuesA.Pow6to5: { return((long)Math.Pow(6, 5)); } case ValuesA.Pow2to3: { return((long)Math.Pow(2, 3)); } case ValuesA.Pow3to3: { return((long)Math.Pow(3, 3)); } case ValuesA.Pow4to3: { return((long)Math.Pow(4, 3)); } case ValuesA.Pow5to3: { return((long)Math.Pow(5, 3)); } case ValuesA.Pow6to3: { return((long)Math.Pow(6, 3)); } case ValuesA.Pow7to3: { return((long)Math.Pow(7, 3)); } case ValuesA.Pow8to3: { return((long)Math.Pow(8, 3)); } case ValuesA.Pow9to3: { return((long)Math.Pow(9, 3)); } case ValuesA.Pow10to3: { return((long)Math.Pow(10, 3)); } case ValuesA.Pow11to3: { return((long)Math.Pow(11, 3)); } case ValuesA.Pow12to3: { return((long)Math.Pow(12, 3)); } case ValuesA.Pow13to3: { return((long)Math.Pow(13, 3)); } case ValuesA.Pow14to3: { return((long)Math.Pow(14, 3)); } case ValuesA.Pow15to3: { return((long)Math.Pow(15, 3)); } case ValuesA.Pow16to3: { return((long)Math.Pow(16, 3)); } case ValuesA.Pow17to3: { return((long)Math.Pow(17, 3)); } case ValuesA.Pow7to5: { return((long)Math.Pow(7, 5)); } case ValuesA.Pow2to16: { return((long)Math.Pow(2, 16)); } case ValuesA.Pow2to15: { return((long)Math.Pow(2, 15)); } case ValuesA.Pow2to14: { return((long)Math.Pow(2, 14)); } default: throw new Exception("Unknown value"); } }