/// <summary> /// Aktiviert die Entschlüsselung eines Senders. /// </summary> /// <param name="pmt">Daten zum Sender.</param> /// <returns>Die neue Befehlssequenz.</returns> public static CACommand CreateDecrypt(PMT pmt) { // Create helper byte[] table = pmt.Section.CreateSITable(); // Create CACommand command = new CACommand(); // Fill command command.Tag = (byte)CACommandTags.Decrypt; command.CommandData = new byte[MaxDataLength]; // Fill data command.CommandData[0] = (byte)CAListTypes.One; command.CommandData[1] = (byte)PMTCommands.Descramble; // Calculate the length - we are in trouble if PMT is too long! command.Length = (ushort)(2 + Math.Min(command.CommandData.Length - 2, table.Length - 1)); // Copy over and get rid of the offset byte Array.Copy(table, 1, command.CommandData, 2, command.Length - 2); // Report return(command); }
/// <summary> /// Wertet eine SI Tabelle aus. /// </summary> /// <param name="pmt"></param> private void OnPMTFound(PMT pmt) { // Validate if (pmt != null) { if (pmt.ProgramNumber != m_WaitForService) { pmt = null; } } // Disable or restart m_WaitForService = m_ResetAfterServiceFound; m_WaitForPID = 0; // Nothing to do if (pmt == null) { return; } // Forward var callback = PMTFound; if (callback != null) { callback(pmt); } }
public async Task <ActionResult> Calculate(PMT pmt) { var accessToken = await GetGraphAccessTokenAsync(); // get the values from the modelstate class (pmt) // as a percentage per month decimal rate = pmt.InterestRate / 12 / 100; // inverse the amount (simply to show the value as a positive amount) decimal loanAmount = pmt.LoanAmount * -1; // number of months int numberOfMonths = pmt.NumberOfMonths; // call one of the built-in workbook functions (pmt) var restUrl = string.Format(@"{0}/v1.0/me/drive/root:/book.xlsx:/workbook/functions/pmt", graphResourceUrl); var pmtRequest = new PMTRequest { Rate = rate, Nper = numberOfMonths, Pv = loanAmount }; var result = await DoRequestAsync(HttpMethod.Post, pmtRequest, restUrl, accessToken); // refresh the model's MonthlyPaymentAmount ModelState.Remove("MonthlyPaymentAmount"); dynamic v = JObject.Parse(result); decimal value = v.value; // for financial purposes round the value to 2 dp pmt.MonthlyPaymentAmount = Math.Round(value, 2); return(View("Index", pmt)); }
/// <summary> /// Die Übersicht über eine Quelle. /// </summary> /// <param name="table">Die Details zur Quelle.</param> private void ProcessMappingTable(PMT table) { // Use earlier DVB.NET imnplementation var pmt = table.Table; if (!pmt.IsValid) { return; } // Register in map m_lastPMTs[pmt.ProgramNumber] = pmt; }
/// <summary> /// Read PAT table, find PMT table, and read that to get the *FIRST* video & audio PIDs. /// Will not change the PIDs after they've first been mapped (to prevent accidental switching). /// </summary> private void MapVideoAudioPIDs() { if (VideoPID > 0 && AudioPID > 0) { return; // Both already mapped } // Should have at least one packet in PID = 0; // Read PAT to find PMT PID: if (!Packets.ContainsKey(0)) { throw new DemuxException("Did not find a PAT packet stream"); } int pmt_pid = DecodePAT(); foreach (var pat_pkt in Packets[pmt_pid]) { PMT pmt = new PMT(pat_pkt.payload); if (pmt.ReverseMap.Count < 1) { continue; // no fields } if (pmt.ReverseMap.ContainsKey(PMT.StreamType.Audio)) // map audio { if (AudioPID <= 0) // not already mapped { AudioPID = pmt.ReverseMap[PMT.StreamType.Audio]; WaitingFrames.Add(AudioPID, new Queue <GenericMediaFrame>()); Timestamps.Add(AudioPID, -1); } } if (pmt.ReverseMap.ContainsKey(PMT.StreamType.Video)) // map audio { if (VideoPID <= 0) // not already mapped { VideoPID = pmt.ReverseMap[PMT.StreamType.Video]; WaitingFrames.Add(VideoPID, new Queue <GenericMediaFrame>()); Timestamps.Add(VideoPID, -1); } } } }
/// <summary> /// Wertet die nächste Tabelle aus. /// </summary> /// <param name="table">Eine aktuelle Tabelle.</param> private void ProcessNext(PMT table) { // Got new data if (table != null) { if (table.IsValid) { // See of there is a previous one PMT previous; if (m_lastTable.TryGetValue(table.ProgramNumber, out previous)) { // Report on change or first request if ((previous == null) || (previous.Version != table.Version)) { if (!m_processor(table, previous == null)) { return; } } // Update m_lastTable[table.ProgramNumber] = table; } } } // Next source to request var source = m_services[m_index++]; // Clip if (m_index == m_services.Length) { m_index = 0; } // Fire up m_graph.ActivatePMTWatchDog(source, ProcessNext); }
/// <summary> /// Read PAT table, find PMT table, and read that to get the *FIRST* video & audio PIDs. /// Will not change the PIDs after they've first been mapped (to prevent accidental switching). /// </summary> private void MapVideoAudioPIDs() { if (VideoPID > 0 && AudioPID > 0) return; // Both already mapped // Should have at least one packet in PID = 0; // Read PAT to find PMT PID: if (!Packets.ContainsKey(0)) throw new DemuxException("Did not find a PAT packet stream"); int pmt_pid = DecodePAT(); foreach (var pat_pkt in Packets[pmt_pid]) { PMT pmt = new PMT(pat_pkt.payload); if (pmt.ReverseMap.Count < 1) continue; // no fields if (pmt.ReverseMap.ContainsKey(PMT.StreamType.Audio)) { // map audio if (AudioPID <= 0) { // not already mapped AudioPID = pmt.ReverseMap[PMT.StreamType.Audio]; WaitingFrames.Add(AudioPID, new Queue<GenericMediaFrame>()); Timestamps.Add(AudioPID, -1); } } if (pmt.ReverseMap.ContainsKey(PMT.StreamType.Video)) { // map audio if (VideoPID <= 0) { // not already mapped VideoPID = pmt.ReverseMap[PMT.StreamType.Video]; WaitingFrames.Add(VideoPID, new Queue<GenericMediaFrame>()); Timestamps.Add(VideoPID, -1); } } } }
public BuiltInFunctions() { // Text Functions["len"] = new Len(); Functions["lower"] = new Lower(); Functions["upper"] = new Upper(); Functions["left"] = new Left(); Functions["right"] = new Right(); Functions["mid"] = new Mid(); Functions["replace"] = new Replace(); Functions["rept"] = new Rept(); Functions["substitute"] = new Substitute(); Functions["concatenate"] = new Concatenate(); Functions["char"] = new CharFunction(); Functions["exact"] = new Exact(); Functions["find"] = new Find(); Functions["fixed"] = new Fixed(); Functions["proper"] = new Proper(); Functions["search"] = new Search(); Functions["text"] = new Text.Text(); Functions["t"] = new T(); Functions["hyperlink"] = new Hyperlink(); Functions["value"] = new Value(); // Numbers Functions["int"] = new CInt(); // Math Functions["abs"] = new Abs(); Functions["asin"] = new Asin(); Functions["asinh"] = new Asinh(); Functions["cos"] = new Cos(); Functions["cosh"] = new Cosh(); Functions["power"] = new Power(); Functions["sign"] = new Sign(); Functions["sqrt"] = new Sqrt(); Functions["sqrtpi"] = new SqrtPi(); Functions["pi"] = new Pi(); Functions["product"] = new Product(); Functions["ceiling"] = new Ceiling(); Functions["count"] = new Count(); Functions["counta"] = new CountA(); Functions["countblank"] = new CountBlank(); Functions["countif"] = new CountIf(); Functions["countifs"] = new CountIfs(); Functions["fact"] = new Fact(); Functions["floor"] = new Floor(); Functions["sin"] = new Sin(); Functions["sinh"] = new Sinh(); Functions["sum"] = new Sum(); Functions["sumif"] = new SumIf(); Functions["sumifs"] = new SumIfs(); Functions["sumproduct"] = new SumProduct(); Functions["sumsq"] = new Sumsq(); Functions["stdev"] = new Stdev(); Functions["stdevp"] = new StdevP(); Functions["stdev.s"] = new Stdev(); Functions["stdev.p"] = new StdevP(); Functions["subtotal"] = new Subtotal(); Functions["exp"] = new Exp(); Functions["log"] = new Log(); Functions["log10"] = new Log10(); Functions["ln"] = new Ln(); Functions["max"] = new Max(); Functions["maxa"] = new Maxa(); Functions["median"] = new Median(); Functions["min"] = new Min(); Functions["mina"] = new Mina(); Functions["mod"] = new Mod(); Functions["average"] = new Average(); Functions["averagea"] = new AverageA(); Functions["averageif"] = new AverageIf(); Functions["averageifs"] = new AverageIfs(); Functions["round"] = new Round(); Functions["rounddown"] = new Rounddown(); Functions["roundup"] = new Roundup(); Functions["rand"] = new Rand(); Functions["randbetween"] = new RandBetween(); Functions["rank"] = new Rank(); Functions["rank.eq"] = new Rank(); Functions["rank.avg"] = new Rank(true); Functions["quotient"] = new Quotient(); Functions["trunc"] = new Trunc(); Functions["tan"] = new Tan(); Functions["tanh"] = new Tanh(); Functions["atan"] = new Atan(); Functions["atan2"] = new Atan2(); Functions["atanh"] = new Atanh(); Functions["acos"] = new Acos(); Functions["acosh"] = new Acosh(); Functions["var"] = new Var(); Functions["varp"] = new VarP(); Functions["large"] = new Large(); Functions["small"] = new Small(); Functions["degrees"] = new Degrees(); // Information Functions["isblank"] = new IsBlank(); Functions["isnumber"] = new IsNumber(); Functions["istext"] = new IsText(); Functions["isnontext"] = new IsNonText(); Functions["iserror"] = new IsError(); Functions["iserr"] = new IsErr(); Functions["error.type"] = new ErrorType(); Functions["iseven"] = new IsEven(); Functions["isodd"] = new IsOdd(); Functions["islogical"] = new IsLogical(); Functions["isna"] = new IsNa(); Functions["na"] = new Na(); Functions["n"] = new N(); // Logical Functions["if"] = new If(); Functions["iferror"] = new IfError(); Functions["ifna"] = new IfNa(); Functions["not"] = new Not(); Functions["and"] = new And(); Functions["or"] = new Or(); Functions["true"] = new True(); Functions["false"] = new False(); // Reference and lookup Functions["address"] = new Address(); Functions["hlookup"] = new HLookup(); Functions["vlookup"] = new VLookup(); Functions["lookup"] = new Lookup(); Functions["match"] = new Match(); Functions["row"] = new Row() { SkipArgumentEvaluation = true }; Functions["rows"] = new Rows() { SkipArgumentEvaluation = true }; Functions["column"] = new Column() { SkipArgumentEvaluation = true }; Functions["columns"] = new Columns() { SkipArgumentEvaluation = true }; Functions["choose"] = new Choose(); Functions["index"] = new Index(); Functions["indirect"] = new Indirect(); Functions["offset"] = new Offset() { SkipArgumentEvaluation = true }; // Date Functions["DATEDIF"] = new DATEDIF(); Functions["date"] = new Date(); Functions["today"] = new Today(); Functions["now"] = new Now(); Functions["day"] = new Day(); Functions["month"] = new Month(); Functions["year"] = new Year(); Functions["time"] = new Time(); Functions["hour"] = new Hour(); Functions["minute"] = new Minute(); Functions["second"] = new Second(); Functions["weeknum"] = new Weeknum(); Functions["weekday"] = new Weekday(); Functions["days360"] = new Days360(); Functions["yearfrac"] = new Yearfrac(); Functions["edate"] = new Edate(); Functions["eomonth"] = new Eomonth(); Functions["isoweeknum"] = new IsoWeekNum(); Functions["workday"] = new Workday(); Functions["networkdays"] = new Networkdays(); Functions["networkdays.intl"] = new NetworkdaysIntl(); Functions["datevalue"] = new DateValue(); Functions["timevalue"] = new TimeValue(); // Database Functions["dget"] = new Dget(); Functions["dcount"] = new Dcount(); Functions["dcounta"] = new DcountA(); Functions["dmax"] = new Dmax(); Functions["dmin"] = new Dmin(); Functions["dsum"] = new Dsum(); Functions["daverage"] = new Daverage(); Functions["dvar"] = new Dvar(); Functions["dvarp"] = new Dvarp(); //Financial Functions["Pmt"] = new PMT(); Functions["Rate"] = new Rate(); }
/// <summary> /// fill a user object from the form /// </summary> /// <param name="user"></param> public void fillUser(PMT.User user) { user.Address=this.AddressTextBox.Text; user.City=this.CityTextBox.Text; user.Email=this.EmailTextBox.Text; user.FirstName=this.FirstNameTextBox.Text; user.LastName=this.LastNameTextBox.Text; user.PhoneNumber=this.PhoneTextBox.Text; if(this.AllowChangeSecurity) user.Role=this.SecurityDropDownList.SelectedItem.Text; user.State=this.StateTextBox.Text; user.ZipCode=this.ZipTextBox.Text; if (NewPassword1TextBox.Text.Length > 0) user.Password=this.NewPassword1TextBox.Text; }
/// <summary> /// Fills the form with a user's information /// </summary> /// <param name="user">A PMT user</param> public void fillForm(PMT.User user) { this.FirstNameTextBox.Text = user.FirstName; this.FirstNameLabel.Text = user.FirstName; this.LastNameTextBox.Text = user.LastName; this.LastNameLabel.Text = user.LastName; this.AddressTextBox.Text = user.Address; this.AddressLabel.Text = user.Address; this.CityTextBox.Text = user.City; this.CityLabel.Text = user.City; this.StateTextBox.Text = user.State; this.StateLabel.Text = user.State; this.ZipTextBox.Text = user.ZipCode; this.ZipLabel.Text = user.ZipCode; this.PhoneTextBox.Text = user.PhoneNumber; this.PhoneLabel.Text = user.PhoneNumber; this.EmailTextBox.Text = user.Email; this.EmailLabel.Text = user.Email; //if (this.UsernameTextBox.Enabled) this.UsernameTextBox.Text = user.UserName; this.UsernameLabel.Text = user.UserName; // select the correct Security in the dropdown //if (this.SecurityDropDownList.Enabled) SecurityDropDownList.SelectedIndex = SecurityDropDownList.Items.IndexOf( SecurityDropDownList.Items.FindByText(user.Role)); this.SecurityLabel.Text = user.Role; }
/// <summary> /// Ermittelt aus der aktuellen <i>Program Map Table</i> die Informationen zum /// Porgramm des eingehenden Transport Streams. /// </summary> /// <remarks> /// Dabei wird das Bild- und das gewünschte Tonsignal ermittelt und in den Transport /// Stream für den DirectShow Graphen übertragen. Dieser kann so mit festen PIDs /// arbeiten, wodurch die weitere Handhabung im DVB.NET DirectShow Graphen vereinfacht wird. /// Man kann die Arbeit dieser Methode daher als Auswahl der Tonspur und PID Mapping /// beschreiben. /// </remarks> /// <param name="pmt">Eine SI Tabelle.</param> private void ProcessPMT(Section pmt) { // Not active if (!IsRunning) { return; } // Validate if (!pmt.IsValid) { return; } // Attach to table PMT table = pmt.Table as PMT; // Validate if (null == table) { return; } if (!table.IsValid) { return; } if (null == table.ProgramEntries) { return; } if (table.ProgramEntries.Length < 1) { return; } // Remember m_CurrentService = table.ProgramNumber; // All audio List <AudioItem> audios = new List <AudioItem>(); // Video and audio ushort video = 0, audio = 0, ttx = 0; bool mpeg4 = false, ac3 = false; // Process all programs foreach (ProgramEntry program in table.ProgramEntries) { if ((program.StreamType == StreamTypes.Audio11172) || (program.StreamType == StreamTypes.Audio13818)) { // Remember MP2 audios.Add(new AudioItem(program, false, audios.Count)); } else if ((program.StreamType == StreamTypes.Video13818) || (program.StreamType == StreamTypes.H264)) { // Only first video if (0 != video) { continue; } // Remember mpeg4 = (StreamTypes.H264 == program.StreamType); video = program.ElementaryPID; } else if (program.StreamType == StreamTypes.PrivateData) { // Modes bool ac3Found = false, ttxFound = false; // Scan descriptors foreach (Descriptor descriptor in program.Descriptors) { if (!ac3Found && (descriptor is AC3)) { // Add to list audios.Add(new AudioItem(program, true, audios.Count)); // Done ac3Found = true; } else if (!ttxFound && (descriptor is Teletext)) { // Remember ttx = program.ElementaryPID; // Done ttxFound = true; } } } } // Always update name list m_AudioNames = audios.ConvertAll <string>(item => item.Name).ToArray(); // Read the audio index int audioIndex = AudioIndex; // Reset to default if ((audioIndex < 0) || (audioIndex >= audios.Count)) { audioIndex = 0; } // Check result if (audioIndex < audios.Count) { // Load item AudioItem item = audios[AudioIndex]; // Copy all audio = item.PID; ac3 = item.AC3; } // Check changes bool videoDecChanged = (mpeg4 != m_MPEG4) || m_RestartAV; bool videoChanged = (video != m_Video) || m_RestartAV; bool audioChanged = (audio != m_Audio) || m_RestartAV; bool audioDecChanged = (ac3 != m_AC3) || m_RestartAV; bool ttxChanged = (ttx != m_TTX) || m_RestartAV; // No change at all if (!videoChanged) { if (!videoDecChanged) { if (!audioChanged) { if (!audioDecChanged) { if (!ttxChanged) { return; } } } } } // Discard old if (null != m_TSParser) { // De-register if (videoChanged && (0 != m_Video)) { m_TSParser.RemoveFilter(m_Video); } if (audioChanged && (0 != m_Audio)) { m_TSParser.RemoveFilter(m_Audio); } if (ttxChanged && (0 != m_TTX)) { m_TSParser.RemoveFilter(m_TTX); } } // Check for enforcement bool first = ((0 == m_Video) && (0 == m_Audio)) || m_RestartAV; // Change AudioIndex = audioIndex; m_RestartAV = false; m_Video = video; m_Audio = audio; m_MPEG4 = mpeg4; m_AC3 = ac3; m_TTX = ttx; // Register new if (null != m_TSParser) { // De-register if (videoChanged && (0 != m_Video)) { m_TSParser.SetFilter(m_Video, false, AddVideo); } if (audioChanged && (0 != m_Audio)) { m_TSParser.SetFilter(m_Audio, false, AddAudio); } if (ttxChanged && (0 != m_TTX)) { m_TSParser.SetFilter(m_TTX, false, m_TTXStream.AddPayload); } } // Attach to client var streamChanged = StreamChanged; if (streamChanged != null) { streamChanged(first || videoDecChanged || audioDecChanged); } }