/// <summary> /// 周波数列挙体を文字列に変換します。 /// </summary> /// <param name="freq">周波数列挙体</param> public static string ToString(Freqs freq) { try { return(FreqNames[(int)freq]); } catch { return(""); } }
protected override void InternalConverter(RmtpDataFrame pDataFrame, object pParameter) { var index = 0; IType = pDataFrame.Data[index]; index += 1; FscanSegment = BitConverter.ToInt16(pDataFrame.Data, index); index += sizeof(short); StartFrequency = BitConverter.ToInt64(pDataFrame.Data, index); index += sizeof(Int64); EndFrequency = BitConverter.ToInt64(pDataFrame.Data, index); index += sizeof(Int64); Step = BitConverter.ToInt64(pDataFrame.Data, index); index += sizeof(Int64); Points = BitConverter.ToInt32(pDataFrame.Data, index); index += sizeof(int); Antennafactors = BitConverter.ToInt32(pDataFrame.Data, index); index += sizeof(int); FscanTypeCount = BitConverter.ToInt16(pDataFrame.Data, index); index += sizeof(short); for (var i = 0; ; i++) { var freq = (StartFrequency + i * Step) / 1000; // 转成kHz if (freq > (EndFrequency / 1000)) { break; } if (!Freqs.Contains(freq)) { Freqs.Add(freq); } } for (var i = 0; i < FscanTypeCount; i++) { var name = Encoding.UTF8.GetString(pDataFrame.Data, index, 16).TrimEnd('$').TrimEnd('\0'); index += 16; var value = BitConverter.ToSingle(pDataFrame.Data, index); index += sizeof(float); var unit = Encoding.UTF8.GetString(pDataFrame.Data, index, 10).TrimEnd('$').TrimEnd('\0'); index += 10; ScanTypes.Add(new Tuple <string, long, string, int>(name, (long)value, unit, i)); } }
public override String ToString() { StringBuilder sb = new StringBuilder(); sb.Append("TCount = " + TCount); sb.Append("\tIds: " + Ids.ToString()); sb.Append("\tFreqs: " + Freqs.ToString()); sb.Append("\n\tTF: " + Probs.ToString()); sb.Append("\n\tIDF: " + IDF); sb.Append("\n\tWeights: " + Weights.ToString()); sb.Append("\n"); return(sb.ToString()); }
public double GetPFdInAt(double freq) { if (PFdIn == null || Freqs == null || freq < Freqs.First() || freq > Freqs.Last()) { return(Double.NaN); } int i; for (i = 0; i < Freqs.Length && Freqs[i] < freq; i++) { ; } if (freq == Freqs[i]) { return(PFdIn[i]); } // Interpolate (linear) return(PFdIn[i - 1] + (PFdIn[i] - PFdIn[i - 1]) / (Freqs[i] - Freqs[i - 1]) * (freq - Freqs[i - 1])); }
protected override void InternalConverter(RmtpDataFrame pDataFrame, object pParameter) { var index = 0; IType = pDataFrame.Data[index]; index += 1; Antennafactors = BitConverter.ToInt32(pDataFrame.Data, index); index += sizeof(int); MscanTypeCount = BitConverter.ToInt16(pDataFrame.Data, index); index += sizeof(short); MscanPoint = BitConverter.ToInt16(pDataFrame.Data, index); index += sizeof(short); Freqs.Clear(); for (var i = 0; i < MscanPoint; i++) { Freqs.Add(BitConverter.ToInt64(pDataFrame.Data, index) / 1000000d); // 转成 MHz index += sizeof(Int64); } for (var i = 0; i < MscanTypeCount; i++) { var name = Encoding.UTF8.GetString(pDataFrame.Data, index, 16).TrimEnd('$').TrimEnd('\0'); index += 16; var value = BitConverter.ToSingle(pDataFrame.Data, index); index += 4; var unit = Encoding.UTF8.GetString(pDataFrame.Data, index, 10).TrimEnd('$').TrimEnd('\0'); index += 10; ScanTypes.Add(new Tuple <string, long, string, int>(name, (long)value, unit, i)); } }
public Bigram(string unigramFile, string bigramFile) { this.freqs = new Freqs { One = Zip2Dict(unigramFile, line => { var toks = line.Trim().Split(' '); var n = int.Parse(toks[0]); var x = Tok2Word(toks[1]); return(Tuple.Create(x, n)); }), Two = Zip2Dict(bigramFile, line => { var toks = line.Split(' '); var n = int.Parse(toks[0]); var x = Tuple.Create( Tok2Word(toks[1]), Tok2Word(toks[2]) ); return(Tuple.Create(x, n)); }), }; this.freqOneSum = this.freqs.One.Values.Sum(); this.freqTwoSum = this.freqs.Two.Values.Sum(); this.numVocabs = this.freqs.One.Keys.Count(); }
public override bool IngestValue(string sVal) { if (null == sVal) { Nulls++; sVal = "{NULL}"; } else if ("" == sVal) { Empties++; } else if (string.IsNullOrWhiteSpace(sVal)) { Blanks++; } if (!Freqs.ContainsKey(sVal)) { Freqs.Add(sVal, 0); } Freqs[sVal]++; Count++; return(true); }
public void SetItemDetails() { if (currentGroupItem == null || currentGroupItem.IsSpoof) { SelectedBrand = null; SelectedFreq = null; SelectedDeliveryMethod = null; SelectedPlatform = null; SelectedSpecialist = null; ContractName = null; if (ReportTypes != null) { ReportTypes.ForEach((thislist, thisreport) => RemoveWeakEventListener(thisreport, ReportListener)); ReportTypes = new ObservableReportTypes(safeReportTypes, true); ReportTypes.ForEach((thislist, thisreport) => AddWeakEventListener(thisreport, ReportListener)); } ClientLocations = null; RaisePropertyChanged("ReportTypes"); ReportText = "Select Report Types..."; return; } if (/*DB.Connnected &&*/ ReportTypes == null) { ReportTypes = new ObservableReportTypes(ReportTypesTarget.GetReportTypesAsList()); safeReportTypes = new ObservableReportTypes(ReportTypes, true); } if (CurrentGroupItem.ContractID == null) { ContractName = "No Contract assigned."; } else { Contract contract = ContractTarget.GetByContractID((int)CurrentGroupItem.ContractID); if (contract == null) { ContractName = "No contract found for this Group."; } else { ContractName = contract.DESCR; } } AddWeakEventListener(CurrentGroupItem, EncryptListener); IgReports = InvoiceGrpReportsTarget.GetById(currentGroupItem.InvoiceGrpId); foreach (ReportType reportType in ReportTypes) { foreach (InvoiceGrpReport igr in IgReports) { if (igr.REPORT_TYPE_ID == reportType.REPORT_TYPE_ID) { reportType.IsSelected = true; } else { reportType.IsSelected = false; } } } RaisePropertyChanged("ReportTypes"); base.ViewCore.UpdateCB(); SelectedSpecialist = (Specialists.First(ss => ss.Id == currentGroupItem.BillingSpecialistID) as BillingSpecialist); SelectedFreq = (Freqs.First(f => f.FREQ == currentGroupItem.BillingFrequency) as Freq); SelectedPlatform = (Platforms.First(p => p.PLATFORM == currentGroupItem.PrimaryPlatform) as Platform); SelectedDeliveryMethod = (DeliveryMethods.First(dm => dm.TheDeliveryMethod == currentGroupItem.DeliveryMethod) as DeliveryMethod); SelectedBrand = (Brands.FirstOrDefault(b => b.BRAND == currentGroupItem.Brand) as Brand); SelectedRemitTo = (RemitTos.First(r => r.REMIT_TO_ID == currentGroupItem.RemitToID) as RemitTo); SelectedInvoiceStyle = (InvoiceStyles.First(i => i.INVOICE_STYLE == currentGroupItem.InvoiceStyle) as InvoiceStyle); SelectedInvoiceGrpStatus = (InvoiceGrpStatuss.First(i => i.INVOICE_GRP_STATUS == currentGroupItem.InvoiceGroupStatus) as InvoiceGrpStatus); if (ClientLocations != null) { ClientLocations.CollectionChanged -= ClientLocCollectionChanged; } ClientLocations = ExtClientTarget.FetchLocations(CurrentGroupItem.InvoiceGrpId, true); ClientLocations.CollectionChanged += ClientLocCollectionChanged; currentGroupItem.Modified = false; GroupVM.EnablePicker = true; }