Jump to content

COM EPGManager.Get() TTime 00:00:00 missing


majstang

Recommended Posts

Hello,

Sorry for all these reports of mine, but the issues Im encountering keeps coming up while testing for a DVBV thumbnailed app.

This time it seem to be something problematic with the parser that, I suppose, is used for fetching all EPG data when getting the

EPGManager.GetAsArray. The parser fails to retrieve starttime for all shows when start is at 00:00:00. In these cases its only the 

date which is retrieved. This of course affects all other EPG data fetching such as EPGManager.Get now and next show data. 

A few recent samples: 

 

Quote

---------------------------

Channel: SVT1 HD
---------------------------
EPGChannelID: 66983902
EventID: 1252458496
Time: 2017-05-07  
Duration: 02:30:00
Event:
Title: World Trade Center
Description: Den 11 september 2001 utsätts tvillingtornen World Trade Center för ett terrorattentat. Poliserna John och William hjälper till vid evakueringen. Men när de befinner sig i den femte byggnaden rasar ett av tornen och de blir fastklämda i rasmassorna
Skådespelare: Nicolas Cage, Maria Bello, Maggie Gyllenhaal, Michael Peña, Jay Hernandez, Danny Nucci, Michael Shannon, Dorothy Lyman, Peter McRobbie, Wass Stevens
Genre: Drama/Dramadokumentär/film Från: 2006

CharSetList:
Content: 0

 

---------------------------

ANOTHER ENTRY
---------------------------
EPGChannelID: 394576
EventID: 1252458976
Time: 2017-05-07 00:15:00
Duration: 01:30:00
Event:
Title: Source code
Description: Amerikansk-fransk science fiction från 2011. Militärpiloten Colter Stevens vaknar upp i en annan mans kropp på ett pendeltåg på väg mot centrala Chicago. Mitt emot honom sitter en kvinna han aldrig tidigare sett. Hon hävdar att de känner varandra. Några minuter senare sprängs tåget. , Skådespelare: Vera Farmiga, Jeffrey Wright, Russell Peters, Jake Gyllenhaal, Michelle Monaghan
Regissör: Duncan Jones
Skådespelare: Vera Farmiga, Jeffrey Wright, Russell Peters, Jake Gyllenhaal, Michelle Monaghan
Från: 2011

CharSetList:
Content: 0

 

 

Edited by majstang
Link to comment

hi,

 

its true, its a bug.

in greenbuttonexex i solved it this way:

 

if rend = ""then
rend = "00:00"
endif
if rstart = ""then
rstart = "00:00"
endif

 

regards,

marc

 

ps. i love your reports, go on :)

 

Edited by Marc32
Link to comment

Hello Marc!

 

Hadnt even started contemplating some sort of error handling, but there it is...served on a sliver plate:D That is what Im calling quality service:thumbsup:

Thanks:)

Edited by majstang
Link to comment
6 hours ago, majstang said:

This time it seem to be something problematic with the parser that, I suppose, is used for fetching all EPG data when getting the

EPGManager.GetAsArray. The parser fails to retrieve starttime for all shows when start is at 00:00:00. In these cases its only the 

date which is retrieved.

 

Can't spot it. Try to describe it more precisely. Which start is 00:00:00? With which parameters do you call GetAsArray?

 

There is no parser involved. It's quite straight forward, similar to a database GetTable request (but no SQLite in this case), and the resulting table ist directly transferred to the output VarArray. There is no code that conditionally truncates TDateTime values to the (integer) date part.

 

I don't know how VarArray works in Delphi and how different data types are handled. The only thing I can imagine is that the (floating point) TDateTime value is converted to an integer for some reason.

 

Link to comment

das problem ist uralt, griga. alles, was um 00 (aka 24.00) anfängt, interpretiert der viewer so wie von majstang beschrieben, nämlich gar nicht. die rs api hat das problem übrigens nicht. 

 

sry for talking german, majstang. german is my mother and its early in the morning

 

 

Link to comment

I don't understand what you mean. If there was a global problem with 00:00:00 the whole EPG output in the UI would be affected. But obviously it isn't:

 

Zwischenablage01.png

 

Internally the EPG start time and duration are stored  as TDateTime values (which are floating point values with the date being the integer part and the time the fractional part), and they are assigned as such to the VarArray. The start time includes the date. So the input to the VarArray is clearly a floating point (double) value, and that's what you should get as output. However, if the time is 00:00:00 the start time has no fractional part. Maybe this causes an interpretation as integer on assignment, that also affects subsequent values, dunno... I'm not familiar with the OleVariant stuff, as already mentioned.

 

Link to comment
2 hours ago, Griga said:

However, if the time is 00:00:00 the start time has no fractional part. Maybe this causes an interpretation as integer on assignment, that also affects subsequent values, dunno...

