/// <summary> /// Compares the groups by the alphabetical position of their names, if they have the same name then by CompareTo for analog groups. /// </summary> /// <returns>Returns 1 if group1 > group2, -1 if group2 > group1, and 0 if group1 = group2</returns> public static int CompareByAlphabeticalPosition(AnalogGroup group1, AnalogGroup group2) { //Check if either group is null, and treat null as less than an actual group if (group1 == null && group2 == null) { return(0); } else if (group1 == null && group2 != null) { return(-1); } else if (group1 != null && group2 == null) { return(1); } //The group whose name has an earlier alphabetical position will come first int comparison = String.Compare(group1.groupName, group2.groupName, StringComparison.CurrentCulture); //If the names were the same, then resort to the normal comparison (by ID #) if (comparison == 0) { comparison = group1.CompareTo(group2); } return(comparison); }
/// <summary> /// Creates an exact copy of copyMe. Make sure to immediately create a unique ID for the analog group when you call this! /// </summary> /// <param name="copyMe">Analog group that will be copied.</param> public void Copy(AnalogGroup copyMe) { GroupName = "Copy of " + copyMe.GroupName; TimeResolution = copyMe.TimeResolution; UserAnalogGroup = copyMe.UserAnalogGroup; GroupDescription = copyMe.GroupDescription; ID = copyMe.ID; foreach (int channelID in copyMe.getChannelIDs()) { if (!channelExists(channelID)) { addChannel(channelID); } ChannelDatas[channelID].ChannelEnabled = copyMe.ChannelDatas[channelID].ChannelEnabled; ChannelDatas[channelID].ChannelWaveformIsCommon = copyMe.ChannelDatas[channelID].ChannelWaveformIsCommon; if (ChannelDatas[channelID].ChannelWaveformIsCommon) { ChannelDatas[channelID].waveform = copyMe.ChannelDatas[channelID].waveform; } else { ChannelDatas[channelID].waveform.DeepCopyWaveform(copyMe.ChannelDatas[channelID].waveform); } } }
private static bool CompareAnalogGroups(string preString, AnalogGroup a, AnalogGroup b, List <SequenceDifference> ans) { bool diffs = false; diffs |= CompareGroups <AnalogGroupChannelData>(preString, a, b, ans, CompareAnalogChannelData); diffs |= CompareParameters(preString + "time resolution ", a.TimeResolution, b.TimeResolution, ans); return(diffs); }
/// <summary> /// Tests if group1 and group2 have the same ID. /// </summary> /// <returns>Returns TRUE if they have the same ID, and FALSE if they do not.</returns> public bool Equals(AnalogGroup group1, AnalogGroup group2) { if (group1 == null || group2 == null) { return(false); } return(group1.Equals(group2)); }
/// <summary> /// Compares the ID of the input analog group to the group this method was called on. /// </summary> public int CompareTo(AnalogGroup compareTo) { if (compareTo == null) { return(1); } return(ID.CompareTo(compareTo.ID)); }
/// <summary> /// Returns the ID of analog group. /// </summary> /// <returns>Returns the ID of group, or 0 if the input is null.</returns> public int GetHashCode(AnalogGroup group) { if (group == null) { return(0); } return(group.GetHashCode()); }
/// <summary> /// Tests if analog group has the same ID as the group this was called on. /// </summary> /// <returns>Returns TRUE if they have the same ID, and FALSE if they do not.</returns> public bool Equals(AnalogGroup group) { if (group == null) { return(false); } else { return(ID.Equals(group.ID)); } }
/// <summary> /// Tests if obj is an analog group and has the same ID as the group this was called on. /// </summary> /// <returns>Returns TRUE if they have the same ID, and FALSE if they do not.</returns> public override bool Equals(object obj) { if (obj == null) { return(false); } AnalogGroup group = obj as AnalogGroup; if (group == null) { return(false); } return(Equals(group)); }
/// <summary> /// returns null if there is no waveform associated with that analog channel ID. Otherwise returns the waveform. /// </summary> /// <param name="analogChannelID"></param> /// <returns></returns> public Waveform getChannelWaveform(int analogChannelID) { if (AnalogGroup == null) { return(null); } if (!AnalogGroup.containsChannelID(analogChannelID)) { return(null); } if (!AnalogGroup.ChannelDatas[analogChannelID].ChannelEnabled) { return(null); } return(AnalogGroup.ChannelDatas[analogChannelID].waveform); }
/// <summary> /// Compare the groups by their ID numbers. /// </summary> /// <returns>Returns 1 if group1 > group2, -1 if group2 > group1, and 0 if group1 = group2</returns> public static int CompareByGroupID(AnalogGroup group1, AnalogGroup group2) { //Check if either group is null, and treat null as less than an actual group if (group1 == null && group2 == null) { return(0); } else if (group1 == null && group2 != null) { return(-1); } else if (group1 != null && group2 == null) { return(1); } //Since neither group is null, compare by ID # return(group1.CompareTo(group2)); }