how to convert real to string?

Discussion in 'General Discussion' started by Tim1212, May 3, 2010.

  1. Tim1212

    Tim1212

    Joined:
    Oct 30, 2009
    Messages:
    27
    Likes Received:
    0
    Location:
    Hong Kong
    i want to use real(temperature value) shown on wiser page is string value?

    many thanks..
     
    Tim1212, May 3, 2010
    #1
  2. Tim1212

    kjayakumar

    Joined:
    Oct 27, 2008
    Messages:
    448
    Likes Received:
    0
    Hi Tim,

    I read this post and your previous post on "Show Temperature on Wiser".

    What I recommend you do is as follows:
    - create a user system IO real widget using the PICED widget manager for your Wiser project
    - in logic, communicate with your temperature sensor (Is your temperature sensor a C-Bus HVAC device? Or something different? From what you wrote I'm not sure. If your device is TCP/IP or some other type of sensor then good, because Wiser can talk to TCP devices through Logic) and retrieve the temperature. Your code would look something like:

    OpenClientSocket(1, sensor_ip_address, sensor_port);
    timerstart(1);
    WaitUntil (ClientSocketConnected(1) or (TimerTime(1) = 600));
    timerstop(1);
    if ClientSocketConnected(1)then
    begin
    WriteClientSocket(1,'Hello Temperature Sensor. Tell me the temperature');
    ReadClientSocket(1,ClientString, #10);
    -- process your temperature result here

    - Naturally, if your temperature sensor supports C-Bus HVAC, then just use the the built-in function like GetRealIBSystemIO("HVAC Temperature", 1, HVACZoneU). As you can see the advantage of that is that you can even do it with just one line of logic like:
    SetRealSystemIO("hvac_real", GetRealIBSystemIO("HVAC Temperature", 1,
    HVACZone1));
    where hvac_real is your user system io real. And eat-voilins, its all done. :)

    - Be careful not to SetReal every cycle because that will waste your network bandwidth, especially if you're connected through 3G on a mobile device. Easy step would be to compare with the old value and only set if it has changed.

    - The above code is just for example, please don't use it without understanding what's going on and how it works and modifying it to be appropriate for your setup.
     
    kjayakumar, May 4, 2010
    #2
  3. Tim1212

    Tim1212

    Joined:
    Oct 30, 2009
    Messages:
    27
    Likes Received:
    0
    Location:
    Hong Kong
    We use the CBUS temperature sensor and need to show on the wiser page as (26 C....somthing like that). so, how can i show the status on wiser page as wanted format?

    thanks.
     
    Tim1212, May 4, 2010
    #3
  4. Tim1212

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    If you have a real number in a variable "t" and you want to get it into a string variable "s" with 1 decimal place, you can use logic code:

    Code:
    Format(s, t:0:1);
    To put this string into a user system IO variable so you can display it on Wiser:

    Code:
    SetStringSystemIO("My User Variable", s);
     
    Darren, May 4, 2010
    #4
  5. Tim1212

    kjayakumar

    Joined:
    Oct 27, 2008
    Messages:
    448
    Likes Received:
    0
    As Darren pointed out, you can use the Format function in conjunction with the GetRealIBSystemIO to get the temperature into exactly the form you want. Also, to make sure we've asked, did you consider just using the standard HVAC widget? That shows the temperature as well.
     
    kjayakumar, May 5, 2010
    #5
  6. Tim1212

    Tim1212

    Joined:
    Oct 30, 2009
    Messages:
    27
    Likes Received:
    0
    Location:
    Hong Kong
    Thanks all,

    Our situation is use two Daikin Split System and include the wire control box. i want to get status(on/off) of air cont. (other function uses IR to control)and just want to show the temperature on wiser. HVAC units of CBUS and wiser widget have many other non-function button(i don't want to show it).

    i pleased with you to advise any good idea in our situation.

    thanks again.
     
    Tim1212, May 7, 2010
    #6
  7. Tim1212

    kjayakumar

    Joined:
    Oct 27, 2008
    Messages:
    448
    Likes Received:
    0
    Oh, that paints a very different picture from your previous posts. Ok, I don't have any Daikin expertise so I don't know exactly how it works. Do you have a rs232 or a TCP/IP interface to it? How do you get Daikin (wire control box?) to tell you what the temperature is? If it is TCP/IP, then the good news is that you should be able to use Wiser to get the temperature without any additional hardware. If it is RS232 or something else, then you'll need to get an ethernet-serial converter. You'll then need to write Logic code to read/write commands/data to get the desired value (you'll need to know the protocol they're using to do that), then once you've gotten the actual number in your logic, you can use the SetReal stuff I pasted before to report it in a System IO real widget. I'm not sure you're up for that so it sounds like you'll need to get a more experienced integrator who is familiar with Logic in PICED, reading/writing TCP/IP sockets in Logic running on Wiser if you want to get it done in a timeframe that'll keep the end customer happy.

    I hope that helps.
     
    kjayakumar, May 8, 2010
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.