Maybe DVBViewer uses some error handling for this case globally? Since when looking at UI EPG (the picture you posted above) and the channel switch menu tooltips they all handle it fine. Also notice the UI samples are truncated from original time format 00:00:00 to 00:00, so there must be some handling somewhere. As Marc32 suggested I applied the same kind of handling, as he did in his greenbuttonexex, to make my channel switch menu tooltips handle when TTime returning Null. Yeah im using 20 for null...not liking RegEx very much:blush:

      If (Item <> ThisItem) {
         st := SystemTime.Now()
         DllCall("oleaut32\SystemTimeToVariantTime", "Ptr", st.p, "Double*", oleSt)
         ;iDVBViewer := ComObjActive("DVBViewerServer.DVBViewer")
         ;ChannelNR := iDVBViewer.channelmanager(channelnumber).GetbyChannelname
         ;channelnumber := 0 ; number of your wanted channel
         epgcid := iDVBViewer.channelmanager(Item -1).EPGChannelID
         SuD := iDVBViewer.channelmanager.GetByEPGChannelID(epgcid).tuner.SID
         TuD := iDVBViewer.channelmanager.GetByEPGChannelID(epgcid).tuner.TransportStreamID
         epgnow := iDVBViewer.epgmanager.Get(SuD,TuD,oleSt,oleSt).item(0).Title
         epgnext := iDVBViewer.epgmanager.Get(SuD,TuD,oleSt,0).item(1).Title
         starttime := iDVBViewer.epgmanager.Get(SuD,TuD,oleSt,oleSt).item(0).Time
         endtime := iDVBViewer.epgmanager.Get(SuD,TuD,oleSt,0).item(0).Endtime
         ;duration := iDVBViewer.epgmanager.Get(SuD,TuD,oleSt,oleSt).item(0).Duration
         ;showinfo := iDVBViewer.epgmanager.Get(SuD,TuD,oleSt,oleSt).item(0).Description
         ;msgbox % starttime . "  " . epgnow . "`n" . endtime "  " epgnext " "
         ;msgbox % duration "`n" showinfo
         EPGNow_Time := SubStr(starttime, InStr(starttime, " ") + 1, InStr(starttime, ":") - InStr(starttime, " ") + 2)
         EPGNext_Time := SubStr(endtime, InStr(endtime, " ") + 1, InStr(endtime, ":") - InStr(endtime, " ") + 2)
         ;---ERROR handling for shows starting at midnight when 00:00:00 time is missing------
         If ((EPGNow_Time = 20) && (epgnow <> ""))
           EPGNow_Time := "00:00"
         Else If ((EPGNext_Time = 20) && (epgnext <> ""))
           EPGNext_Time := "00:00"
         ;---------------------------------------------------------------------------------
         ;---ERROR handling for when no broadcasts are aired (often at nights) = time and title is missing------
         If ((EPGNow_Time <> "") && (epgnow <> "")) {
         ;------------------------------------------------------------------------------------------------------
         NowAndNext := EPGNow_Time . "  " . epgnow . " `n " . EPGNext_Time "  " epgnext " "	  
         Sleep, 200 ; Delay tooltip pop-up 200 milliseconds
         ToolTipEx(" " NowAndNext " ", , , , , "Black", "White") ;ToolTip, The mouse cursor is on item %Item%
         }
         Else
          ToolTipEx("") ;ToolTip
     }

Background info http://www.DVBViewer.tv/forum/topic/59819-com-epgmanagerepgnow-and-epgnext/?do=findComment&comment=462359

 

2 hours ago, Griga said:

I'm not familiar with the OleVariant stuff, as already mentioned.

Well, as long as we are abled to handle it...it is a no-problem. I might do some investigation on this topic :bye:

 

Edited by majstang
Link to comment
4 hours ago, Griga said:

There is no parser involved. It's quite straight forward, similar to a database GetTable request (but no SQLite in this case), and the resulting table ist directly transferred to the output VarArray. There is no code that conditionally truncates TDateTime values to the (integer) date part.

 

I dont think its an OleVariant problem. Its more likely related to when inserting the TTime into the database Table if it is 00:00:00. The net is littered with error reports describing this problem (and also solutions implying conversion of some sort), especially for folks using SQLite. 

Edited by majstang
Link to comment
2 hours ago, majstang said:

Maybe DVBViewer uses some error handling for this case globally? 

 

No. Why should it?

 

1 hour ago, majstang said:

Its more likely related to when inserting the TTime into the database Table if it is 00:00:00.

 

There is a simple EPG BCD time format -> TDateTime conversion without any if.. then. From this point on the resulting TDateTime value remains untouched.

 

We are not using SQlite for storing the received EPG data. We have to handle EPG input with up to 5 MBit/s. That's why we are using our own stuff that is optimized for speed.

 

2 hours ago, majstang said:

Also notice the UI samples are truncated from original time format 00:00:00 to 00:00, so there must be some handling somewhere.

 

