Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Monitor UPS status within delphi

Posted on 2009-12-17
24
Medium Priority
?
696 Views
Last Modified: 2013-12-11
Hi,

I'd like to monitor the status of a UPS that is connected with USB to a computer. It  should happen from within a program that is build in Delphi. I have found these components
http://www.abf-dev.com/abf-vcl/delphi-advanced-power-management.shtml
but i don't have any luck with this. Does anyone know if this is possible in some way ?

Thanx
0
Comment
Question by:nestor0973
23 Comments
 
LVL 25

Expert Comment

by:epasquier
ID: 26070677
I purchased the ABF suite myself a while ago, they are generally good enough. But I haven't tried the APM components. What is your problem with those ? I have an UPS that could be linked with COM port but never bothered, so eventually I could try. But I need to know more about what is your problem, which Delphi version do you use, what is your UPS etc...
0
 

Author Comment

by:nestor0973
ID: 26070713
Hi,

The bottomline is this : i have written a program that sends out SMS trough a gsm-modem in case of some events that occur in a database. I want to add the feature to send a SMS incase of a power -down. I know that the UPS itself has the possibility to send a SMS trought a gsm-modem but i can't connect to the same modem twice. The UPS is a Riello USC5.

I think if i could be able to add the UPS to the windows APM (in config ->powermanagement ->UPS) that i will be able to read the signal, and i think that is where the ABF component gets its data from. But so far i haven't been succesfull in adding the UPS to the APM mananger

I'm using Delphi 7 on a XP and Win7 machine.
0
 
LVL 25

Expert Comment

by:epasquier
ID: 26070774
Ok, so basically it's not a problem with ABF components but with interfacing the UPS with windows APM, right ?
What do you mean by you have not been successful in adding the UPS to the APM manager ? You could not install the drivers or the drivers did not register in the APM ? What have you done, what is different from before you did it ? do you have Riello tools that can read the informations ? What appears in the UPS tab of the Power Manager (XP) ?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:nestor0973
ID: 26070881
Well that's what i mean, i can't add the Reillo UPS to the UPS tab in the power manager of XP.  As far as i see i can only connect troug a COM port there there's no such port for my UPS.  The software that comes with the reillo itself works ok, but i need to be able to monitor from within my own program. And i'm pretty sure the ABF component just reads the value that is seen in the windows APM, meaning it doesn't directly connect with the UPS. On itself that shouldn't be a problem, if i could get the correct value i don't care how it comes in my program.
I hope this is clear enough
0
 

Author Comment

by:nestor0973
ID: 26071668
I think if there is a way that i can communicate with UPSAgent.exe that would work. I hope anyone has any idea
0
 
LVL 25

Expert Comment

by:epasquier
ID: 26072478
well, it's impossible to access directly to the device data via the USB port, so either there is a driver interfacing with windows APM or it is a proprietary solution. It would appear the first case is not working for you, so you have to dig a bit more in the documentation of your UPS, or calling Rellio technical support for a mean to get data from UPSAgent (if possible). I suppose this one is the software from Rellio that you setup
0
 

Author Comment

