Link to home
Start Free TrialLog in
Avatar of nestor0973
nestor0973

asked on

Monitor UPS status within delphi

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
Avatar of Emmanuel PASQUIER
Emmanuel PASQUIER
Flag of France image

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...
Avatar of nestor0973
nestor0973

ASKER

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.
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) ?
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
I think if there is a way that i can communicate with UPSAgent.exe that would work. I hope anyone has any idea
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
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 :(
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.
i-e what command can you send, in what format, and how to read the response given by the service.
I get 'Connection refused' on the HTTPClient.exe demo ..
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
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 ?
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 ?
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.
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
I have to follow epasquier in this..
so nestor, how do you do with TClientSocket & Documentation ?
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
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.
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?
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
ASKER CERTIFIED SOLUTION
Avatar of Emmanuel PASQUIER
Emmanuel PASQUIER
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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