UEPGMHW.pas ( File view )

  • By sathex 2016-03-20
  • View(s):0
  • Download(s):0
  • Point(s): 1
			unit UEPGMHW;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, Buttons,ExtCtrls,UBitManager,UEPGEntry,
  UTS184ToBitFilter,DateUtils, ComCtrls, UfrmMHWEPGEntries, Menus;

const NewLine=chr(10);
{
$DEFINE DEBUG_MHWEPG=1
}

type RMHWChannel=record
    Name: String;
    DVBSID: WORD;
end;

type RMHWTheme=record
    Name: string;
    RootTheme: BYTE;
end;

type TMHWEPG=Class(TObject)
  protected
    mvarSortedEvents: integer;
    mvarSortedEventsByUniqueID: integer;
    mvarReceivedEvents: integer;
    mvarProcessedTables: integer;
  private
    mvarAllChannels: Boolean;
    mvarAllThemes: Boolean;
    mvarAllDescriptions: Boolean;
    mvarEPGEntries: TList;
    mvarEPGEntriesSortedByUniqueID: TList;
    mvarEPGEntriesSortedByMHWProgramIdent: TList;
    mvarRootThemes: Array [0..15] of Byte;
    mvarThemes: array [0..255] of RMHWTheme;
    mvarLastTheme: BYTE;
    mvarChannels: Array [0..255] of RMHWChannel;
    mvarT72Counter: integer;
    mvarDupeCounter1: integer;
    mvarFirstEvent1: DWORD;
    mvarDupeCounter2: integer;
    mvarFirstEvent2: DWORD;
    mvarPhase1IsComplete: Boolean;
    mvarNeedRepaint: Boolean;
    mvarExtendedReceived: integer;
    mvarEPGTimeOffset: integer;
    function GetEventsCount: integer;
    function GetEvent(index: integer): TEPGEntry;
    function QuickFindMHWProgramIdent(L: TList;li: integer; ui: integer; Target: DWORD): integer;
    function QuickFindEvent(L: TList;li: integer; ui: integer; Target: DWORD): integer;
    function QuickFindHour(L: TList;li: integer; ui: integer; TargetBegin: TDateTime; TargetEnd: TDateTime): integer;
    procedure SelectEventsBelongsToSID(L: TList; SID: DWORD);
    procedure ProcessMHWDescription(P: PBYTEARRAY;Len: integer);
    procedure ProcessMHWChannelNames(P: PBYTEARRAY;Len: integer);
    procedure ProcessMHWThemes(P: PBYTEARRAY;Len: integer);
    function GetChannelName(index: integer): String;
    function GetChannelID(index: integer): integer;
    function GetTheme(index: integer): string;
    procedure SortMHWProgramIdent;
  public
    property EventsCount: integer read GetEventsCount;
    property Event[index: integer]: TEPGEntry read GetEvent;
    Property ChannelName[index: integer]: String read GetChannelName;
    Property ChannelID[index: integer]: integer read GetChannelID;
    property Theme[index: integer]: string read GetTheme;
    property Phase1IsComplete: Boolean read mvarPhase1IsComplete;
    property TimeOffset: integer read mvarEPGTimeOffSet write mvarEPGTimeOffSet;
    function ConvertMJD40(P: PBYTEARRAY): TDateTime;
    Procedure AddEntry(EPG: TEPGEntry);
    procedure SortDateTime;
    function EventBelongsToMHWProgramIdent(ID: DWORD): TEPGEntry;
    function IsEventInList(EPG: TEPGEntry): Boolean;
    function EventsBelongsToTime(TimeBegin: TDateTime; TimeEnd: TDateTime): TList;
    function ProcessTableMHWEPG_D2(P: PBYTEARRAY; Len: integer): Boolean;
    function ProcessTableMHWEPG_D3(P: PBYTEARRAY; Len: integer): Boolean;
    Constructor Create;
    Destructor Destroy; override;
end;