It's just a TDateTime -> String conversion using FormatDateTime from the Delphi runtime library. Your assumptions about what is going on inside DVBViewer are definitely off the mark.

 

Where is the GetAsArray in your Code? Ends don't meet here.

Link to comment
48 minutes ago, Griga said:

Your assumptions about what is going on inside DVBViewer are definitely off the mark.

As it should be since its closed source which makes it a guessing game;) Also Im no programmer and cant therefor communicate or understand the right terms fully:blush:

48 minutes ago, Griga said:

Where is the GetAsArray in your Code? Ends don't meet here.

Hmm..if necessarily nitpicking is needed, yes, correctly spotted Im not using the GetAsArray in that code snippet. In fact I havent found use of enumerating the GetAsArray as of yet, but Im sure it will come up later. http://www.DVBViewer.tv/forum/topic/59821-get-com-arrays/ 

However EPGManager.GetAsArray(0,0,0,vref) and EPGManager.Get() both obviously gets the info from the same source (and the problem is mutual as stated in TS post). I will change the title of this topic:)

Edited by majstang
Link to comment
3 hours ago, majstang said:

starttime := iDVBViewer.epgmanager.Get(SuD,TuD,oleSt,oleSt).item(0).Time

 

Here DVBViewer returns a floating point TDateTime value:

function TEPGItem.Get_Time: TDateTime;
begin
  result := 0;
  if assigned(FEPG) then
    result := FEPG.Time;
end;

But some lines later it is obviously handled as string in your code:

 

3 hours ago, majstang said:

EPGNow_Time := SubStr(starttime, InStr(starttime, " ") + 1, InStr(starttime, ":") - InStr(starttime, " ") + 2)

 

which means there are implicite conversions happening in between. I'm pretty sure that's the source of the problem. There is nothing I can do about it in the DVBViewer code.

Link to comment

Sorry Griga, I dont exactly follow how you mean:blush: FYI both Marc32 and I get the same result with VBScript. For what its worth, Im quite possitive the error lies within DVBV code.

Quote

starttime := iDVBViewer.epgmanager.Get(SuD,TuD,oleSt,oleSt).item(0).Time

This COM call definitely returns a readable string (integer). How do you mean the function is returning a floating point (double) to starttime var? It would be completely unreadable and useless for most COM users if being forced to convert the floating point (double) back to integer before its usable information. The inputted oleSt value on the other hand is a floating point (double) passed to the DVBViewer Function. Then the exact steps for the function to access the database Table to Get the TDateTime, then convert it to integer and return it I have no idea. My two cents on..it goes wrong somewhere in that chain when TDateTime contains 00:00:00. 

 

5 hours ago, Griga said:

But some lines later it is obviously handled as string in your code:

Since starttime is a string I can act upon it with different stringmanaging methods, so Im retrieving HH:MM from the specified position in the string. No conversion going on. This works excellent as long as startime is anything else than yyyy-MM-dd 00:00:00. When startime is null (the error) the string retrieved is 20 (the two first digits of the year 2017), but that is just lazyness from my end not finding a way yet to handle when the search stringposition is empty. So I would say I disagree with my coding is the source of error here, especially when the same error can be reproduced with VBScript, which natively handles the TDateTime format.

 

 

Edited by majstang
Link to comment
2 hours ago, majstang said:

This COM call definitely returns a readable string (integer).

 

But the Delphi function result is no string, but the binary representation of a floating point value. So there must be some implicite conversion in between.

 

Usually script programmers are not aware of the data types and their internal representation, because the scripting engine does a lot in the background that you don't see. For you a variable is just a container that can hold any type, and if you access an integer or floating point value as string it is automatically converted to the target type.

 

However, with Delphi as a compiler language it's completely different. Delphi programmers have to be *very* aware of the data type. Every variable has to be declared with a certain type.

 

var

  DateTime: TDateTime;

  StringVar: String;

 

and the compiler does not allow to access TDateTime as a string, e.g. StringVar := DateTime is forbidden. 90% of what you are doing in your script is "evil" from the Delphi point of view and would cause an error message at compile time. In Delphi you have to explicitely call a function that converts DateTime to String, e.g.

 

StringVar := DateTimeToStr(DateTime);

 

The EPG TDateTime values exposed by the COM interface are never converted to or processed as string in DVBViewer, unless it comes to displaying them in the UI.

 

Link to comment

Ok, Im starting to get this! Thank you for the VERY explicit explanation:) Im surprised VBScript does the same implicite conversion, but not when AHK does it cuz it has been a pain in the neck dealing with COM all the way. Im not sure if its worth the effort to dig deeper into this in order to find a solution (I guess that will be about handling Raw Values), my handling dealing with this issue is easy and it works 100%.

Best regards:bye:

majstang   

Edited by majstang
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...