Results 1 to 10 of 10

Thread: UPS make my program get a problem.

  1. #1

    Thread Starter
    Hyperactive Member solar115's Avatar
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    268

    UPS make my program get a problem.

    I use some computer that connect to UPS. Some time when electric problem occurs it will make UPS work. OK that UPS can make a backup electrical for my PC but sometime like the time that UPS is low battery it will try to shutdown my PC before battery is empty. That is a problem , it shutdown in a time that my program still running. It's make my program get some problem and relate to database (I mean my database will not be used after this problem). So I think if UPS can shutdown my PC, it maybe use the way that send some command to my PC to shutdown. However that is my problem that I don't know more than this. My I ask you like this.

    1. How that UPS connect to PC? (I see some communication line on this case but I don't know more.)
    2. How can I try to break the shutdown process and save all of my data and then shutdhown it with my program? (Sure that my program is developed by VB.)

    All of this solution for make sure that it's a good result for my computer and for my program (shutdown befor no electrical but shutdown after all data is save).

    I will try to look this post in most time for discuss everything with you.
    ^solaris^

  2. #2
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    UPS dosn't send any command that I'm aware of. It is there
    to maintain power to the PC in the event of mains power failure.

    If the battery in the UPS is low, then there is a problem with the UPS.



    Bruce.

  3. #3

    Thread Starter
    Hyperactive Member solar115's Avatar
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    268
    I understand your opinion but this something I want to tell you.

    1. I think it about Model of UPS. Some model is used for electrical support only but some model have a communication port or LAN that use for connect to PC that do something.
    2. At least 2 things that I see UPS can do. One is send UPS status to PC for showing in monitor. Other one is shutdown computer. I havebeen see the shutdown process with UPS.
    ^solaris^

  4. #4
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    Actually most UPS's connect to a machine via a serial cable. When the power goes out, or there is a surge, a message is sent via the cable to the computer. It is determined how long the computer can survive on the UPS and it will usually initiate a shutdown sequence in order to save data.

    The way I see it Solar there are two things you can try, the first is hard and the second is fairly simple:

    1. What you can try and do Solar is listen to the com port via your program. You will probably have to do some trial and error to see what commands you get from the UPS device.

    2. You can use the QueryUnload event to see if it is a system shutdown causing your program to quit:

    Code:
       Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    ' System is shutting down
       If UnloadMode >= 2 Then
          'Do whatever you need to do to save your DB.
       End If
    
    End Sub

  5. #5

    Thread Starter
    Hyperactive Member solar115's Avatar
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    268
    May I ask you more from your suggestion one by one.

    1. "listen to the com port ". Can you explain me more that how? May you give me some code.
    2. "Form_QueryUnload". You mean that all thing I try in this Sub will be done if computer try to shutdown, Right? And after all process in this sub done so computer will be continue shutdhown, Right? And computer will be not shut down if all command in this Sub is not finished, Right?
    ^solaris^

  6. #6
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Originally posted by Bruce Fox
    UPS dosn't send any command that I'm aware of.
    My appologies solar115, I have since learned that they do connect to the PC (as Negative0 has also mentioned).


    Bruce.

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Originally posted by solar115
    [B]May I ask you more from your suggestion one by one.

    1. "listen to the com port ". Can you explain me more that how? May you give me some code.
    this is a nightmare to work with - don't even try it.


    2. "Form_QueryUnload". You mean that all thing I try in this Sub will be done if computer try to shutdown, Right? And after all process in this sub done so computer will be continue shutdhown, Right? And computer will be not shut down if all command in this Sub is not finished, Right?
    Basically yes, but the computer will only give your program a certain amount of time to finish.

    I think the default is 10 to 15 seconds, but this can be changed on the pc (I can't remember how).

  8. #8
    Hyperactive Member
    Join Date
    Apr 2001
    Location
    N42 29.340 W71 53.215
    Posts
    422

    Do you want the UPS to control your PC?

    I have a UPS, but I never installed the s/w that came with it or the serial cable to the PC.
    It's used ONLY for the batteries and whatever line filtering it provides.

    This PC essentially never runs unattended, i.e. it's not a blackbox server running in a closet somewhere, so when the power goes out someone knows and hears the UPS beeping so a controlled, manual shutdown can be done.

    So, if you don't want the s/w overhead, or questions about any strange program interactions or undesired "HAL" type control of your PC, then uninstall any software that came with the UPS and disconnect the control cable. (just my opinion)

    Have fun, DaveBo
    "The wise man doesn't know all the answers, but he knows where to find them."
    VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15

  9. #9

    Thread Starter
    Hyperactive Member solar115's Avatar
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    268
    DaveBo, I think your opinion is OK but may not match with my concept. Cause that my project is something like ATM (but my project is not relate to money ). That it still running without somebody to monitor it. If user come to use in a time that it shutdown by UPS the error is effect to user too (and some data in my program will be error.)
    ^solaris^

  10. #10
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385
    solar115

    The whole point of the UPS and the UPS software is to keep your computer running long enough for you to shut it down gracefully before it has to do it forcablily.

    If the electricity goes off. It is only a matter of time before the computer will stop running anyway. It is up to the program to know this. The OS (if equiped) will notify the programs by attempting to shut them down.

    This is your programs responsibility at this time to exit gracefully. If not it will be shut down soon anyway. Either abuptly by having no power or gently by issuing a shutdown command to all programs and the program saving their data and run states.

    You only have two options... I suggest your program should shut itself down to avoid data corruption possibilities.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width