00001 /* ----------------------------------------------------------------------------- 00002 * parser.h 00003 * 00004 * iPDC - Phasor Data Concentrator 00005 * 00006 * Copyright (C) 2011 Nitesh Pandit 00007 * Copyright (C) 2011 Kedar V. Khandeparkar 00008 * 00009 * This program is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU General Public License 00011 * as published by the Free Software Foundation; either version 2 00012 * of the License, or (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 * 00023 * Authors: 00024 * Kedar V. Khandeparkar <kedar.khandeparkar@gmail.com> 00025 * Nitesh Pandit <panditnitesh@gmail.com> 00026 * 00027 * ----------------------------------------------------------------------------- */ 00028 00029 00030 #define MAXBUFLEN 2000 00031 00032 00033 /* ---------------------------------------------------------------- */ 00034 /* Data Structure prototypes */ 00035 /* ---------------------------------------------------------------- */ 00036 00037 /* ---------------------------------------------------------------- */ 00038 /* Configuartion Frame Data Structure */ 00039 /* ---------------------------------------------------------------- */ 00040 00041 struct cfg_frame { 00042 00043 unsigned int framesize; 00044 unsigned int idcode; 00045 unsigned long int soc; 00046 unsigned long int fracsec; 00047 unsigned long int time_base; 00048 unsigned int num_pmu; 00049 struct for_each_pmu **pmu; 00050 unsigned int data_rate; 00051 struct cfg_frame *cfgnext; 00052 00053 }*cfgfirst; 00054 00055 00056 struct for_each_pmu{ 00057 00058 unsigned char stn[17]; 00059 unsigned int idcode; 00060 char data_format[3]; 00061 struct format *fmt; 00062 unsigned int phnmr; 00063 unsigned int annmr; 00064 unsigned int dgnmr; 00065 struct channel_names *cnext; 00066 float **phunit; 00067 float **anunit; 00068 unsigned char **dgunit; 00069 unsigned int fnom; 00070 unsigned int cfg_cnt; 00071 }; 00072 00073 struct channel_names { 00074 00075 unsigned char **phnames; 00076 unsigned char **angnames; 00077 struct dgnames *first; 00078 }; 00079 00080 struct dgnames { 00081 00082 unsigned char **dgn; // Stores 16 digital names for each word 00083 struct dgnames *dg_next; 00084 }; 00085 00086 // This struct is added to help find out whether the measurements are floating/fixed, polar/rectangular . 00087 struct format{ 00088 00089 char freq; 00090 char analog; 00091 char phasor; 00092 char polar; 00093 }; 00094 00095 00096 /* ---------------------------------------------------------------- */ 00097 /* Function prototypes */ 00098 /* ---------------------------------------------------------------- */ 00099 00100 00101 void cfgparser(unsigned char []); 00102 00103 void cfginsert(struct cfg_frame *); 00104 00105 int dataparser(unsigned char data[]); 00106 00107 char* hexTobin(char s); 00108 00109 int check_statword(unsigned char stat[]); 00110 00111 void remove_old_cfg(int idcode,unsigned char frame[]); 00112 00113 unsigned int to_intconvertor(unsigned char array[]); 00114 00115 unsigned long int to_long_int_convertor(unsigned char * array); 00116 00117 float decode_ieee_single(const void *v); 00118 00119 void copy_cbyc(unsigned char dst[],unsigned char *s,int size); 00120 00121 int ncmp_cbyc(unsigned char dst[],unsigned char src[],int size);
1.6.3