Commit 409440f4 authored by claes's avatar claes

More audio functions

parent 2c83f9cb
......@@ -394,6 +394,55 @@ Help on graph window will soon be written...
</TOPIC>
</chapter>
<chapter>
<TOPIC> trendwindow
Trend Window
The Trend Window is opened from the object popup menu (method
"Trend", or with the xtt command 'open trend'.
The window displays a trend stored in a DsTrend objekt, or a number of trends
specified by a PlotGroup object.
<image> xtt_trendwindow.gif
The limits for the y-axis for a curve can be changed by double clicking
at the colored axis for that curve. A dialog box is opened where the
new minimum and maximum values are entered.
The limits for the x-axis are changed from the menu, 'View/X-axis limits'.
When 'View/Show names' in the menu is activated, the name of the signals
are displayed together with a colored checkbox for each signal. By clicking
on the checkbox, the curve can be hidden or viewed.
</TOPIC>
<TOPIC> fastwindow
Fast Curve Window
The Fast Curve Window is opened from the object popup menu (method
"Fast", or with the xtt command 'open fast'.
The window displays a trend stored in a DsTrend objekt, or a number of trends
specified by a PlotGroup object.
<image> xtt_fastwindow.gif
The limits for the y-axis for a curve can be changed by double clicking
at the colored axis for that curve. A dialog box is opened where the
new minimum and maximum values are entered.
The limits for the x-axis are changed from the menu, 'View/X-axis limits'.
When 'View/Show names' in the menu is activated, the name of the signals
are displayed together with a colored checkbox for each signal. By clicking
on the checkbox, the curve can be hidden or viewed.
</TOPIC>
</chapter>
//
// Commands
//
......@@ -537,6 +586,7 @@ Xtt commands
<b>show eventlist<t>Show the event list <LINK> show eventlist
<b>show alarmlist<t>Show the alarm list <LINK> show alarmlist
<b>show user <t>Show current user <LINK> show user
<b>sound <t>Play a sound defined by a sound object <LINK> sound
<b>store <t>Store an attribute list in a file <LINK> store
<H2>related subjects
......@@ -1089,6 +1139,15 @@ Show the current user and his privileges.
<B>xtt> show user
</TOPIC>
<TOPIC> sound <style> function
Command sound
Play a sound defined by a Sound or SoundSequence object.
<B>xtt> sound 'object'
</TOPIC>
<TOPIC> store <style> function
Command store
......@@ -1129,6 +1188,7 @@ logging show <LINK> logging show
logging store <LINK> logging store
</TOPIC>
</headerlevel>
</chapter>
......
......@@ -2,22 +2,22 @@
100 20
135 20
101 20
102 -40
103 -91
104 4.06918
136 4.06918
102 199
103 -41
104 5.30719
136 5.30719
105 100
106 -8
107 -18
106 2
107 -10
108 36.6307
109 0.415271
110 32.9544
111 1
116 0
116 50
117 0
118 199
119 122
120 1
118 200
119 115
120 0
121 Claes context
122 0
126 1
......@@ -32,7 +32,7 @@
134
22
2200 0
2201 129
2201 133
2202 pwr_c_sound
2203 51
2205 0
......@@ -42,7 +42,7 @@
2208
2209 0.2
2210 0.8
2211 36
2211 36.8
2212 33
2213 4
2214
......@@ -4047,6 +4047,119 @@ pwr_exe:
320 0
328 0
99
3
300 pwr_buttoncommand
301
2
19
1904
1900 5.1
1901 0.2
1902 1.8
1903 0.2
1908 0
1909 102
1910 102
1911 1
1915 1
1913 16
1916 2
1914 0
1918 0
1919 0
1917 0
1907 0
1906
1905
5
500 0
501 1
504 1
505 1
502
7
700 0.2
701 0.2
99
503
7
700 5.1
701 1.8
99
99
1912
28
2800 1
2801 0
2802 0
2803 0
2804 1
2805 0
2806 0
99
99
29
2907
13
1300 1
1301 304
1306 0
1302 3
1305 1
1303
7
700 0.55
701 0.65
99
1304 0
99
2908
28
2800 1
2801 0
2802 0.2
2803 0
2804 1
2805 0.55
2806 0
99
99
99
302 0
304 0
303
305 0
306
307
308 0
321 64
309 0
313 0
322 0
323 0
324 0
325 0
326 0
327 0
310 0
311 0
312
314
315 1
316 1
317 0
318 0
319 0
320 0
328 1080498440
329
1
100 1
101 1
102 33619964
103 0
99
99
99
124
2
......@@ -7740,8 +7853,8 @@ pwr_exe:
3004
3000 3.3
3001 1.15
3002 14.8164
3003 14.1164
3002 14.1164
3003 13.4164
3008 103
3007 0
3006
......@@ -7764,7 +7877,7 @@ pwr_exe:
2802 0.05
2803 0
2804 1
2805 12.1664
2805 11.4664
2806 0
99
99
......@@ -7825,12 +7938,12 @@ pwr_exe:
0
1006 9.34251
1007 4.65
1008 14.9
1009 13.9
1008 14.2
1009 13.2
1013 9.34251
1014 4.65
1015 14.9
1016 13.9
1015 14.2
1016 13.2
1003
0
0
......@@ -7872,7 +7985,7 @@ pwr_exe:
2802 4.65
2803 0
2804 1
2805 13.9
2805 13.2
2806 0
99
2716 0
......@@ -7908,8 +8021,8 @@ pwr_exe:
3004
3000 3.4
3001 1.15
3002 16.1664
3003 15.4664
3002 15.4664
3003 14.7664
3008 103
3007 0
3006
......@@ -7932,7 +8045,7 @@ pwr_exe:
2802 0.05
2803 0
2804 1
2805 13.5164
2805 12.8164
2806 0
99
99
......@@ -7993,12 +8106,12 @@ pwr_exe:
0
1006 9.34251
1007 4.65
1008 16.25
1009 15.25
1008 15.55
1009 14.55
1013 9.34251
1014 4.65
1015 16.25
1016 15.25
1015 15.55
1016 14.55
1003
0
0
......@@ -8040,7 +8153,7 @@ pwr_exe:
2802 4.65
2803 0
2804 1
2805 15.25
2805 14.55
2806 0
99
2716 0
......@@ -8129,12 +8242,12 @@ pwr_exe:
0
1006 36.1249
1007 9.5148
1008 14.8499
1009 14.0166
1008 14.1499
1009 13.3166
1013 36.1249
1014 9.5148
1015 14.8499
1016 14.0166
1015 14.1499
1016 13.3166
1003
0
0
......@@ -8176,7 +8289,7 @@ pwr_exe:
2802 36.1249
2803 0.416667
2804 -0
2805 14.0166
2805 13.3166
2806 -270
99
2716 0
......@@ -8256,12 +8369,12 @@ pwr_exe:
0
1006 17.6987
1007 16.9448
1008 15.013
1009 14.0857
1008 14.313
1009 13.3857
1013 17.6987
1014 16.9448
1015 15.013
1016 14.0857
1015 14.313
1016 13.3857
1003
0
0
......@@ -8303,7 +8416,7 @@ pwr_exe:
2802 17.6448
2803 0.618182
2804 -0
2805 14.0239
2805 13.3239
2806 -270
99
2716 0
......@@ -8383,12 +8496,12 @@ pwr_exe:
0
1006 36.1249
1007 9.5148
1008 16.1999
1009 15.3666
1008 15.4999
1009 14.6666
1013 36.1249
1014 9.5148
1015 16.1999
1016 15.3666
1015 15.4999
1016 14.6666
1003
0
0
......@@ -8430,7 +8543,7 @@ pwr_exe:
2802 36.1249
2803 0.416667
2804 -0
2805 15.3666
2805 14.6666
2806 -270
99
2716 0
......@@ -8510,12 +8623,12 @@ pwr_exe:
0
1006 17.6987
1007 16.9448
1008 16.363
1009 15.4357
1008 15.663
1009 14.7357
1013 17.6987
1014 16.9448
1015 16.363
1016 15.4357
1015 15.663
1016 14.7357
1003
0
0
......@@ -8557,7 +8670,7 @@ pwr_exe:
2802 17.6448
2803 0.618182
2804 -0
2805 15.3739
2805 14.6739
2806 -270
99
2716 0
......@@ -8588,8 +8701,8 @@ pwr_exe:
1904
1900 34.15
1901 11.65
1902 13.1529
1903 12.4
1902 12.9029
1903 12.15
1908 0
1909 0
1910 0
......@@ -8627,7 +8740,7 @@ pwr_exe:
2802 -33.8
2803 -0.627451
2804 0
2805 20.3373
2805 20.0873
2806 -90
99
99
......@@ -8647,8 +8760,8 @@ pwr_exe:
1904
1900 34.15
1901 11.65
1902 17.2533
1903 16.4
1902 17.6533
1903 16.8
1908 0
1909 0
1910 0
......@@ -8686,7 +8799,7 @@ pwr_exe:
2802 -33.8
2803 -0.711111
2804 0
2805 25.3956
2805 25.7956
2806 -90
99
99
......@@ -11017,8 +11130,8 @@ pwr_exe:
1904
1900 35.1107
1901 23.1781
1902 32.2034
1903 31.35
1902 31.9034
1903 31.05
1908 0
1909 0
1910 0
......@@ -11056,7 +11169,7 @@ pwr_exe:
2802 -0.92573
2803 -0.711111
2804 0
2805 40.3456
2805 40.0456
2806 -90
99
99
......@@ -13108,8 +13221,8 @@ pwr_exe:
1904
1900 17.7107
1901 5.77809
1902 32.2034
1903 31.35
1902 31.9534
1903 31.1
1908 0
1909 0
1910 0
......@@ -13147,7 +13260,7 @@ pwr_exe:
2802 -18.3257
2803 -0.711111
2804 0
2805 40.3456
2805 40.0956
2806 -90
99
99
......@@ -15655,5 +15768,551 @@ pwr_exe:
2806 0
99
99
30
3004
3000 3.55
3001 1.15
3002 16.7664
3003 16.0664
3008 103
3007 0
3006
3005
9
900 2
901 304
904 0
902 Tremolo
903
7
700 1.1
701 2.5
99
99
3009
28
2800 1
2801 0
2802 0.05
2803 0
2804 1
2805 14.1164
2806 0
99
99
27
2703 47
2704 10000
2722 10000
2705 10000
2723 10000
2706 47
2708 0
2709 0
2710 0
2711 0
2712 0
2713 0
2714 0
2715 0
2720 0
2702 0
2701
2700
10
1000 pwr_valueinputmedium
1002 O129
1005
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1006 9.34251
1007 4.65
1008 16.85
1009 15.85
1013 9.34251
1014 4.65
1015 16.85
1016 15.85
1003
0
0
0
0
0
0
0
0
0
0
1004
1001
7
700 7.45
701 -0.25
99
1010
1011
1018
1019
1020
1021
1022
1023
1024
1025
1012 0
1017 9999
1027 9999
1026 65532
1028 0
1029
99
2707
28
2800 1.56417
2801 0
2802 4.65
2803 0
2804 1
2805 15.85
2806 0
99
2716 0
2718
2717
2719 0
2724 0
2721
1
100 1024
101 4096
102 6
103 0
12
1200 $object.Tremolo##Float32
1201 %10.3f
1202 1
1203 1
1204 0
99
13
1302 0
1303 100
1304 0
1305 0
1306 0
1307
1308
99
99
99
27
2703 10000
2704 10000
2722 10000
2705 10000
2723 10000
2706 10000
2708 0
2709 0
2710 2
2711 2
2712 0
2713 0
2714 0
2715 0
2720 0
2702 0
2701
2700
10
1000 pwr_sliderbackground1
1002 O130
1005
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1006 36.1249
1007 9.5148
1008 16.7999
1009 15.9666
1013 36.1249
1014 9.5148
1015 16.7999
1016 15.9666
1003
0
0
0
0
0
0
0
0
0
0
1004
1001
7
700 40.8213
701 4.1719
99
1010
1011
1018
1019
1020
1021
1022
1023
1024
1025
1012 0
1017 9999
1027 9999
1026 65532
1028 0
1029
99
2707
28
2800 0
2801 -2.4191
2802 36.1249
2803 0.416667
2804 -0
2805 15.9666
2806 -270
99
2716 0
2718
2717
2719 0
2724 0
2721
1
100 1
101 1
102 65532
103 0
99
99
33
3301 4
3302 100
3303 0
3304 0
3305 0
3300
27
2703 10000
2704 10000
2722 10000
2705 10000
2723 10000
2706 10000
2708 1
2709 1
2710 0
2711 0
2712 0
2713 0
2714 0
2715 0
2720 0
2702 0
2701
2700
10
1000 pwr_slider1
1002 O131
1005
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1006 17.6986
1007 16.9448
1008 16.963
1009 16.0357
1013 17.6986
1014 16.9448
1015 16.963
1016 16.0357
1003
0
0
0
0
0
0
0
0
0
0
1004
1001
7
700 40.2932
701 3.96067
99
1010 $object.ActualValue##Float32
1011
1018
1019
1020
1021
1022
1023
1024
1025
1012 0
1017 9999
1027 9999
1026 6
1028 0
1029
99
2707
28
2800 -0
2801 -0.538462
2802 17.6448
2803 0.618182
2804 -0
2805 15.9739
2806 -270
99
2716 0
2718
2717
2719 0
2724 0
2721
1
100 1
101 1
102 6
103 0
60
6000 $object.Tremolo##Float32
6001
6002
6003
99
99
99
99
27
2703 10000
2704 32
2722 10000
2705 32
2723 10000
2706 10000
2708 0
2709 0
2710 0
2711 0
2712 0
2713 0
2714 0
2715 0
2720 0
2702 0
2701
2700
10
1000 pwr_buttoncommand
1002 O132
1005
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1006 36.6
1007 31.7
1008 6.35
1009 4.75
1013 36.6
1014 31.7
1015 6.35
1016 4.75
1003
0
9
0
0
0
0
0
0
0
0
1004
" Play"
1001
7
700 24.2
701 5.25
99
1010
1011
1018
1019
1020
1021
1022
1023
1024
1025
1012 0
1017 9999
1027 9999
1026 33619964
1028 0
1029
99
2707
28
2800 1
2801 0
2802 31.5
2803 0
2804 1
2805 4.55
2806 0
99
2716 0
2718
2717
2719 0
2724 0
2721
1
100 1
101 1
102 33619966
103 0
55
5500 call method/method="Play"/object=$object
99
99
99
99
99
......@@ -139,8 +139,11 @@ int XttAudio::beep( pwr_tAttrRef *arp)
short *buffer;
pwr_tTid tid;
pwr_tStatus sts;
pwr_tAttrRef prioaref;
pwr_tInt32 prio;
if ( write_buffer) {
// Busy, add to que...
if ( queue_cnt == AUDIO_QUESIZE) {
// Queue full, skip beep
......@@ -151,7 +154,36 @@ int XttAudio::beep( pwr_tAttrRef *arp)
if ( cdh_ArefIsEqual( arp, &queue[i]))
return XNAV__SUCCESS;
}
queue[ queue_cnt++] = *arp;
// Insert in priority order
// Get prio
sts = gdh_ArefANameToAref( arp, "Prio", &prioaref);
if ( EVEN(sts)) return sts;
sts = gdh_GetObjectInfoAttrref( &prioaref, (void *) &prio, sizeof(prio));
if ( EVEN(sts)) return sts;
for ( int i = queue_cnt - 1; i >= -1; i--) {
if ( i == -1) {
queue[0] = *arp;
queue_prio[0] = prio;
queue_cnt++;
break;
}
if ( queue_prio[i] >= prio) {
// Insert
queue[i+1] = *arp;
queue_prio[i+1] = prio;
queue_cnt++;
break;
}
else {
// Shift
queue[i+1] = queue[i];
queue_prio[i+1] = queue_prio[i];
}
}
return XNAV__QUEUED;
}
......@@ -185,12 +217,12 @@ int XttAudio::beep( pwr_tAttrRef *arp)
if ( strncmp( sound.Source, "Sine", 4) == 0) {
MakeSine( buffer, size, 0, 0, sound.Length, sound.BaseTone + sound.ToneTable[i],
sound.Volume/100 * sound.VolumeTable[i], sound.Volume/100 * sound.VolumeTable[i],
sound.Attack, sound.Decay, sound.Sustain/100, sound.Release);
sound.Attack, sound.Decay, sound.Sustain/100, sound.Release, sound.Tremolo/100);
}
else if ( strncmp( sound.Source, "Square", 6) == 0) {
MakeSquare( buffer, size, 0, 0, sound.Length, sound.BaseTone + sound.ToneTable[i],
sound.Volume/100 * sound.VolumeTable[i], sound.Volume/100 * sound.VolumeTable[i],
sound.Attack, sound.Decay, sound.Sustain/100, sound.Release);
sound.Attack, sound.Decay, sound.Sustain/100, sound.Release, sound.Tremolo/100);
}
}
}
......@@ -330,7 +362,8 @@ int XttAudio::beep( pwr_tAttrRef *arp)
sound[seq.SequenceTable[i].SoundIdx].Attack,
sound[seq.SequenceTable[i].SoundIdx].Decay,
sound[seq.SequenceTable[i].SoundIdx].Sustain/100,
sound[seq.SequenceTable[i].SoundIdx].Release);
sound[seq.SequenceTable[i].SoundIdx].Release,
sound[seq.SequenceTable[i].SoundIdx].Tremolo/100);
}
else if ( strncmp( sound[seq.SequenceTable[i].SoundIdx].Source, "Square", 6) == 0) {
MakeSquare( buffer, size, 0, seq.SequenceTable[i].StartTime,
......@@ -341,7 +374,8 @@ int XttAudio::beep( pwr_tAttrRef *arp)
sound[seq.SequenceTable[i].SoundIdx].Attack,
sound[seq.SequenceTable[i].SoundIdx].Decay,
sound[seq.SequenceTable[i].SoundIdx].Sustain/100,
sound[seq.SequenceTable[i].SoundIdx].Release);
sound[seq.SequenceTable[i].SoundIdx].Release,
sound[seq.SequenceTable[i].SoundIdx].Tremolo/100);
}
}
}
......@@ -378,7 +412,7 @@ int XttAudio::beep( pwr_tAttrRef *arp)
buffer = (short *) calloc( sizeof(short), size);
if(!buffer) return XNAV__NOMEMORY;
MakeSine( buffer, size, 0, 0, 0.3, 38, 100.0, 100.0, 0, 0, 0, 0);
MakeSine( buffer, size, 0, 0, 0.3, 38, 100.0, 100.0, 0, 0, 0, 0, 0);
}
write_buffer = buffer;
......@@ -594,6 +628,8 @@ int XttAudio::Init_OSS(char *device, int samplerate)
double XttAudio::envelope( double time, double endtime, double attack, double decay, double sustain,
double release)
{
#if 0
// Version with linear decay, replaced by exponential decay
if ( time < endtime) {
if ( time >= attack + decay)
return sustain;
......@@ -603,15 +639,29 @@ double XttAudio::envelope( double time, double endtime, double attack, double de
}
if ( time >= endtime + release)
return 0;
return 1.0 - (time - endtime) / release;
return (1.0 - (time - endtime) / release) * sustain;
#endif
if ( time < endtime) {
if ( time <= attack)
return time / attack;
if ( sustain == 1.0)
return 1.0;
return sustain + (1.0 - sustain) * exp( -(time - attack) / decay);
}
if ( time >= endtime + release)
return 0;
if ( sustain == 1.0)
return ( 1.0 - (time - endtime) / release);
return (1.0 - (time - endtime) / release) * (sustain + (1.0 - sustain) * exp( -(endtime - attack) / decay));
}
void XttAudio::MakeSine(short *buffer, int buffersize, double time, double starttime, double endtime,
int tone, double volume_ch1, double volume_ch2, double attack, double decay,
double sustain, double release)
double sustain, double release, double tremolo)
{
int i;
double val;
double valtremolo;
double sum;
double ampl;
double t;
......@@ -627,13 +677,18 @@ void XttAudio::MakeSine(short *buffer, int buffersize, double time, double start
val = ampl * sin( freq[tone] * t * 2 * M_PI);
sum = 327.67 * volume_ch1 * val + buffer[i];
if ( tremolo != 0)
valtremolo = 1 - tremolo * (sin( t * 6 * 2 * M_PI) + 1) / 2;
else
valtremolo = 1;
sum = 327.67 * volume_ch1 * val * valtremolo + buffer[i];
if ( sum > 32767)
buffer[i] = 32767;
else
buffer[i] = (unsigned short) sum;
sum = 327.67 * volume_ch2 * val + buffer[i+1];
sum = 327.67 * volume_ch2 * val * valtremolo + buffer[i+1];
if ( sum > 32767)
buffer[i+1] = 32767;
else
......@@ -643,10 +698,11 @@ void XttAudio::MakeSine(short *buffer, int buffersize, double time, double start
void XttAudio::MakeSquare(short *buffer, int buffersize, double time, double starttime, double endtime,
int tone, double volume_ch1, double volume_ch2, double attack, double decay,
double sustain, double release)
double sustain, double release, double tremolo)
{
int i;
double val;
double valtremolo;
double sum;
double ampl;
double t;
......@@ -662,13 +718,18 @@ void XttAudio::MakeSquare(short *buffer, int buffersize, double time, double sta
val = ampl * ( int(freq[tone] * t * 2) % 2 * 2 - 1);
sum = 327.67 * volume_ch1 * val + buffer[i];
if ( tremolo != 0)
valtremolo = 1 - tremolo * (sin( t * 6 * 2 * M_PI) + 1) / 2;
else
valtremolo = 1;
sum = 327.67 * volume_ch1 * val * valtremolo + buffer[i];
if ( sum > 32767)
buffer[i] = 32767;
else
buffer[i] = (unsigned short) sum;
sum = 327.67 * volume_ch2 * val + buffer[i+1];
sum = 327.67 * volume_ch2 * val * valtremolo + buffer[i+1];
if ( sum > 32767)
buffer[i+1] = 32767;
else
......
/*
* Proview $Id: xtt_audio.h,v 1.1 2005-11-14 16:17:13 claes Exp $
* Proview $Id: xtt_audio.h,v 1.2 2005-11-17 09:01:35 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -66,6 +66,7 @@ class XttAudio
int write_buffer_idx;
XtIntervalId timerid;
pwr_tAttrRef queue[AUDIO_QUESIZE];
int queue_prio[AUDIO_QUESIZE];
int queue_cnt;
int Init_ALSA(char *, unsigned int);
......@@ -74,10 +75,10 @@ class XttAudio
double decay, double sustain, double release);
void MakeSine(short *buffer, int buffersize, double time, double starttime, double endtime,
int tone, double volume_ch1, double volume_ch2, double attack, double decay,
double sustain, double release);
double sustain, double release, double tremolo);
void MakeSquare(short *buffer, int buffersize, double time, double starttime, double endtime,
int tone, double volume_ch1, double volume_ch2, double attack, double decay,
double sustain, double release);
double sustain, double release, double tremolo);
static void audio_write( XttAudio *);
};
......
/*
* Proview $Id: xtt_evlist.cpp,v 1.12 2005-11-14 16:17:13 claes Exp $
* Proview $Id: xtt_evlist.cpp,v 1.13 2005-11-17 09:01:35 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -391,6 +391,31 @@ EvList::EvList(
evlist_init_brow_cb, this, (Widget *)&brow_widget);
XtManageChild( form_widget);
if ( type == ev_eType_AlarmList) {
// Fetch sound objects
pwr_tStatus sts;
sts = gdh_NameToAttrref( pwr_cNObjid, "rt:Sounds-AAlarm", &aalarm_sound);
if ( EVEN(sts))
aalarm_sound = pwr_cNAttrRef;
sts = gdh_NameToAttrref( pwr_cNObjid, "rt:Sounds-BAlarm", &balarm_sound);
if ( EVEN(sts))
balarm_sound = pwr_cNAttrRef;
sts = gdh_NameToAttrref( pwr_cNObjid, "rt:Sounds-CAlarm", &calarm_sound);
if ( EVEN(sts))
calarm_sound = pwr_cNAttrRef;
sts = gdh_NameToAttrref( pwr_cNObjid, "rt:Sounds-DAlarm", &dalarm_sound);
if ( EVEN(sts))
dalarm_sound = pwr_cNAttrRef;
sts = gdh_NameToAttrref( pwr_cNObjid, "rt:Sounds-InfoEvent", &info_sound);
if ( EVEN(sts))
info_sound = pwr_cNAttrRef;
}
*w = form_widget;
}
......@@ -856,7 +881,33 @@ void EvList::beep( double scantime)
ItemAlarm *item;
if ( id_to_item( id, (void **)&item)) {
sts = (sound_cb)( parent_ctx, &item->eventsound);
pwr_tAttrRef *sound_arp;
if ( cdh_ObjidIsNotNull(item->eventsound.Objid))
sound_arp = &item->eventsound;
else {
switch ( item->event_type) {
case evlist_eEventType_Alarm:
switch ( item->eventprio) {
case mh_eEventPrio_A:
sound_arp = &aalarm_sound;
break;
case mh_eEventPrio_B:
sound_arp = &balarm_sound;
break;
case mh_eEventPrio_C:
sound_arp = &calarm_sound;
break;
default:
sound_arp = &dalarm_sound;
}
break;
default:
sound_arp = &info_sound;
break;
}
}
sts = (sound_cb)( parent_ctx, sound_arp);
}
}
if ( EVEN(sts))
......@@ -1394,25 +1445,42 @@ int EvList::get_last_not_acked_beep( mh_sEventId **id)
brow_tObject *object_list;
int object_cnt;
ItemAlarm *object_item;
int found = 0;
unsigned int prio = 0;
// Get first not acked event with highest priority
brow_GetObjectList( brow->ctx, &object_list, &object_cnt);
for ( i = 0; i < object_cnt; i++)
{
for ( i = 0; i < object_cnt; i++) {
brow_GetUserData( object_list[i], (void **)&object_item);
switch( object_item->type)
{
switch( object_item->type) {
case evlist_eItemType_Alarm:
if ( object_item->status & mh_mEventStatus_NotAck &&
object_item->eventflags & mh_mEventFlags_Bell) {
switch ( object_item->event_type) {
case evlist_eEventType_Alarm:
if ( object_item->eventprio > prio) {
*id = &object_item->eventid;
prio = object_item->eventprio;
found = 1;
if ( prio == mh_eEventPrio_A)
return 1;
}
break;
default:
;
case evlist_eEventType_Info:
*id = &object_item->eventid;
prio = 1;
found = 1;
break;
default: ;
}
}
return 0;
break;
default: ;
}
}
return found;
}
int EvList::get_last_not_acked_prio( mh_sEventId **id, unsigned long type,
......
/*
* Proview $Id: xtt_evlist.h,v 1.9 2005-11-14 16:17:13 claes Exp $
* Proview $Id: xtt_evlist.h,v 1.10 2005-11-17 09:01:35 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -168,6 +168,11 @@ class EvList {
int (*sound_cb)( void *, pwr_tAttrRef *);
double acc_beep_time;
double beep_interval;
pwr_tAttrRef aalarm_sound;
pwr_tAttrRef balarm_sound;
pwr_tAttrRef calarm_sound;
pwr_tAttrRef dalarm_sound;
pwr_tAttrRef info_sound;
void event_info( mh_sMessage *msg);
void event_alarm( mh_sMessage *msg);
......
/*
* Proview $Id: xtt_xnav.cpp,v 1.25 2005-11-14 16:17:13 claes Exp $
* Proview $Id: xtt_xnav.cpp,v 1.26 2005-11-17 09:01:35 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -352,8 +352,12 @@ int xnav_attr_string_to_value( int type_id, char *value_str,
{
pwr_tObjid objid;
if ( strcmp( value_str, "0") == 0)
objid = pwr_cNObjid;
else {
sts = gdh_NameToObjid ( value_str, &objid);
if (EVEN(sts)) return XNAV__OBJNOTFOUND;
}
memcpy( buffer_ptr, &objid, sizeof(objid));
break;
}
......@@ -411,8 +415,12 @@ int xnav_attr_string_to_value( int type_id, char *value_str,
{
pwr_sAttrRef attrref;
if ( strcmp( value_str, "0") == 0)
attrref = pwr_cNAttrRef;
else {
sts = gdh_NameToAttrref ( pwr_cNObjid, value_str, &attrref);
if (EVEN(sts)) return XNAV__OBJNOTFOUND;
}
memcpy( buffer_ptr, &attrref, sizeof(attrref));
break;
}
......
/*
* Proview $Id: xtt_xnav_command.cpp,v 1.24 2005-11-14 16:17:13 claes Exp $
* Proview $Id: xtt_xnav_command.cpp,v 1.25 2005-11-17 09:01:35 claes Exp $
* Copyright (C) 2005 SSAB Oxelsund AB.
*
* This program is free software; you can redistribute it and/or
......@@ -125,7 +125,9 @@ static void xnav_op_map_cb( void *ctx);
static int xnav_op_get_alarm_info_cb( void *xnav, evlist_sAlarmInfo *info);
static void xnav_op_ack_last_cb( void *xnav, unsigned long type, unsigned long prio);
static void xnav_trend_close_cb( void *ctx, XttTrend *trend);
static void xnav_trend_help_cb( void *ctx, char *key);
static void xnav_fast_close_cb( void *ctx, XttFast *fast);
static void xnav_fast_help_cb( void *ctx, char *key);
static void xnav_xao_close_cb( void *ctx, XAttOne *xao);
static void xnav_clog_close_cb( void *ctx);
......@@ -175,6 +177,8 @@ static int xnav_check_func( void *client_data,
void *client_flag);
static int xnav_print_func( void *client_data,
void *client_flag);
static int xnav_sound_func( void *client_data,
void *client_flag);
dcli_tCmdTable xnav_command_table[] = {
{
......@@ -323,6 +327,11 @@ dcli_tCmdTable xnav_command_table[] = {
"/OBJECT", "/CLASSGRAPH", "/INSTANCE",
""}
},
{
"SOUND",
&xnav_sound_func,
{ "dcli_arg1", "/OBJECT", ""}
},
{"",}};
......@@ -2751,14 +2760,18 @@ static int xnav_open_func( void *client_data,
xnav->message('E',"Error in trend configuration");
else {
trend->close_cb = xnav_trend_close_cb;
trend->help_cb = xnav_trend_help_cb;
xnav->appl.insert( applist_eType_Trend, (void *)trend, &plotgroup, "",
NULL);
}
}
}
else
new XttTrend( xnav, xnav->parent_wid, title_str, &w, aref_vect,
else {
trend = new XttTrend( xnav, xnav->parent_wid, title_str, &w, aref_vect,
0, &sts);
if ( ODD(sts))
trend->help_cb = xnav_trend_help_cb;
}
}
else if ( strncmp( arg1_str, "FAST", strlen( arg1_str)) == 0)
{
......@@ -2833,6 +2846,7 @@ static int xnav_open_func( void *client_data,
xnav->message('E',"Error in fast configuration");
else {
fast->close_cb = xnav_fast_close_cb;
fast->help_cb = xnav_fast_help_cb;
xnav->appl.insert( applist_eType_Fast, (void *)fast, &aref, "",
NULL);
}
......@@ -3306,6 +3320,19 @@ static void xnav_trend_close_cb( void *ctx, XttTrend *trend)
delete trend;
}
static void xnav_trend_help_cb( void *ctx, char *key)
{
XNav *xnav = (XNav *) ctx;
int sts;
sts = CoXHelp::dhelp( key, "", navh_eHelpFile_Base, NULL, 0);
if ( EVEN(sts))
xnav->message( 'E', "Unable to find topic");
else
xnav->message( ' ', null_str);
}
static void xnav_fast_close_cb( void *ctx, XttFast *fast)
{
XNav *xnav = (XNav *) ctx;
......@@ -3314,6 +3341,19 @@ static void xnav_fast_close_cb( void *ctx, XttFast *fast)
delete fast;
}
static void xnav_fast_help_cb( void *ctx, char *key)
{
XNav *xnav = (XNav *) ctx;
int sts;
sts = CoXHelp::dhelp( key, "", navh_eHelpFile_Base, NULL, 0);
if ( EVEN(sts))
xnav->message( 'E', "Unable to find topic");
else
xnav->message( ' ', null_str);
}
static void xnav_xao_close_cb( void *ctx, XAttOne *xao)
{
XNav *xnav = (XNav *) ctx;
......@@ -4450,6 +4490,33 @@ static int xnav_print_func(void *client_data,
return XNAV__SUCCESS;
}
static int xnav_sound_func(void *client_data,
void *client_flag)
{
XNav *xnav = (XNav *)client_data;
pwr_tOName object_str;
int sts;
pwr_tAttrRef aref;
if ( EVEN( dcli_get_qualifier( "/OBJECT", object_str, sizeof(object_str)))) {
if ( EVEN( dcli_get_qualifier( "dcli_arg1", object_str, sizeof(object_str)))) {
xnav->message('E', "Object is missing");
return XNAV__HOLDCOMMAND;
}
}
sts = gdh_NameToAttrref( pwr_cNObjid, object_str, &aref);
if ( EVEN(sts)) {
xnav->message('E',"Sound object not found");
return XNAV__HOLDCOMMAND;
}
xnav->sound( &aref);
return XNAV__SUCCESS;
}
int XNav::show_database()
{
int sts;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment