private void createConverterBase(Converter conv) { ConvertFM.Visibility = Visibility.Hidden; ConvertBDF.Visibility = Visibility.Hidden; conv.channels = this.channels; conv.EDE = (EventDictionaryEntry)listView1.SelectedItem; conv.equalStatusOnly = (bool)ExactStatus.IsChecked; conv.continuousSearch = (bool)ContinuousSearch.IsChecked; if (ExtSearch.Text != "") conv.maxSearch = (int)(_extSearch * oldSR + 0.5); else conv.maxSearch = Int32.MaxValue; conv.risingEdge = conv.EDE.rise; // fixed entry until we allow discordant edges conv.threshold = _extThreshold; conv.directory = this.directory; conv.GV = listView2.SelectedItems.Cast<GVEntry>().ToList<GVEntry>(); conv.eventHeader = this.head; conv.decimation = _decimation; conv.removeOffsets = removeOffsets.IsEnabled && (bool)removeOffsets.IsChecked; conv.removeTrends = removeTrends.IsEnabled && (bool)removeTrends.IsChecked; conv.radinOffset = Radin.IsEnabled && (bool)Radin.IsChecked; if (conv.radinOffset) { conv.radinLow = System.Convert.ToInt32(RadinLowPts.Text); conv.radinHigh = System.Convert.ToInt32(RadinHighPts.Text); } if ((bool)radioButton2.IsChecked) //list of reference channels { conv.referenceGroups = new List<List<int>>(1); conv.referenceGroups.Add(conv.channels); // All channels are referenced to conv.referenceChannels = new List<List<int>>(1); // this list of channels conv.referenceChannels.Add(_refChan); } else if ((bool)radioButton4.IsChecked) //Reference expression { conv.referenceGroups = new List<List<int>>(); conv.referenceChannels = new List<List<int>>(); for (int i = 0; i < _refChanExp.Count; i += 2) { conv.referenceGroups.Add(_refChanExp[i]); conv.referenceChannels.Add(_refChanExp[i + 1]); } correctReferenceLists(conv); } else // no overall reference { conv.referenceGroups = null; conv.referenceChannels = null; } conv.BDF = bdf; }
public void registerHeader(Converter c) { string conversionType; double recordLength; if (c.GetType() == typeof(FMConverter)) { conversionType = "FM"; recordLength = ((FMConverter)c).length; } else //BDFConverter { conversionType = "BDF"; recordLength = (double)((BDFConverter)c).length; } logStream.WriteStartElement("Conversion"); logStream.WriteAttributeString("Type", conversionType); logStream.WriteElementString("Computer", Environment.MachineName); logStream.WriteElementString("User", Environment.UserName); logStream.WriteElementString("Source", c.directory); logStream.WriteStartElement("Event"); logStream.WriteAttributeString("Name", c.EDE.Name); logStream.WriteElementString("Type", c.EDE.intrinsic ? "intrinsic" : "extrinsic"); logStream.WriteElementString("Continuous", c.continuousSearch ? "Yes" : "No"); logStream.WriteElementString("ExactMatch", c.equalStatusOnly ? "Yes" : "No"); if (!c.EDE.intrinsic) { logStream.WriteElementString("Channel", c.EDE.channelName); logStream.WriteElementString("Edge", c.EDE.rise ? "rising" : "falling"); logStream.WriteElementString("Location", c.EDE.location ? "after" : "before"); logStream.WriteElementString("Min", c.EDE.channelMin.ToString("G6") + c.BDF.dimension(c.EDE.channel)); logStream.WriteElementString("Max", c.EDE.channelMax.ToString("G6") + c.BDF.dimension(c.EDE.channel)); logStream.WriteElementString("Threshold", (c.threshold * 100D).ToString("0.0") + "%"); logStream.WriteElementString("MaxSearch", c.maxSearch.ToString("0") + "pts"); } logStream.WriteEndElement(/* Event */); logStream.WriteStartElement("GroupVars"); foreach (GVEntry gv in c.GV) logStream.WriteElementString("GroupVar", gv.Name); logStream.WriteEndElement(/* GroupVars */); logStream.WriteElementString("Channels", CCIUtilities.Utilities.intListToString(c.channels, true)); logStream.WriteStartElement("Record"); if (conversionType == "BDF") logStream.WriteElementString("BDFContinuous", ((BDFConverter)c).allSamps?"true":"false"); logStream.WriteElementString("Start", c.offset.ToString("0.00") + "secs"); logStream.WriteElementString("Length", recordLength.ToString("0.00") + "secs"); logStream.WriteElementString("Decimation", c.decimation.ToString("0")); logStream.WriteStartElement("Processing"); string p; if (c.radinOffset) p = "Radin: " + c.radinLow.ToString("0") + " to " + c.radinHigh.ToString("0") + "pts"; else { p = "None"; if (c.removeTrends) p = "Offset and linear trend removal"; else if (c.removeOffsets) p = "Offset removal"; } logStream.WriteString(p); logStream.WriteEndElement(/* Processing */); logStream.WriteEndElement(/* Record */); logStream.WriteStartElement("Reference"); if (c.referenceGroups == null || c.referenceGroups.Count == 0) logStream.WriteAttributeString("Type", "None"); else { logStream.WriteAttributeString("Type", "Channel"); for (int i = 0; i < c.referenceGroups.Count; i++) { logStream.WriteStartElement("ReferenceGroup"); logStream.WriteElementString("Channels", CCIUtilities.Utilities.intListToString(c.referenceGroups[i], true)); logStream.WriteElementString("ReferenceChans", CCIUtilities.Utilities.intListToString(c.referenceChannels[i], true)); logStream.WriteEndElement(/*ReferenceGroup*/); } } logStream.WriteEndElement(/* Reference */); logStream.WriteEndElement(/* Conversion */); }
private void correctReferenceLists(Converter conv) { List<List<int>> list = conv.referenceGroups; for (int c = 1; c < list.Count; c++) //don't need to check first list { List<int> chanList1 = list[c]; for (int chan = 0; chan < chanList1.Count; chan++) { int chan1 = chanList1[chan]; //channel number to look for for (int d = 0; d < c; d++) //look into previous lists only { List<int> chanList2 = list[d]; for (int comp = chanList2.Count - 1; comp >= 0; comp--) //always work backwards to avoid changing indices if (chan1 == chanList2[comp]) //remove element from chanList2 chanList2.Remove(chanList2[comp]); //assumes that no dupes within lists (enforced by parser) } } } for (int i = list.Count - 1; i >= 0; i--) { if (list[i].Count == 0) { list.Remove(list[i]); conv.referenceChannels.Remove(conv.referenceChannels[i]); } } }