by:nestor0973
ID: 26072684
I have found that i should be able to connect to the UPSAgent trought TCP/IP on port 33000 or trough SNMP. But i don't see how i can do that . I know that Indy has both tcp as snmp components but no good examples of how to use them in this system. If i run a server on localhost is should be able to access it trough http://127.0.0.1:33000 ?? i can't get any way to connect to that port tcp 33000 :(
0
 
LVL 25

Expert Comment

by:epasquier
ID: 26072807
connecting to the TCP port is easy enough, I recommend for such client connection to use the good old TClientSocket component in Internet page to do that. If you don't see it in Delphi 7, it might be that you have to add the dclsockets70.bpl (Borland Sockets Components in packages list when installed)

What will be your problem is then what protocol you have to use to get the information you want.
0
 
LVL 25

Expert Comment

by:epasquier
ID: 26072814
i-e what command can you send, in what format, and how to read the response given by the service.
0
 

Author Comment

by:nestor0973
ID: 26073081
I get 'Connection refused' on the HTTPClient.exe demo ..
0
 
LVL 25

Expert Comment

by:epasquier
ID: 26073156
it's not HTTP, is plain old TCP/IP with a proprietary protocol
First put a TClientSocket in your form, then set its port to 33000 and Host = localhost
Then put active = True (or in your code, do ClientSocket.Open;

you can add in the onConnect event a ShowMessage('Connected');

it should work, but that's only a beginning since you'll have then to send the correct command and analyse the response in onRead event
0
 

Author Comment

by:nestor0973
ID: 26073513
Thanks allot for all the help but still i don't have any success.. I wrote a small app like you said , but i get a 'Asynchronous Socket Error 10061', possibily meaning that the server doesn't allow connections ? i just don't get it ! Don't i have to fill in the address property of the TclientSocket ?
0
 
LVL 25

Expert Comment

by:epasquier
ID: 26073731
the address is the Host parameter. By stating 'localhost' you are saying that you app is communicating with a port on the same computer. That's the same as putting an IP address='127.0.0.1'
Check your firewall also, open the 33000 port or completely disable while testing
If you can't connect, and you have both Host and Port set then it is that UPSAgent is either not running, or that it's not configured to let TCP/IP connection as documented.
Can you post your documentation or a link to it ?
0
 
LVL 2

Expert Comment

by:curtisla
ID: 26073925
Guys,

I have a sorta simple solution to the issue. If this works like it reads the problem is the USB port as a communications port. Would using the following device would allow you to get RS-232 connectivity. Please see link below:

http://www.usbgear.com/USBG-232MINI.html

I hope that this helps.
0
 
LVL 25

Expert Comment

by:epasquier
ID: 26073985
nope, this type of hardware is used for the opposite case : when you have an COM device that needs to be connected to a computer without COM Port.

There is no way to do the opposite (and god knows I have searched)
Putting the software and signal aside, it would require a female USB (or USB Host port) and a female COM
0
 

Author Comment

by:nestor0973
ID: 26074032
I have to follow epasquier in this..
0
 
LVL 25

Expert Comment

by:epasquier
ID: 26074052
so nestor, how do you do with TClientSocket & Documentation ?
0
 

Author Comment

by:nestor0973
ID: 26075318
Well i'm still struggling with it, i don't think it will be possible to do. I have contacted the suplier of the UPS and i'll wait for their answer and come back here
0
 
LVL 22

Expert Comment

by:8080_Diver
ID: 26075461
nestor0973,
I have been monitoring this discussion because I had thought of doing the same sort of thing with a UPS I have . . . but, since you took "point", I thought I'd see if you got shot before I ventured into the field. ;-)
Do keep us updated.
0
 
LVL 19

Expert Comment

by:MerijnB
ID: 26075652
Have you asked the manufacturer for details on the protocol?
Have you tried running the app which came with the UPS while running a tcp sniffer?
0
 
LVL 25

Expert Comment

by:epasquier
ID: 26076291
does this applies to your UPS ?
http://extranet.riello-ups.com/areaftp/Manuals/0MNU106NPB-GB%20%28Manuale%20software%20UPSmon%20GB%29.pdf

if so, you have to download and install UPSMON package (if not allready), and maybe then we can play a bit

Ah, I see that it is not exactly TCP/IP but UDP that is used, on port 33000 by default

another thing that could help :
in UPSMON.INI :
put DebugMode=3 for complete UDP packet decode
0
 
LVL 25

Accepted Solution

by:
epasquier earned 2000 total points
ID: 26076620
then you will have to see what's going between the UPSAgent and the client application
Thanks to the DebugMode and a sniffer,  it should be possible to compare decoded and raw data, in order to reverse engineering the protocol.
Sounds like a lot of fun !!

About the UDP communication, we've had a thread over it with MerjinB :
http://www.experts-exchange.com/Programming/Editors_IDEs/Delphi/Q_24944073.html?cid=1131#a25954666
to summerize, you'de better use 3rd party components instead of the poor delphi one.

You can either use a simple one that I upgraded for newer versions of Delphi :
https://filedb.experts-exchange.com/incoming/ee-stuff/7809-WSock.rar

Or the more advanced one that MerjinB proposed, and after consideration I prefer also :
http://www.overbyte.be/frame_index.html

This is a convenient Buffer unit I made specially to encode/decode conveniently protocol messages :
https://filedb.experts-exchange.com/incoming/ee-stuff/7818-TBuffer.rar

And last, here is a complete sample project to use all of this, opening a UDP connexion, send & receive packets
https://filedb.experts-exchange.com/incoming/ee-stuff/7820-TestUDP.rar

Have fun !!!
0
 

Author Comment

by:nestor0973
ID: 26078981
Epasquier, you're going to earn the points! :D  

I'm getting into this hoping that i'll get somewhere and i'll get back today.

thanx
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In the modern office, employees tend to move around the workplace a lot more freely. Conferences, collaborative groups, flexible seating and working from home require a new level of mobility. Technology has not only changed the behavior and the expe…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question