[Xastir-dev] Weather Validation Patch

Clay Jackson clayj at nwlink.com
Mon Mar 1 23:33:17 EST 2010


For some reason, the list seems to be rejecting my attachments - it's just pasted below:

diff -ur xastir/config/language-English.sys build_dev/config/language-English.sys
--- xastir/config/language-English.sys	2010-02-21 15:21:33.000000000 -0800
+++ build_dev/config/language-English.sys	2010-02-21 15:07:31.000000000 -0800
@@ -948,6 +948,7 @@
 IFDNL00012|Networked AGWPE||
 IFDNL00013|Serial Multi-Port KISS TNC||
 IFDNL00014|SQL Database (Experimental)||
+IFDNL00015|Weather File||
 #
 # Interface device info 
 IFDIN00000|%s %2d %s %s   %s||
@@ -1005,6 +1006,9 @@
 WXPUPSI026|Davis Weather Monitor II/Wizard III/Vantage Pro||
 WXPUPSI027|LaCrosse WX-23xx||
 WXPUPSI028|Davis APRS Data Logger||
+WXPUPSI029|Latest Time||
+WXPUPSI030|Weather XML File||
+WXPUPSI031|Weather APRS File||
 #
 # Station Lists
 LHPUPNI000|All Stations||
diff -ur xastir/src/interface.h build_dev/src/interface.h
--- xastir/src/interface.h	2010-02-21 15:26:30.000000000 -0800
+++ build_dev/src/interface.h	2010-02-22 21:35:48.000000000 -0800
@@ -71,7 +71,7 @@
 
 
 
-#define MAX_IFACE_DEVICE_TYPES 15
+#define MAX_IFACE_DEVICE_TYPES 16
 
 /* Define Device Types */
 enum Device_Types {
@@ -89,7 +89,8 @@
     DEVICE_NET_DATABASE,
     DEVICE_NET_AGWPE,
     DEVICE_SERIAL_MKISS_TNC,    // Multi-port KISS TNC, like the Kantronics KAM
-    DEVICE_SQL_DATABASE         // SQL server (MySQL/Postgis) database
+    DEVICE_SQL_DATABASE,        // SQL server (MySQL/Postgis) database
+    DEVICE_WX_FILE		// Weather data in an XML file
 };
 
 enum Device_Active {
diff -ur xastir/src/interface_gui.c build_dev/src/interface_gui.c
--- xastir/src/interface_gui.c	2010-02-27 16:43:06.000000000 -0800
+++ build_dev/src/interface_gui.c	2010-02-28 14:03:47.000000000 -0800
@@ -7850,6 +7850,9 @@
                                     sizeof(temp2),
                                     "%s",
                                     langcode("IFDIN00006"));
+				if (devices[i].device_type == DEVICE_SERIAL_WX || 
+					devices[i].device_type == DEVICE_NET_WX )
+				    wx_valid = 0;
                                 break;
 
                             case DEVICE_UP:
@@ -7857,6 +7860,9 @@
                                     sizeof(temp2),
                                     "%s",
                                     langcode("IFDIN00007"));
+				    if (devices[i].device_type == DEVICE_SERIAL_WX || 
+					    devices[i].device_type == DEVICE_NET_WX )
+				        wx_valid = 1;
                                 break;
 
                             case DEVICE_ERROR:
@@ -7864,6 +7870,9 @@
                                     sizeof(temp2),
                                     "%s",
                                     langcode("IFDIN00008"));
+				    if (devices[i].device_type == DEVICE_SERIAL_WX || 
+					    devices[i].device_type == DEVICE_NET_WX )
+				        wx_valid = 0;
                                 break;
 
                             default:
@@ -7871,6 +7880,9 @@
                                     sizeof(temp2),
                                     "%s",
                                     langcode("IFDIN00009"));
+				    if (devices[i].device_type == DEVICE_SERIAL_WX || 
+					    devices[i].device_type == DEVICE_NET_WX )
+				        wx_valid = 0;
                                 break;
                         }
                     } else {
@@ -7878,6 +7890,9 @@
                             sizeof(temp2),
                             "%s",
                             langcode("IFDIN00006"));
+			if (devices[i].device_type == DEVICE_SERIAL_WX || 
+			    devices[i].device_type == DEVICE_NET_WX )
+			    wx_valid = 0;
                     }
                     switch (devices[i].device_type) {
                         case DEVICE_SERIAL_TNC:
@@ -8964,7 +8979,10 @@
 if (end_critical_section(&port_data_lock, "interface_gui.c:interface_status(2)" ) > 0)
     fprintf(stderr,"port_data_lock, Port = %d\n", i);
                         read_data=1;
-                    }
+	                if (devices[i].device_type == DEVICE_SERIAL_WX || 
+		  	       devices[i].device_type == DEVICE_NET_WX )
+		            wx_valid = 1;
+                    } 
                     if (port_data[i].bytes_output_last != port_data[i].bytes_output) {
 if (begin_critical_section(&port_data_lock, "interface_gui.c:interface_status(3)" ) > 0)
     fprintf(stderr,"port_data_lock, Port = %d\n", i);
diff -ur xastir/src/main.c build_dev/src/main.c
--- xastir/src/main.c	2010-02-16 17:12:35.000000000 -0800
+++ build_dev/src/main.c	2010-02-27 21:10:58.000000000 -0800
@@ -12429,12 +12429,15 @@
                         case DEVICE_SERIAL_WX:
 
                         case DEVICE_NET_WX:
-                            if (log_wx)
-                                log_data( get_user_base_dir(LOGFILE_WX),
-                                    (char *)data_string);
-
-                            wx_decode(data_string,
-                                data_port);
+			    if (wx_valid) {	// only decode good data
+                                if (log_wx)
+                                    log_data( get_user_base_dir(LOGFILE_WX),
+                                        (char *)data_string);
+
+                                wx_decode(data_string,
+                                    data_port);
+			    } else
+                                fprintf(stderr,"Weather data invalid\n");
                             break;
 
                         default:
diff -ur xastir/src/wx.c build_dev/src/wx.c
--- xastir/src/wx.c	2010-02-21 15:27:29.000000000 -0800
+++ build_dev/src/wx.c	2010-02-28 12:46:31.000000000 -0800
@@ -129,6 +129,9 @@
 char wx_low_temp_on;
 char wx_heat_index[10];
 char wx_heat_index_on;
+char wx_latest_time[30];
+char wx_latest_time_on;
+int wx_valid;			// flag to tell if weather data is valid
 
 
 
@@ -3284,11 +3287,13 @@
 
     st[0] = '\0';
     wx_time = 0;
+    if ( !wx_valid )
+	return 0;
+
     if (search_station_name(&p_station,my_callsign,1)) {
-        if (get_weather_record(p_station)) {    // station has wx data
+        if (get_weather_record(p_station)) {
             weather = p_station->weather_data;
 
-
 //WE7U: For debugging purposes only
 //weather->wx_sec_time=sec_now();
 //sprintf(weather->wx_course,"359");          // degrees
@@ -3371,8 +3376,7 @@
                 xastir_snprintf(st,
                     st_size,
                     ".../...");
-
-
+            
             if (debug_level & 1) {
                 fprintf(stderr,"\n\nAt least one field was empty: Course: %s\tSpeed: %s\n", weather->wx_course, weather->wx_speed);
                 fprintf(stderr,"Will be sending '.../...' instead of real values.\n\n\n");
@@ -3583,7 +3587,6 @@
     if (debug_level & 1)
         fprintf(stderr,"Weather String:  %s\n", st);
 
-
     return(wx_time);
 }
 
diff -ur xastir/src/wx_gui.c build_dev/src/wx_gui.c
--- xastir/src/wx_gui.c	2010-02-21 15:27:29.000000000 -0800
+++ build_dev/src/wx_gui.c	2010-02-22 21:46:48.000000000 -0800
@@ -753,11 +753,13 @@
 Widget WX_three_hour_baro_label;
 Widget WX_hi_temp_data;
 Widget WX_low_temp_data;
+Widget WX_latest_wx_time_data;
 Widget WX_dew_point_label;
 Widget WX_wind_chill_label;
 Widget WX_heat_index_label;
 Widget WX_hi_temp_label;
 Widget WX_low_temp_label;
+Widget WX_latest_wx_time_label;
 Widget WX_high_wind_label;
 
 
@@ -801,7 +803,7 @@
             dew_point,
             high_wind, wind_chill,
             heat_index, three_hour_baro,
-            hi_temp, low_temp,
+            hi_temp, low_temp, latest_wx_time,
             sts;
 
     Atom delw;
@@ -1690,6 +1692,52 @@
                                       NULL);
 
 
+        latest_wx_time = XtVaCreateManagedWidget(langcode("WXPUPSI029"),xmLabelWidgetClass, form1,
+                                      XmNtopAttachment, XmATTACH_WIDGET,
+                                      XmNtopWidget, low_temp,
+                                      XmNtopOffset, 11,
+                                      XmNbottomAttachment, XmATTACH_NONE,
+                                      XmNleftAttachment, XmATTACH_POSITION,
+                                      XmNleftPosition, 4,
+                                      XmNrightAttachment, XmATTACH_NONE,
+                                      XmNbackground, colors[0xff], 
+                                      XmNfontList, fontlist1,
+                                      NULL);
+
+        WX_latest_wx_time_data = XtVaCreateManagedWidget("WX_station Latest time", xmTextFieldWidgetClass, form1,
+                                      XmNeditable,   FALSE,
+                                      XmNcursorPositionVisible, FALSE,
+                                      XmNcolumns, 6,
+                                      XmNsensitive,TRUE,
+                                      XmNshadowThickness,1,
+                                      XmNleftAttachment, XmATTACH_POSITION,
+                                      XmNleftPosition, 5,
+                                      XmNrightAttachment, XmATTACH_NONE,
+                                      XmNtopAttachment,XmATTACH_WIDGET,
+                                      XmNtopWidget, low_temp,
+                                      XmNtopOffset, 7,                    
+                                      XmNbottomAttachment,XmATTACH_NONE,
+                                      XmNbackground, colors[0x0f], 
+                                      XmNfontList, fontlist1,
+                                      NULL);
+
+        WX_latest_wx_time_label = XtVaCreateManagedWidget("WX_station latest time label",xmTextFieldWidgetClass, form1,
+                                      XmNeditable,   FALSE,
+                                      XmNcursorPositionVisible, FALSE,
+                                      XmNsensitive, STIPPLE,
+                                      XmNshadowThickness,0,
+                                      XmNtopAttachment, XmATTACH_WIDGET,
+                                      XmNtopWidget,  low_temp,
+                                      XmNtopOffset, 8,
+                                      XmNbottomAttachment, XmATTACH_NONE,
+                                      XmNleftAttachment, XmATTACH_WIDGET,
+                                      XmNleftWidget, WX_latest_wx_time_data,
+                                      XmNleftOffset, 5,
+                                      XmNrightAttachment, XmATTACH_NONE,
+                                      XmNbackground, colors[0xff], 
+                                      XmNfontList, fontlist1,
+                                      NULL);
+
         button_close = XtVaCreateManagedWidget(langcode("UNIOP00003"),xmPushButtonGadgetClass, my_form,
 XmNtraversalOn, TRUE,
                                       XmNtopAttachment, XmATTACH_WIDGET,
@@ -1985,6 +2033,19 @@
 
                     XtManageChild(WX_low_temp_data);
 
+                    wx_latest_time_on = 1; 
+
+                    if (wx_latest_time_on) {
+                        xastir_snprintf(temp,
+                            sizeof(temp),
+                            "%03d",
+                             (int)((int)sec_now()-weather->wx_sec_time));
+                       XmTextFieldSetString(WX_latest_wx_time_data,temp);
+                    } else
+                        XmTextFieldSetString(WX_latest_wx_time_data,"");
+
+                    XtManageChild(WX_latest_wx_time_data);
+
                     if (wx_heat_index_on) {
                         if (!english_units) {
                             xastir_snprintf(temp,

On Mar 1, 2010, at 7:48 PM, Clay Jackson wrote:

> Of course,I forgot the attachment - so, here it is.  It's against 1.9.8 stable.  I have another version almost ready to go that implements Dew Point for Davis (both flavors) and does Wind Chill (for Davis) with temps higher than 50 degrees.  I'm still testing that; will probably post later this week (Friday with my current schedule).
> 
> 
> Clay
> N7QNM
> 
> 
> On Feb 28, 2010, at 3:34 PM, Clay Jackson wrote:
> 
>> I finally got around to modifying Xastir (1.9.4 stable) so that it would not repeatedly transmit weather data from a "broken" or down interface - so, here's my first attempt at a contribution.  Do with it as you will :-)  It's a work in progress; but I wanted to get what I think is a stable version out for folks to look at.
>> 
>> I also included some code that computes how "old" the latest weather record is - my goal is to have put a "timing" bar in that will allow the user to select how old you want weather data to be before it's considered "too old" to be useful (i.e., transmitted).
>> 
>> Clay
>> N7QNM
>> _______________________________________________
>> Xastir-dev mailing list
>> Xastir-dev at lists.xastir.org
>> http://lists.xastir.org/cgi-bin/mailman/listinfo/xastir-dev
> 
> _______________________________________________
> Xastir-dev mailing list
> Xastir-dev at lists.xastir.org
> http://lists.xastir.org/cgi-bin/mailman/listinfo/xastir-dev




More information about the Xastir-dev mailing list