Ejemplo n.º 1
0
 private void StopAlarmSound()
 {
     Player.Stop();
     string totalk = "";
     object[] tomake = { totalk };
     this.Invoke(UpdatelblIdleTXT, tomake);
     AlarmOnOrOff=CurrentAlarmState.AlarmOff;
     ClientSideAlarmActivation = false;
 }
Ejemplo n.º 2
0
        private void PollInstrumentStatus()
        {
            try
            {
                while (PerformPolling)
                {
                    AlarmState AS = InstrumentMonitor.GetAlarmStatus();
                    InstrumentStatus IS = InstrumentMonitor.GetInstrumentStatus();
                    if (chkMonitorVideo.Checked)
                    {

                        //update images
                        string updatetime1;
                        string updatetime2;
                        //Bitmap Cam1 = InstrumentMonitor.GetCameraImage1(out updatetime1);
                        //Bitmap Cam2 = InstrumentMonitor.GetCameraImage2(out updatetime2);
                        byte[] myStream = InstrumentMonitor.ReturnJPEGCamera1(out updatetime1);
                        Image Cam1 = TurnByteArrayToImage(myStream);
                        myStream = InstrumentMonitor.ReturnJPEGCamera2(out updatetime2);
                        Image Cam2 = TurnByteArrayToImage(myStream);
                        object[] args = { Cam1, updatetime1, Cam2, updatetime2 };
                        this.Invoke(BitmapDel, args);

                    }
                    if (chkIdle.Checked)
                    { CheckForIdle(); }

                    if (AS.AlarmOn)
                    {
                        if (AlarmOnOrOff == CurrentAlarmState.AlarmOn)
                        {
                            //alarm already running

                            continue;
                        }
                        else if (AS.TimeTurnedOn == AlarmToIgnore.TimeTurnedOn)
                        {
                            //alarm already ignored
                            continue;
                        }
                        else
                        {
                            CurAlarm = new AlarmState();
                            CurAlarm.AlarmOn = AS.AlarmOn;
                            CurAlarm.TimeTurnedOn = AS.TimeTurnedOn;
                            AlarmOnOrOff = CurrentAlarmState.AlarmOn;
                            PlayAlarmSound();
                        }
                    }
                    else if (AlarmOnOrOff== CurrentAlarmState.AlarmOn && !ClientSideAlarmActivation)
                    {
                        StopAlarmSound();
                    }
                    //update the status
                    object[] tmp = new object[1] { IS.Status };
                    this.Invoke(UpdateStatusDel, tmp);
                    //wait 4 seconds
                    Thread.Sleep(POLLING_INTERVAL);
                }
            }
            catch (Exception thrown)
            {
                if (chkAlarmDisconnect.Checked)
                {
                    CreateAndActivateAlarm();
                }
                isConnected = false;
                MessageBox.Show("Could not poll the Clarity software for its status.  This suggests the software is not running.\n\n"+thrown.Message,"Problem Connecting",MessageBoxButtons.OK,MessageBoxIcon.Error);
                ChangeButtonFromOtherThread();
            }
        }
Ejemplo n.º 3
0
 private void Form1_Load(object sender, EventArgs e)
 {
     PerformPolling = true;
     AlarmOnOrOff = CurrentAlarmState.AlarmOff;
     cmbIdleTime.SelectedIndex = 2;
     string curDir = Environment.CurrentDirectory;
     string toAdd;
     if (curDir.Contains('/'))
     {
         toAdd = "/alarm.wav";
     }
     else{toAdd= "\\alarm.wav";}
     Player = new SoundPlayer(new FileStream((curDir+toAdd),FileMode.Open,FileAccess.Read,FileShare.Read));
     UpdateStatusDel=new del_String(UpdateInstrumentStatus);
     BitmapDel=new del_BitMap(UpdateImages);
     //start polling
     BeginMonitoring();
 }
Ejemplo n.º 4
0
 private void PlayAlarmSound()
 {
     AlarmOnOrOff=CurrentAlarmState.AlarmOn;
         Player.PlayLooping();
 }
Ejemplo n.º 5
0
 private void CreateAndActivateAlarm()
 {
     PlayAlarmSound();
     CurAlarm = new AlarmState();
     CurAlarm.AlarmOn = true;
     CurAlarm.TimeTurnedOn = DateTime.Now;
     ClientSideAlarmActivation = true;
     AlarmOnOrOff = CurrentAlarmState.AlarmOn;
 }