Link to home
Start Free TrialLog in
Avatar of Deluxion
Deluxion

asked on

Automatic alarm

Hello All,

I want write a program which sounds an alarm at predefined times.
USER SHOULD BE ABLE TO:-
* enter start date and time (DateTimePicker) and end date time (DateTimePicker).
* select the sound file to play.
* enter the duration of the sound.
* select interval between each alarm.(SpinEdit)
* select dates on which the alarm should keep quiet.(should have a DateTimePicker to pick the dates)

Grateful if you could provide some sample codes.
Any Help Please..
Thanks
Avatar of robert_marquardt
robert_marquardt

This is not really a Delphi question.
The main task is to design a user interface for entering alarm times.

* enter start date and time (DateTimePicker) and end date time (DateTimePicker).
  This is silly. You want an alarm which is a time point not a duration.

* select the sound file to play.
  Needs a "preview" button to play the selected file.
* enter the duration of the sound.
  The duration is determined by the WAV file. Duration is therefore silly.
 
* select interval between each alarm.(SpinEdit)
  Here the user interface needs to be carefully designed.
  You want to enter two different task kinds. Single shot alarms and repeated alarms.
* select dates on which the alarm should keep quiet.(should have a DateTimePicker to pick the dates)
  This is a task list of its own.

You need at first two lists of tasks.
One for the alarms and one for the alarm suppression.
Each list can take either single shot elements or repeating elements.

From the alarm list the next outstanding alarm point is generated and waited for.

When firing the suppression list is asked if the alarm should play or not.
The sound is played or not.

Back to next outstanding alarm point.
Avatar of Deluxion

ASKER

I agree that this is not a Delphi specific question, however I am going to write this program in Delphi. (so that makes it delphi question, atleast for me :-)).

Anyways thanks for your comments robert.

Actually it should read "automatic bell" and not "automatic alarm".

Well it is kind of an automatic bell program that I am going to write, which, once you program it then it keeps sounding the bell whenever neccessary.

Thanks
any body has sample codes please....
I have some, but you need to be more specific.  Mine actaully is a scheuler.  What it does is launch an application at a specific time, or interval, that you specify.  It could be modified though to sound an alarm.  I will put some code in for you.  

/////////////////////////////////

unit
......

  public
    TimeToExecute  : String;
    DateToExecute  : String;

procedure TForm1.btnExecuteClick(Sender: TObject);
begin

 Timer1.Enabled := False;

 if CheckBox1.State = cbChecked then
  WaitOnProcess := True;
 if CheckBox1.State = cbUnChecked then
  WaitOnProcess := False;

  TimeToExecute := TimeToStr(dtpTime.Time);
  DateToExecute := DateToStr(dtpDate.Date);

  Timer1.Interval := 200;
  Timer1.Enabled := True;

end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
 if (TimeToExecute = TimeToStr(Time)) and
    (DateToExecute = DateToSTr(Date))
  then
   begin
    StartExecution;
   end;
end;

procedure TForm1.StartExecution;
var
 Count: Integer;
 CurrentExe: String;
begin
 try
  //Sound your alarm!!!!!!
  SysUtils.Beep; // Beep or call multimedia now!
  Label1.Caption := 'Last run status: Success';
 except
  MessageDlg('Internal Error: TForm1.StartExecution ' + #13#10 + 'Could not sound alarm!', mtError, [mbOK], 0);
 end;
end;
ASKER CERTIFIED SOLUTION
Avatar of krukmat
krukmat

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
krukmat, Thanks for your help, my email is deluxion@hotmail.com.
your help is appreciated :-)