type
  TfrmEPGMHW = class(TForm)
    MHWGrid: TStringGrid;
    tmrEffect: TTimer;
    pnlEffect: TPanel;
    lblF1: TLabel;
    lblF2: TLabel;
    lblF3: TLabel;
    lblEvents: TLabel;
    Label1: TLabel;
    Button1: TButton;
    cbDate: TDateTimePicker;
    pbExtended: TProgressBar;
    pbWorking: TProgressBar;
    butExport: TBitBtn;
    popExport: TPopupMenu;
    XMLTV: TMenuItem;
    SaveXML: TSaveDialog;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure tmrEffectTimer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure MHWGridDrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure cbDateChange(Sender: TObject);
    procedure MHWGridDblClick(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure MHWGridKeyPress(Sender: TObject; var Key: Char);
    procedure XMLTVClick(Sender: TObject);
    procedure butExportClick(Sender: TObject);
  private
    {
 Private declarations 
}
    mvarDefaultDock: TWinControl;
    mvarLoadingEffectStatus: integer;
    mvarEPGCleared: integer;
    EPG: TMHWEPG;
    mvarDefaultFolder: string;
    mvarExportPPVID: Boolean;
    mvarEPGTimeOffset: integer;
    mvarExportCharSet: String;
    mvarInvertTZ: Boolean;
    mvarPhase1CompleteFirstTime: Boolean;
    function DoubleSpaceRemove(s: string): string;
    function XMLEscape(S: string): string;
    Function WriteString(FileHandle: TFileStream;s: string): Boolean;
    function DarkNess(Cl: TColor; Intensity: integer): TColor;
    Procedure DrawEvent(Canvas: TCanvas;Rect: TRect; E: TEPGEntry;Text: String;State: TGridDrawState);
    Procedure CreateGrid;
    function GetPhase1IsComplete: Boolean;
    function GetPhase2IsComplete: Boolean;
    function getTimeOffset(): integer;
    procedure SetTimeOffset(const Value: integer);
  public
    {
 Public declarations 
}
    property EPGCleared: integer read mvarEPGCleared write mvarEPGCleared;
    property Phase1IsComplete: Boolean read GetPhase1IsComplete;
    property Phase2IsComplete: Boolean read GetPhase2IsComplete;
    property DefaultDock: TWinControl read mvarDefaultDock write mvarDefaultDock;
    property DefaultFolder: string read mvarDefaultFolder write mvarDefaultFolder;
    property ExportPPVEventID: Boolean read mvarExportPPVID write mvarExportPPVID;
    property TimeOffset: integer read getTimeOffset write SetTimeOffset;
    property XMLExportCharset: string read mvarExportCharSet write mvarExportCharSet;
    property InvertTZInformation: Boolean read mvarInvertTZ write mvarInvertTZ;
    procedure RefreshEPG;
    procedure SubmitMHWEPGTable_D2(P: PBYTEARRAY; Len: integer);
    procedure SubmitMHWEPGTable_D3(P: PBYTEARRAY; Len: integer);
    procedure Start;
    procedure Stop;
    procedure Reset;
    function ExportToXMLTV(FileHandle: TFileStream): Boolean;
  end;

var
  frmEPGMHW: TfrmEPGMHW;

implementation

uses Math;

{
$R *.dfm
}

function Sort_MHWProgramID(Po1, Po2: POINTER): integer;
var
    P1: TEPGEntry;
    P2: TEPGEntry;
begin
    P1:=Po1;
    P2:=Po2;
    if P1.MHWProgramIdent>P2.MHWProgramIdent Then begin
        Result:=1;
    end else if P1.MHWProgramIdent<P2.MHWProgramIdent Then begin
        Result:=-1
    end else begin
        Result:=0;
    end;
end;


function Sort_UniqueID(Po1, Po2: POINTER): integer;
var
    P1: TEPGEntry;
    P2: TEPGEntry;
begin
    P1:=Po1;
    P2:=Po2;
    if P1.UniqueID>P2.UniqueID Then begin
        Result:=1;
    end else if P1.UniqueID<P2.UniqueID Then begin
        Result:=-1
    end else begin
        Result:=0;
    end;
end;

function Sort_DateTime(Po1, Po2: POINTER): integer;
var
    P1: TEPGEntry;
    P2: TEPGEntry;
begin
    P1:=Po1;
    P2:=Po2;
    Result:=CompareDateTime(P1.StartTime,P2.StartTime);
{
    if P1.StartTime>P2.StartTime Then begin
        Result:=1;
    end else if P1.StartTime<P2.StartTime Then begin
        Result:=-1
    end else begin
        Result:=0;
    end;
}
end;

procedure TfrmEPGMHW.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
    if Assigned(mvarDefaultDock) Then begin
        CanClose:=false;
        Self.ManualDock(mvarDefaultDock,nil,alClient);
    end;
end;

procedure TfrmEPGMHW.FormCreate(Sender: TObject);
begin
    mvarDefaultDock:=nil;
    mvarPhase1CompleteFirstTime:=false;
    EPG:=nil;
    mvarExportPPVID:=false;
    Reset;
end;

procedure TfrmEPGMHW.SubmitMHWEPGTable_D2(P: PBYTEARRAY; Len: integer);
begin
    inc(EPG.mvarProcessedTables);
    if EPG.mvarProcessedTables mod 50 =0 Then begin
        if pbWorking.Position>99 Then begin
            pbWorking.Position:=0;
        end else begin
            pbWorking.Position:=pbWorking.position+1;
        end;
    end;
    if P[0]=$72 Then begin
        inc(EPG.mvarT72Counter);
        Exit;
    end;
    if P[0]=$90 Then begin
        EPG.ProcessTableMHWEPG_D2(P,Len);
        if epg.EventsCount mod 53 = 0 Then begin
            lblEvents.Caption:=inttostr(epg.EventsCount);
        end;
        if EPG.Phase1IsComplete Then begin
            lblEvents.Caption:=inttostr(epg.EventsCount);
            pbExtended.Max:=EPG.mvarExtendedReceived;
            EPG.mvarExtendedReceived:=0;
            if mvarPhase1CompleteFirstTime Then begin
                EPG.SortDateTime;
                EPG.SortMHWProgramIdent;
                RefreshEPG;
                mvarPhase1CompleteFirstTime:=false;
            end;
        end else begin
            mvarPhase1CompleteFirstTime:=true;
        end;
    end;
end;

procedure TfrmEPGMHW.tmrEffectTimer(Sender: TObject);
    function RColor(): TColor;
    var
        C: TColor;
    begin
        C:=RandomRange(1,4);
        Case C of
            1: C:=clSkyBlue;
            2: C:=clBlack;
            3: C:=clWhite;
        end;
        Result:=C;
    end;
begin
    lblF1.Color:=RColor();
    lblF2.Color:=RColor();
    lblF3.Color:=RColor();
end;

{
 TMHWEPG 
}

procedure TMHWEPG.AddEntry(EPG: TEPGEntry);
begin
    inc(mvarReceivedEvents);
    mvarEPGEntries.Add(EPG);
    mvarEPGEntriesSortedByUniqueID.Add(EPG);
    if EPG.MHWHaveSummary Then begin
        mvarEPGEntriesSortedByMHWProgramIdent.Add(EPG);
        inc(mvarExtendedReceived);
    end;
    if mvarEPGEntries.Count mod 1000 =0 Then begin
        //Sort UniqueIDs for quick find..
        mvarEPGEntriesSortedByUniqueID.Sort(Sort_UniqueID);
        mvarSortedEventsByUniqueID:=mvarEPGEntries.Count;
    end;
    if mvarReceivedEvents mod 1000 = 0 Then begin
        SortDateTime;
    end;
end;

constructor TMHWEPG.Create;
begin
    mvarEPGEntries:=TList.Create;
    mvarEPGEntriesSortedByUniqueID:=Tlist.Create;
    mvarEPGEntriesSortedByMHWProgramIdent:=Tlist.Create;
    mvarSortedEventsByUniqueID:=0;
    mvarSortedEvents:=0;
    mvarReceivedEvents:=0;
    mvarAllCh
...
...
(Not finished, please download and read the complete file)
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
About.rtf20.49 kB2005-03-15|17:16
changelog.txt4.26 kB2005-03-15|17:16
clean.bat92.00 B2005-01-05|02:35
DVBCore.pas31.98 kB2004-12-17|23:45
frmPPVInfo.dfm15.69 kB2004-12-19|19:54
frmPPVInfo.pas6.17 kB2005-03-03|01:02
01.96 kB
About.bmp3.05 kB2004-12-17|23:52
About.ico2.40 kB2004-12-17|23:52
Add.bmp1.30 kB2004-12-17|23:52
bluenote.ico7.23 kB2004-12-17|23:52
bug.jpg6.04 kB2005-01-05|02:35
CAM.ico2.40 kB2004-12-17|23:52
Close.bmp3.05 kB2004-12-17|23:52
EPG.bmp1.05 kB2005-01-05|21:10
EPG.ico1.37 kB2004-12-17|23:52
EPGOFF.bmp1.62 kB2004-12-17|23:52
EPGON.bmp1.62 kB2004-12-17|23:52
EPG_Gliph.bmp3.43 kB2004-12-17|23:52
Event.ico1.37 kB2004-12-17|23:52
jetons.ico1.37 kB2004-12-17|23:52
leftLogo.bmp9.96 kB2004-12-17|23:52
logger.ico1.68 kB2004-12-17|23:52
MagicWand.bmp1.30 kB2004-12-17|23:52
MagicWand.ico1.37 kB2004-12-17|23:52
MAS.ico1.37 kB2004-12-17|23:52
MENOS.ico1.37 kB2004-12-17|23:52
nemesis.ico4.19 kB2004-12-17|23:52
Phoenix.ico1.72 kB2004-12-17|23:52
Provider.ico1.37 kB2004-12-17|23:52
Remove.bmp1.30 kB2004-12-17|23:52
Reset.bmp3.05 kB2004-12-17|23:52
Restart.bmp1.30 kB2004-12-17|23:52
Save.bmp2.05 kB2004-12-17|23:52
scriptengine.ico7.23 kB2004-12-17|23:52
ScriptsEngine.bmp6.80 kB2004-12-17|23:52
Tools.bmp246.00 B2004-12-17|23:52
tuxprogramming.jpg4.15 kB2005-01-13|19:01
V9Card.jpg11.00 kB2005-03-03|01:02
IFSI_IniFiles.pas10.45 kB2004-12-19|19:54
MpgLib.DLL141.50 kB2004-12-24|17:03
PMCAM0.00 B2005-03-15|17:18
PMCAM4.67 kB2005-01-05|17:24
PMCAM4.69 kB2005-01-05|17:24
PMCAM4.52 kB2005-01-05|17:24
PMCAM.rc3.60 kB2004-12-17|23:47
PMCAM2.dpr6.30 kB2005-03-11|20:15
PMCAM2.res1.70 kB2005-03-15|17:16
PMCAM2StandAlone.dpr1.19 kB2005-03-03|01:02
PMCAM2StandAlone.res4.95 kB2005-03-11|20:15
PMCAMMenu.rc259.00 B2004-12-26|20:10
PMCAMMenu.RES162.25 kB2005-03-15|17:16
rUPClickSplitter.res740.00 B2004-12-19|19:54
santa_rock.jpg5.65 kB2004-12-24|17:59
UBitManager.pas4.18 kB2004-12-17|23:45
uDecode123.pas4.01 kB2004-12-29|01:33
UDVBConditionalAccessSystemNames.pas1.49 kB2004-12-17|23:45
UDVBCoreToMD.pas4.59 kB2004-12-17|23:45
UDVBPIDNames.pas1.23 kB2004-12-17|23:45
UDVBTablesHolder.pas2.68 kB2004-12-28|02:17
UEPGEntry.pas3.29 kB2004-12-17|23:45
UEPGMHW.dfm7.72 kB2005-01-11|02:38
UEPGMHW.pas40.85 kB2005-01-11|02:38
UfrmAddFilter.dfm6.86 kB2004-12-17|23:46
UfrmAddFilter.pas3.68 kB2004-12-17|23:45
UfrmCAM.dfm217.00 kB2005-03-15|03:22
UfrmCAM.pas159.37 kB2005-03-15|17:16
ufrmDLLForm.dfm420.00 B2004-12-19|19:54
ufrmDLLForm.pas1.87 kB2004-12-26|20:10
UfrmEMM.dfm1.28 kB2004-12-17|23:46
UfrmEMM.pas1.47 kB2004-12-17|23:45
UfrmEPGAdvanced.dfm7.01 kB2005-01-05|21:10
UfrmEPGAdvanced.pas2.56 kB2005-01-05|21:10
UfrmMHWEPGEntries.dfm3.81 kB2004-12-17|23:46
UfrmMHWEPGEntries.pas4.33 kB2004-12-17|23:45
ufrmMHWRadio.dfm35.85 kB2005-01-21|18:53
ufrmMHWRadio.pas37.84 kB2005-01-21|18:53
UfrmPMTDetails.dfm2.31 kB2005-01-21|18:53
UfrmPMTDetails.pas2.74 kB2005-01-21|18:53
UfrmWarningOnExit.dfm15.64 kB2005-01-05|21:10
UfrmWarningOnExit.pas1.44 kB2005-01-05|21:10
ULogEngine.pas15.89 kB2005-03-12|17:11
UMDDefs.pas4.07 kB2005-03-03|01:02
UMD_Impl.pas11.26 kB2005-03-03|01:02
United32.pas14.20 kB2004-12-17|23:45
UnitISO639_3.pas10.04 kB2005-03-03|01:02
UnitMDInterface.pas28.92 kB2005-03-15|03:22
UnitTimer.pas1.39 kB2004-12-17|23:45
Unit_CRC32.pas3.62 kB2004-12-17|23:45
uPESToTS.pas6.11 kB2005-03-03|01:02
UScriptFunctions.pas2.97 kB2005-01-03|16:45
UScriptsEditor.dfm58.10 kB2005-01-21|18:53
UScriptsEditor.pas22.02 kB2005-03-03|01:02
USECAManager.pas18.26 kB2005-03-03|01:02
USECATableStore.pas12.92 kB2004-12-17|23:45
USECA_EMM.pas7.74 kB2005-03-12|03:36
USmartCardISO.pas14.45 kB2004-12-17|23:45
UTfrmMultiDec.dfm407.00 B2005-01-21|18:53
UTfrmMultiDec.pas4.38 kB2005-01-21|18:53
UTranslate.pas6.49 kB2004-12-24|17:03
UTS184ToBitFilter.pas36.28 kB2005-03-11|20:15
uUPClickSplitter.dcr488.00 B2004-12-19|19:54
uUPClickSplitter.dcu18.09 kB2005-03-03|01:02
uUPClickSplitter.pas20.43 kB2004-12-26|20:10
PMCAM2_2.50.zip870.87 kB2016-03-19|22:08
...
Sponsored links

UEPGMHW.pas (1.30 MB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D