pari: branch asterisknow r2133 - /branches/asterisknow/config/digital.html

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Fri Jan 11 19:53:45 CST 2008


Author: pari
Date: Fri Jan 11 19:53:44 2008
New Revision: 2133

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=2133
Log:
Read sync/clock source from zaptel.conf

Modified:
    branches/asterisknow/config/digital.html

Modified: branches/asterisknow/config/digital.html
URL: http://svn.digium.com/view/asterisk-gui/branches/asterisknow/config/digital.html?view=diff&rev=2133&r1=2132&r2=2133
==============================================================================
--- branches/asterisknow/config/digital.html (original)
+++ branches/asterisknow/config/digital.html Fri Jan 11 19:53:44 2008
@@ -21,11 +21,11 @@
  *
  ** this page is designed to work with the following sample ztscan output 
  ** - - - - - - begin ztscan output - - - - - - - - 
- **   [1]
+ **   [3]
  **   active=yes
  **   alarms=UNCONFIGURED
- **   description=T4XXP (PCI) Card 0 Span 1
- **   name=TE4/0/1
+ **   description=T4XXP (PCI) Card 2 Span 1
+ **   name=TE4/2/1
  **   manufacturer=Digium
  **   devicetype=Wildcard TE410P/TE405P (1st Gen)
  **   location=PCI Bus 02 Slot 04
@@ -40,9 +40,12 @@
  **   coding=
  **   framing=
  ** - - - - - - End of ztscan output - - - - - - - - 
+ ** in the above output, [3] is the span number and the description says 'Card 2 Span 1' which is 
+ ** still valid because 'span 3' is the 'span 1' on 'card 2'
  ** if your ztscan outputs in some other wiered format, this page will go crazy and might not work as expected.
  ** 
  ** 
+ *** in this page, SPANS[l]['syncsrc'] is NOT the syncsrc from ztscan - but it is read from zaptel.conf
  -->
 <script src="scripts/prototype.js"></script>
 <script src="scripts/astman.js"></script>
@@ -119,6 +122,8 @@
 var hwchanged = true ; // -1 for no previous configuration found (first time), true for detected hardware changes, false for no hardware changes
 
 var HAS_ANALOGHARDWARE = true; var HAS_DIGITALHARDWARE = true; // if the user does not have any hardware - always set parent.REQUIRE_RESTART to false
+
+var SPANCOUNT_LOCATION = {}; // this object is used to store the number of spans found in each location Ex: SPANCOUNT_LOCATION['PCI Bus 02 Slot 04'] = 4;
 
 function detectHwChanges(){ // compare DETECTEDHARDWARE vs CONFIGUREDHARDWARE 
 // returns true if a hardware change is detected and false if there are no hardware changes
@@ -259,7 +264,16 @@
 	}else{
 		_$('editspan_switchtype').selectedIndex = -1 ;
 	}
-	ASTGUI.selectbox.selectOption( _$('editspan_syncsrc') , SPANS[l]['syncsrc'] );
+
+	(function (){
+		ASTGUI.selectbox.clear( _$('editspan_syncsrc'));
+		var y = SPANCOUNT_LOCATION[ SPANS[l]['location'] ];
+		var u =0; 
+		while(u<=y){ ASTGUI.selectbox.append( _$('editspan_syncsrc'),u,u ); u++ }
+		if( !SPANS[l].hasOwnProperty('syncsrc') ){ SPANS[l]['syncsrc'] = '1' } // default
+		ASTGUI.selectbox.selectOption( _$('editspan_syncsrc') , SPANS[l]['syncsrc'] );
+	})();
+
 	ASTGUI.selectbox.selectOption( _$('editspan_lbo') , SPANS[l]['lbo'] );
 	_$('edit_span').style.display = "";
 	_$('bg_transparent').style.display = "";
