RE: SDL-News: Operator I defined can't be converted to C


Subject: RE: SDL-News: Operator I defined can't be converted to C
From: Scott Shen (Scott.Shen#holleycomm.com)
Date: Thu Feb 20 2003 - 18:19:28 GMT


Hi Yang:

It looks like you are working on 802.11 or something like that :)

If you doing what I am thinking, here is my comment:

SDL time and timer is very different from the "tick" based timer system used
in embedded systems. In SDL, the time and duration are generally in real
number in units of second, but in embedded system the time and duration are
usually calculated in "ticks" and one tick can be 10ms or 10us, etc. That
is, when you calculate the time or duration in your embedded system you are
actually using integers to count the number of ticks, not SDL time/duration;
and the tick based calculation is really what will happen in your target
system. However, in order to make your design compatible with SDL when you,
for example, SET a timer, you need to translate ticks into SDL
time/duration. The translation is quite simple, you can create a procedure
like this:

Synonym TIMER_TICKS_DURATION Real = 0.01; /* 10ms tick */

fPar
IN num_of_ticks Natural;
RETURNS SDL_duration Duration;
dcl d Duration := 1.0;

SDL_duration := (float (num_of_ticks)*TIMER_TICKS_DURATION) * d

Once your tick is translated into time/duration you can use the results with
SDL timers.

I am not familiar with Tau's code generation though.

Regards,
Scott

-----Original Message-----
From: Yang LIU [mailto:lyly97#mails.tsinghua.edu.cn]
Sent: February 19, 2003 10:05 PM
To: sdlnews#sdl-forum.org
Subject: SDL-news: Operator I defined can't be converted to C

Become an SDL Forum Society member
<http://www.sdl-forum.org/Society/members.htm>
The originator of this message is responsible for its content.
-----From "Yang LIU" <lyly97#mails.tsinghua.edu.cn> to sdlnews -----

I am using Telelogic tau suite 4.3, now I have a problem:
I define a NewType and Operator in SDl like this:

newtype Usec inherits Integer operators all;
  adding operators
    dUsec : Usec -> Duration;
  axioms
    for all u in Usec (for all d in Duration( for all r in Real(
     r = float(u) ==> dUsec(u) == Duration!(r); )));
  endnewtype Usec;

But in generated C file, there have no C code for function dUsec,
my question is :
Is axioms useless in telelogic SDL?
how generate C code of Operator dUsec?

--End text from "Yang LIU" <lyly97#mails.tsinghua.edu.cn> to sdlnews ---
For extra SDL Forum Society benefits join at
<http://www.sdl-forum.org/Society/members.htm>
or (iff this does not answer your question) email:
owner-sdlnews#sdl-forum.org

RE: SDL-News: Operator I defined can't be converted to C

Hi Yang:

It looks like you are working on 802.11 or something like that  :)

If you doing what I am thinking, here is my comment:

SDL time and timer is very different from the "tick" based timer system used in embedded systems. In SDL, the time and duration are generally in real number in units of second, but in embedded system the time and duration are usually calculated in "ticks" and one tick can be 10ms or 10us, etc. That is, when you calculate the time or duration in your embedded system you are actually using integers to count the number of ticks, not SDL time/duration; and the tick based calculation is really what will happen in your target system. However, in order to make your design compatible with SDL when you, for example, SET a timer, you need to translate ticks into SDL time/duration. The translation is quite simple, you can create a procedure like this:

Synonym TIMER_TICKS_DURATION Real = 0.01;  /* 10ms tick  */

fPar
IN num_of_ticks Natural;
RETURNS SDL_duration Duration;
dcl d Duration := 1.0;

SDL_duration := (float (num_of_ticks)*TIMER_TICKS_DURATION) * d


Once your tick is translated into time/duration you can use the results with SDL timers.

I am not familiar with Tau's code generation though.

Regards,
Scott


-----Original Message-----
From: Yang LIU [mailto:lyly97#mails.tsinghua.edu.cn]
Sent: February 19, 2003 10:05 PM
To: sdlnews#sdl-forum.org
Subject: SDL-News: Operator I defined can't be converted to C


Become an SDL Forum Society member <http://www.sdl-forum.org/Society/members.htm>
The originator of this message is responsible for its content.
-----From "Yang LIU" <lyly97#mails.tsinghua.edu.cn> to sdlnews  -----

I am using Telelogic tau suite 4.3, now I have a problem:
I define a NewType and Operator in SDl like this:

newtype Usec   inherits Integer   operators all;
  adding  operators
    dUsec : Usec -> Duration;
  axioms
    for all u in Usec (for all d in Duration(    for all r in Real(
     r = float(u) ==> dUsec(u) == Duration!(r); )));
  endnewtype Usec;

But in generated C file, there have no C code for function dUsec,
my question is :
Is axioms useless in telelogic SDL?
how generate C code of Operator dUsec? 


--End text from "Yang LIU" <lyly97#mails.tsinghua.edu.cn> to sdlnews ---
For extra SDL Forum Society benefits join at <http://www.sdl-forum.org/Society/members.htm>
For help, email "majordomo#sdl-forum.org" with the body of your email as:
    help
or (iff this does not answer your question) email: owner-sdlnews#sdl-forum.org

--End text from Scott Shen to sdlnews --- For extra SDL Forum Society benefits join at



This archive was generated by hypermail 2a23 : Thu May 09 2013 - 16:05:49 GMT