You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by chihi asma <ch...@yahoo.fr> on 2009/04/11 22:50:54 UTC

Re : Re : Problem with upnp examples

Hi Francesco,

Thanks a  lot, I'll try this and I will tell you.




________________________________
De : "francesco.furfari@isti.cnr.it" <fr...@isti.cnr.it>
À : "users@felix.apache.org" <us...@felix.apache.org>
Cc : francesco.furfari@isti.cnr.it
Envoyé le : Samedi, 11 Avril 2009, 17h45mn 54s
Objet : Re: Re : Problem with upnp examples

Hi Asma, Sana

I fixed the bug by changing the type used by the clock to a DateTime
type. Update and rebuild the TV and clock device to test them.

FYI, 1) I changed the types used by the UPnPStateVariable of the clock

*TimeStateVariable*, line 46;

public Class getJavaDataType() {

return Date.class; // before Long.class

}

public String getUPnPDataType() {

return TYPE_DATETIME; // before TYPE_TIME

}

2) The right Date value is fired now by the clock

*ClockDevice* line 143;

-- old version ---

public void update() {

  Clock clock = Clock.getInstance();
  Calendar cal = clock.getCalendar();
  long time = cal.getTime().getTime();
  UPnPStateVariable variable = timerService.getStateVariable("Time");
    notifier.propertyChange(
      new PropertyChangeEvent(variable,
      "Time",
      new Long(time-1000),
      new long(time)));
}



-- new version --

public void update() {

Clock clock = Clock.getInstance();
Calendar cal = clock.getCalendar();
Date date = cal.getTime();
UPnPStateVariable variable = timerService.getStateVariable("Time");
notifier.propertyChange(
    new PropertyChangeEvent(variable,"Time",null,date));
}

3) finally, the TV is refreshed by using directly a Date .

*TvDevice*, line 263

public void notifyUPnPEvent(

    String deviceId,String serviceId, Dictionary events) {
    ....
    if (deviceId.indexOf("Clock") != -1){
      Date date = (Date) events.get("Time");
      clockTime = date.toString();
    }
...



The converter was ok. In the UPnP OSgi Spec. the time is mapped to a
long, and the DateTime to a Date.

BRs,
francesco





On 4/10/2009, "sana" <sa...@gmail.com> wrote:

> 4810 FETCH (BODY[1.1] NI

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


      

Re: Re : Re : Problem with upnp examples

Posted by sana <sa...@gmail.com>.
thanks a lot :)

2009/4/11 chihi asma <ch...@yahoo.fr>

> Hi Francesco,
>
> Thanks a  lot, I'll try this and I will tell you.
>
>
>
>
> ________________________________
> De : "francesco.furfari@isti.cnr.it" <fr...@isti.cnr.it>
> À : "users@felix.apache.org" <us...@felix.apache.org>
> Cc : francesco.furfari@isti.cnr.it
> Envoyé le : Samedi, 11 Avril 2009, 17h45mn 54s
> Objet : Re: Re : Problem with upnp examples
>
> Hi Asma, Sana
>
> I fixed the bug by changing the type used by the clock to a DateTime
> type. Update and rebuild the TV and clock device to test them.
>
> FYI, 1) I changed the types used by the UPnPStateVariable of the clock
>
> *TimeStateVariable*, line 46;
>
> public Class getJavaDataType() {
>
> return Date.class; // before Long.class
>
> }
>
> public String getUPnPDataType() {
>
> return TYPE_DATETIME; // before TYPE_TIME
>
> }
>
> 2) The right Date value is fired now by the clock
>
> *ClockDevice* line 143;
>
> -- old version ---
>
> public void update() {
>
>   Clock clock = Clock.getInstance();
>   Calendar cal = clock.getCalendar();
>   long time = cal.getTime().getTime();
>   UPnPStateVariable variable = timerService.getStateVariable("Time");
>     notifier.propertyChange(
>       new PropertyChangeEvent(variable,
>       "Time",
>       new Long(time-1000),
>       new long(time)));
> }
>
>
>
> -- new version --
>
> public void update() {
>
> Clock clock = Clock.getInstance();
> Calendar cal = clock.getCalendar();
> Date date = cal.getTime();
> UPnPStateVariable variable = timerService.getStateVariable("Time");
> notifier.propertyChange(
>     new PropertyChangeEvent(variable,"Time",null,date));
> }
>
> 3) finally, the TV is refreshed by using directly a Date .
>
> *TvDevice*, line 263
>
> public void notifyUPnPEvent(
>
>     String deviceId,String serviceId, Dictionary events) {
>     ....
>     if (deviceId.indexOf("Clock") != -1){
>       Date date = (Date) events.get("Time");
>       clockTime = date.toString();
>     }
> ...
>
>
>
> The converter was ok. In the UPnP OSgi Spec. the time is mapped to a
> long, and the DateTime to a Date.
>
> BRs,
> francesco
>
>
>
>
>
> On 4/10/2009, "sana" <sa...@gmail.com> wrote:
>
> > 4810 FETCH (BODY[1.1] NI
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>
>
>