@@ -481,6 +495,10 @@
 				SPANS[l] = {};
 				for( var k in n[l] ){ if(n[l].hasOwnProperty(k)){ 
 					SPANS[l][k] = n[l][k]; // store all the other fields in spans[l]
+					if( k == 'location'){
+						if(!(SPANCOUNT_LOCATION[n[l]['location']]) ){ SPANCOUNT_LOCATION[n[l]['location']] = 0; }
+						SPANCOUNT_LOCATION[n[l]['location']] = SPANCOUNT_LOCATION[n[l]['location']] + 1;
+					}
 					if( k=='location' && !(DETECTEDHARDWARE[n[l]['location']]) ){
 						DETECTEDHARDWARE[ n[l]['location'] ] = {};
 						DETECTEDHARDWARE[ n[l]['location'] ]['device'] = n[l]['devicetype'];
@@ -603,24 +621,52 @@
 	},
 
 	load_zaptel_conf: function(){
+		// we parse zaptel.conf to get the loadzone and syncsrc for each span
+
 		var tmp_file = 'zaptel_guiRead.conf';
 		parent.astmanEngine.run_tool("touch /etc/asterisk/" + tmp_file, function(t){
 			var parseZaptelconf = function(zp){
-				if(zp['general']['loadzone']){
-					var y = zp['general']['loadzone'];
-					ASTGUI.selectbox.selectOption( _$('loadZone'), y );
-				}else{
-					var y ='';
-					 _$('loadZone').selectedIndex = -1;
-				}
-;			};
+				(function (){
+					var t = zp['general'] ; // t is an array
+					var line = '';
+					_$('loadZone').selectedIndex = -1;
+					for(var g=0; g < t.length; g++){
+						line = t[g];
+						//try{
+							if( line.beginsWith('loadzone=')) {
+								var y = ASTGUI.parseContextLine.read(line) ;
+								ASTGUI.selectbox.selectOption( _$('loadZone'), y[1] );
+								return;
+							}
+						//}catch(err){
+						//	_$('loadZone').selectedIndex = -1;
+						//}
+					}
+				})();
+
+				(function (){
+					
+					var t = zp['general'] ; // t is an array
+					t.each(function(line){
+						try{
+						if(line.beginsWith('span=')){
+							var y = ASTGUI.parseContextLine.read(line)[1] ;
+							var span_no = y.split(',')[0];
+							var src_span = y.split(',')[1];
+							if(SPANS[span_no]){ SPANS[span_no]['syncsrc'] = src_span; }
+						}
+						}catch(err){}
+					});
+				})();
+
+			};
 
 			var somefunction = function(){
 				var c = 0;
 				var uri = build_action('delcat', c, 'general', "", ""); c++;
 				uri += build_action('newcat', c, 'general', "", ""); c++;
 				uri += build_action('update', c, 'general', '#include "../zaptel.conf" ;', ''); c++;
-				makerequest('u', tmp_file, uri, function(t) { config2json(tmp_file, 1, parseZaptelconf); });
+				makerequest('u', tmp_file, uri, function(t) { config2json(tmp_file, 0, parseZaptelconf); });
 			}();
 		});
 	},
@@ -845,7 +891,7 @@
 				SPANS[k]['fac'] = SPANS[k]['framing'] + '/' + SPANS[k]['coding'];
 
 				if(SPANS[k]['lbo'] == "") { SPANS[k]['lbo'] = 0; }
-				if(SPANS[k]['syncsrc'] == "") { SPANS[k]['syncsrc'] = 0; }
+				if(SPANS[k]['syncsrc'] == "") { SPANS[k]['syncsrc'] = 1; }
 				secondpart = k + "," + SPANS[k]['syncsrc']  + "," + SPANS[k]['lbo'] + "," + SPANS[k]['fac'].toLowerCase().replace("/", ",");
 				uri += build_action('append', c, context, firstpart, secondpart ); c++;
 				tmp2 = (bchanstring)? ",":"";
@@ -1004,8 +1050,6 @@
 	</TR>
 	<TR>	<TD align="right">Sync/Clock Source</TD>
 		<TD>	<select id="editspan_syncsrc">
-				<option value="0">Master (0) (Set Timing)</option>
-				<option value="1">Slave (1) (Take Timing)</option>
 			</select>
 		</TD>
 	</TR>




More information about the asterisk-gui-commits mailing list