├── 2dsdump ├── .gitignore └── SConscript ├── oapinfo ├── .gitignore ├── .cvsignore └── SConscript ├── xpms2d ├── .gitignore ├── src │ ├── TODO │ ├── global.cc │ ├── ccb.cc │ ├── cb_printer.cc │ ├── cb_mag.cc │ ├── cb_canvas.cc │ ├── Makefile │ ├── cb_text.cc │ └── xpms2d.cc ├── class │ ├── Hex.h │ ├── Enchilada.h │ ├── MagnifyCanvas.h │ ├── Histogram.h │ ├── Magnify.h │ ├── PlotInfo.h │ ├── MagnifyWindow.h │ ├── CanvasWindow.h │ ├── FileMgr.h │ ├── Histogram.cc │ ├── FileMgr.cc │ ├── Colors.h │ ├── Enchilada.cc │ ├── Makefile │ ├── ControlWindow.h │ ├── MagnifyWindow.cc │ ├── Hex.cc │ ├── MagnifyCanvas.cc │ ├── define.h │ ├── Magnify.cc │ ├── MainCanvas.h │ ├── CanvasWindow.cc │ └── DataFile.h └── SConscript ├── cip ├── pads2oap │ ├── .gitignore │ ├── SConscript │ ├── pads2oap.h │ └── pads2oap.cc └── padsinfo │ ├── .gitignore │ └── SConscript ├── extract2ds ├── .gitignore ├── SConscript ├── config.cc ├── spec.h ├── particle.h └── config.h ├── process2d ├── .gitignore ├── SConscript ├── ProbeData.h ├── config.h ├── probe.cpp ├── ProbeData.cpp ├── netcdf.h └── probe.h ├── translate2ds ├── .gitignore ├── Makefile ├── Packet.h ├── SConscript ├── Mask3VCPI.h ├── README ├── log.h ├── PacketTypes.h ├── XML_header.h ├── MaskData.h ├── timestamp_ucar.h ├── merge_files.h ├── wordCounter.c ├── directory.h ├── HouseKeeping3VCPI.h ├── File.h ├── block.h ├── 2DS.h ├── 2DSParticle.h ├── Particle3VCPI.h ├── 3VCPI.h ├── CommandLine.h └── main.cc ├── .gitmodules ├── doc └── procfd2c.doc ├── .gitignore ├── usb2diag ├── usb2d.pro ├── usb2d.cc ├── DataUsb2d64.h ├── DataPlot.h ├── CanvasWindow.h ├── DataMng.h ├── DataMng.cc ├── DataPlot.cc ├── CanvasWindow.cc ├── DataUsb2d64.cc └── Makefile ├── hvpsdiag ├── DataPlot.h ├── hvps.pro ├── extern.h ├── global.cc ├── error.cc ├── define.h ├── hvpsdiag.cc ├── CanvasWindow.h ├── init.cc ├── DataPlot.cc └── CanvasWindow.cc ├── 2dssim ├── 2dlisten.py ├── readme.md └── 2dsend.py ├── Jenkinsfile ├── SConstruct ├── xpms2d.spec └── README.md /2dsdump/.gitignore: -------------------------------------------------------------------------------- 1 | /2dsdump 2 | -------------------------------------------------------------------------------- /oapinfo/.gitignore: -------------------------------------------------------------------------------- 1 | /oapinfo 2 | -------------------------------------------------------------------------------- /xpms2d/.gitignore: -------------------------------------------------------------------------------- 1 | /src/xpms2d 2 | -------------------------------------------------------------------------------- /cip/pads2oap/.gitignore: -------------------------------------------------------------------------------- 1 | /pads2oap 2 | -------------------------------------------------------------------------------- /cip/padsinfo/.gitignore: -------------------------------------------------------------------------------- 1 | /padsinfo 2 | -------------------------------------------------------------------------------- /extract2ds/.gitignore: -------------------------------------------------------------------------------- 1 | /extract2ds 2 | -------------------------------------------------------------------------------- /process2d/.gitignore: -------------------------------------------------------------------------------- 1 | /process2d 2 | -------------------------------------------------------------------------------- /translate2ds/.gitignore: -------------------------------------------------------------------------------- 1 | /translate2ds 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vardb"] 2 | path = vardb 3 | url = ../aircraft_vardb 4 | -------------------------------------------------------------------------------- /oapinfo/.cvsignore: -------------------------------------------------------------------------------- 1 | .sconsign.dblite 2 | .sconf_temp 3 | config.log 4 | oapinfo 5 | -------------------------------------------------------------------------------- /doc/procfd2c.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NCAR/aircraft_oap/master/doc/procfd2c.doc -------------------------------------------------------------------------------- /translate2ds/Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | g++ -g -O2 main.cc -o translate2ds 3 | .PHONY: all 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ignore objects and archives, anywhere in the tree. 2 | *.[oa] 3 | *~ 4 | /.scon* 5 | /config.log 6 | -------------------------------------------------------------------------------- /xpms2d/src/TODO: -------------------------------------------------------------------------------- 1 | - printing hvps 2 | 3 | - pgFbuff needs one pre-record or something with first time stamp. Printing & 4 | pg bkwd get bogus time stamp. 5 | 6 | - Convert to Qt or merge into aeros 7 | 8 | - add options for 'size cutoff' and ' area ration' rejection. 9 | -------------------------------------------------------------------------------- /cip/pads2oap/SConscript: -------------------------------------------------------------------------------- 1 | # -*- python -*- 2 | 3 | env = Environment() 4 | 5 | env.Append(CCFLAGS='-g -Wall') 6 | 7 | sources = Split(""" 8 | pads2oap.cc 9 | """) 10 | 11 | pads2oap = env.Program(target = 'pads2oap', source = sources) 12 | env.Default(pads2oap) 13 | 14 | env.Install("$INSTALL_PREFIX/bin", 'pads2oap') 15 | -------------------------------------------------------------------------------- /cip/padsinfo/SConscript: -------------------------------------------------------------------------------- 1 | # -*- python -*- 2 | 3 | env = Environment() 4 | 5 | env.Append(CCFLAGS='-g -Wall') 6 | 7 | sources = Split(""" 8 | padsinfo.cc 9 | """) 10 | 11 | padsinfo = env.Program(target = 'padsinfo', source = sources) 12 | env.Default(padsinfo) 13 | 14 | env.Install("$INSTALL_PREFIX/bin", 'padsinfo') 15 | -------------------------------------------------------------------------------- /2dsdump/SConscript: -------------------------------------------------------------------------------- 1 | # -*- python -*- 2 | 3 | env = Environment(tools = ['default', 'raf']) 4 | env.Append(CXXFLAGS='-g -std=c++11 -Wall') 5 | 6 | sources = Split(""" 7 | 2dsdump.cc 8 | """) 9 | 10 | tdsdump=env.Program(target = '2dsdump', source = sources) 11 | env.Default(tdsdump) 12 | 13 | env.Install("$INSTALL_PREFIX/bin", '2dsdump') 14 | -------------------------------------------------------------------------------- /oapinfo/SConscript: -------------------------------------------------------------------------------- 1 | # -*- python -*- 2 | 3 | env = Environment(tools = ['default', 'raf']) 4 | env.Append(CXXFLAGS='-g -std=c++11 -Wall') 5 | 6 | sources = Split(""" 7 | oapinfo.cc 8 | """) 9 | 10 | oapinfo=env.Program(target = 'oapinfo', source = sources) 11 | env.Default(oapinfo) 12 | 13 | env.Install("$INSTALL_PREFIX/bin", 'oapinfo') 14 | -------------------------------------------------------------------------------- /translate2ds/Packet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "common.h" 3 | #include 4 | namespace sp 5 | { 6 | class Log; 7 | 8 | struct Packet 9 | { 10 | Word PacketID; 11 | }; 12 | 13 | template 14 | inline T& operator >> (T& reader, Packet& in) 15 | { 16 | reader >> in.PacketID; 17 | return reader; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /translate2ds/SConscript: -------------------------------------------------------------------------------- 1 | #!python 2 | 3 | env = Environment(tools=['default', 'raf']) 4 | 5 | env.Append(CXXFLAGS='-g -std=c++11 -Wall') 6 | 7 | sources = Split(""" 8 | main.cc 9 | """) 10 | 11 | 12 | translate2ds = env.Program(target = 'translate2ds', source = sources) 13 | env.Default(translate2ds) 14 | 15 | env.Install("$INSTALL_PREFIX/bin", 'translate2ds') 16 | -------------------------------------------------------------------------------- /extract2ds/SConscript: -------------------------------------------------------------------------------- 1 | # -*- python -*- 2 | 3 | env = Environment(tools = ['default', 'raf']) 4 | env.Append(CXXFLAGS='-g -std=c++11 -Wall') 5 | 6 | sources = Split(""" 7 | extract2ds.cc 8 | config.cc 9 | particle.cc 10 | """) 11 | 12 | tdsdump=env.Program(target = 'extract2ds', source = sources) 13 | env.Default(tdsdump) 14 | 15 | env.Install("$INSTALL_PREFIX/bin", 'extract2ds') 16 | -------------------------------------------------------------------------------- /translate2ds/Mask3VCPI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Packet.h" 3 | //#include 4 | namespace sp 5 | { 6 | 7 | struct MaskData3VCPI: public Packet 8 | { 9 | word _data[25]; 10 | }; 11 | 12 | template 13 | inline T& operator >> (T& reader, MaskData3VCPI& in) 14 | { 15 | reader.read(reinterpret_cast(&in._data[0]),sizeof(in._data)); 16 | in.PacketID = in._data[0]; 17 | return reader; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /process2d/SConscript: -------------------------------------------------------------------------------- 1 | # -*- python -*- 2 | 3 | tools = ['default', 'prefixoptions', 'vardb', 'raf', 'netcdfcxx4'] 4 | env = Environment(tools=tools) 5 | 6 | env.Append(CXXFLAGS='-g -std=c++11 -Wall') 7 | 8 | sources = Split(""" 9 | process2d.cpp 10 | netcdf.cpp 11 | probe.cpp 12 | ProbeData.cpp 13 | """) 14 | 15 | process2d = env.Program(target='process2d', source=sources) 16 | env.Default(process2d) 17 | env.InstallProgram('process2d') 18 | -------------------------------------------------------------------------------- /translate2ds/README: -------------------------------------------------------------------------------- 1 | Translator to translate 2DS data from the 3V-CPI into the RAF OAP file format. 2 | Decompress the data and repackages. 3 | 4 | See http://www.eol.ucar.edu/raf/Software/OAPfiles.html 5 | 6 | 7 | 2D_compat_trans_v6.zip is the original code from SPEC. 8 | It produces two output files for every input file, splitting H & V into 9 | separate files. We would prefer to have them integrated into a single 10 | file, and have all files from a directory in one file. 11 | -------------------------------------------------------------------------------- /usb2diag/usb2d.pro: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Automatically generated by qmake (1.04a) Tue Apr 8 18:49:19 2003 3 | ###################################################################### 4 | 5 | CONFIG += debug 6 | TEMPLATE = app 7 | INCLUDEPATH += . 8 | INCLUDEPATH += /opt/nidas/x86/include 9 | 10 | # Input 11 | HEADERS += CanvasWindow.h DataMng.h DataUsb2d64.h DataPlot.h 12 | SOURCES += CanvasWindow.cc DataMng.cc DataUsb2d64.cc DataPlot.cc usb2d.cc 13 | -------------------------------------------------------------------------------- /hvpsdiag/DataPlot.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "define.h" 4 | #include 5 | 6 | 7 | class QwtPlotCurve; 8 | 9 | /* -------------------------------------------------------------------- */ 10 | class DataPlot : public QwtPlot 11 | { 12 | public: 13 | DataPlot(QWidget *, ADS_rtFile *); 14 | 15 | void ToggleFreeze(); 16 | 17 | protected: 18 | virtual void timerEvent(QTimerEvent *e); 19 | 20 | private: 21 | QwtPlotCurve * crv1, * crv2; 22 | bool freeze; 23 | ADS_rtFile *file; 24 | 25 | }; 26 | 27 | -------------------------------------------------------------------------------- /translate2ds/log.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | namespace sp 6 | { 7 | class Log 8 | { 9 | public: 10 | Log(const char* file_name = "log.txt"): _out(file_name) 11 | { 12 | 13 | } 14 | ~Log(void) 15 | { 16 | _out.close(); 17 | } 18 | 19 | template 20 | Log& operator << (const T& obj) 21 | { 22 | std::cout << obj; 23 | 24 | _out << obj; 25 | return *this; 26 | } 27 | 28 | private: 29 | 30 | std::ofstream _out; 31 | }; 32 | 33 | } 34 | 35 | extern sp::Log g_Log; 36 | -------------------------------------------------------------------------------- /2dssim/2dlisten.py: -------------------------------------------------------------------------------- 1 | import socket 2 | 3 | def listen_for_udp(port=5000): 4 | """Listen for incoming UDP packets.""" 5 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 6 | sock.bind(('0.0.0.0', port)) 7 | print(f"Listening for UDP packets on port {port}...") 8 | 9 | try: 10 | while True: 11 | data, addr = sock.recvfrom(4096) 12 | print(f"Received {len(data)} bytes from {addr}") 13 | except KeyboardInterrupt: 14 | print("Stopped listening") 15 | finally: 16 | sock.close() 17 | 18 | # Start listening 19 | listen_for_udp(5000) -------------------------------------------------------------------------------- /hvpsdiag/hvps.pro: -------------------------------------------------------------------------------- 1 | ###################################################################### 2 | # Automatically generated by qmake (1.04a) Tue Apr 8 18:49:19 2003 3 | ###################################################################### 4 | 5 | QWT_DIR = /opt/local/aeros/qwt-5.0 6 | CONFIG += debug 7 | TEMPLATE = app 8 | INCLUDEPATH += . 9 | INCLUDEPATH += ${JLOCAL}/include 10 | INCLUDEPATH += $${QWT_DIR}/include 11 | 12 | # Input 13 | HEADERS += CanvasWindow.h DataPlot.h define.h extern.h 14 | SOURCES += CanvasWindow.cc DataPlot.cc error.cc global.cc hvpsdiag.cc init.cc 15 | LIBS += -L${JLOCAL}/lib -lraf -L$${QWT_DIR}/lib -lqwt 16 | -------------------------------------------------------------------------------- /xpms2d/class/Hex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Hex.h 4 | 5 | FULL NAME: View Hex 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 2000-2018 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef HEX_H 12 | #define HEX_H 13 | 14 | #include 15 | #include 16 | 17 | 18 | /* -------------------------------------------------------------------- */ 19 | class Hex : public TextWindow 20 | { 21 | public: 22 | Hex(const Widget parent); 23 | 24 | void Update(size_t nBuffs, OAP::P2d_rec sets[]); 25 | 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent { 3 | node { 4 | label 'CentOS9_x86_64' 5 | } 6 | } 7 | triggers { 8 | pollSCM('H/15 6-21 * * *') 9 | } 10 | stages { 11 | stage('Build') { 12 | steps { 13 | sh 'git submodule update --init --recursive vardb' 14 | sh 'scons' 15 | } 16 | } 17 | } 18 | post { 19 | failure { 20 | emailext to: "cjw@ucar.edu janine@ucar.edu cdewerd@ucar.edu", 21 | subject: "Jenkinsfile aircraft_oap build failed", 22 | body: "See console output attached", 23 | attachLog: true 24 | } 25 | } 26 | options { 27 | buildDiscarder(logRotator(numToKeepStr: '10')) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /hvpsdiag/extern.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: extern.h 4 | 5 | FULL NAME: Global Variable External Declarations 6 | 7 | DESCRIPTION: 8 | 9 | AUTHOR: websterc@ncar 10 | ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef EXTERN_H 14 | #define EXTERN_H 15 | 16 | extern bool Grid, Frozen, FlashMode; 17 | 18 | extern char buffer[], DataPath[], *ProjectName, FlightNumber[]; 19 | 20 | extern int NumberDataSets, NumberSeconds, NumberElements[], CurrentDataSet; 21 | extern int Aircraft; 22 | 23 | extern double *plotData, *xData; 24 | 25 | #endif 26 | 27 | /* END EXTERN.H */ 28 | -------------------------------------------------------------------------------- /2dssim/readme.md: -------------------------------------------------------------------------------- 1 | # 2DS UDP Simulator 2 | 3 | ## Usage 4 | 5 | `python 2dsend.py /path/to/file.F2DS [--ip IP_ADDRESS] [--port PORT] [--delay SECONDS] [--data-only]` 6 | For testing, it is set up to send the file back to your IP on port 5000. You can run the 2dlisten.py to ensure it's reading the 4096 byte data package. 7 | `python 2dlisten.py` 8 | 9 | 10 | 11 | ## Arguments 12 | - **filename**: Path to the OAP file to stream 13 | - **--ip**: Target IP address (default: `127.0.0.1`) 14 | - **--port**: Target port number (default: `5000`) 15 | - **--delay**: Delay between packets in seconds (default: `0.2`) 16 | - **--data-only**: Send only the 4096-byte data portion instead of the full 4114-byte record -------------------------------------------------------------------------------- /xpms2d/class/Enchilada.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Enchilada.h 4 | 5 | FULL NAME: View Enchilada 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 2000-2018 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef ENCHILADA_H 12 | #define ENCHILADA_H 13 | 14 | #include 15 | #include 16 | 17 | 18 | /* -------------------------------------------------------------------- */ 19 | class Enchilada : public TextWindow 20 | { 21 | public: 22 | Enchilada(const Widget parent); 23 | 24 | void AddLineItem(int cnt, OAP::Particle *cp); 25 | 26 | }; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /usb2diag/usb2d.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: usb2d.c 4 | 5 | COPYRIGHT: University Corporation for Atmospheric Research, 2007 6 | ------------------------------------------------------------------------- 7 | */ 8 | 9 | #include "CanvasWindow.h" 10 | 11 | #include 12 | 13 | 14 | int main(int argc, char *argv[]) 15 | { 16 | QApplication app(argc, argv); 17 | 18 | CanvasWindow * canvasWindow = new CanvasWindow(&app, argc > 1 ? argv[1] : 0); 19 | canvasWindow->show(); 20 | 21 | app.setMainWidget(canvasWindow); 22 | canvasWindow->setCaption("USB_2d"); 23 | canvasWindow->resize(1054, 800); 24 | 25 | app.exec(); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /usb2diag/DataUsb2d64.h: -------------------------------------------------------------------------------- 1 | #ifndef _DataUsb2d64_h_ 2 | #define _DataUsb2d64_h_ 3 | 4 | #define _LARGEFILE64_SOURCE 5 | #include "DataMng.h" 6 | 7 | 8 | #define _FILE_OFFSET_BITS 64 9 | /* -------------------------------------------------------------------- */ 10 | /** 11 | * Class to mng PMS-2D 64 bit data. 12 | */ 13 | class DataUsb2d64: public DataMng 14 | { 15 | 16 | public: 17 | DataUsb2d64 ( FILE * fp); 18 | virtual ~DataUsb2d64() {} 19 | 20 | virtual QPointArray* GetPoints(); 21 | 22 | private: 23 | virtual void _getRecord(int x, int y, unsigned char* data_p); 24 | virtual void _get2drec(); 25 | QString _gettw(unsigned long long t); 26 | static const unsigned long long _syncMask, _syncWord; 27 | 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /xpms2d/src/global.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: global.cc 4 | 5 | FULL NAME: Global Variable Definitions 6 | 7 | DESCRIPTION: extern.h should look just like this. 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #include "define.h" 12 | 13 | bool DataChanged; /* New data was read from file. */ 14 | bool UTCseconds; /* Seconds since midnight vs. HH:MM:SS */ 15 | 16 | char DataPath[PATH_LEN], pngPath[PATH_LEN], psPath[PATH_LEN]; 17 | 18 | 19 | /* Time stuff */ 20 | int UserStartTime[4], UserEndTime[4]; /* HH:MM:SS, 4th is seconds*/ 21 | int MinStartTime[4], MaxEndTime[4]; /* since midnight. */ 22 | 23 | 24 | /* END GLOBAL.CC */ 25 | -------------------------------------------------------------------------------- /xpms2d/class/MagnifyCanvas.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: MagnifyCanvas.h 4 | 5 | FULL NAME: Magnify canvas 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef MAGCANVAS_H 12 | #define MAGCANVAS_H 13 | 14 | #include 15 | 16 | #include 17 | 18 | 19 | /* -------------------------------------------------------------------- */ 20 | class MagnifyCanvas : public Canvas { 21 | 22 | public: 23 | MagnifyCanvas(Widget w); 24 | 25 | void draw(); 26 | 27 | 28 | private: 29 | 30 | }; /* END MAGNIFYCANVAS.H */ 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /translate2ds/PacketTypes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace sp 4 | { 5 | enum PacketType 6 | { 7 | HOUSEKEEPING = 0x484b, //HK (0x484b = HK in ASCII) 8 | MASK = 0x4d4b, //MK 9 | DATA = 0x3253, //2S particle marker (NOT record marker) 10 | FLUSH = 0x4e4c, //NL 11 | TAS_H = 0x5454, //tt 12 | TAS_V = 0x4141, //aa 13 | 14 | H_PARTICLE = 0x4848, //HH 15 | V_PARTICLE = 0x5656, //VV 16 | 17 | H_DEADTIME = 0x6C6C, //LL 18 | V_DEADTIME = 0x7C7C, //ll 19 | 20 | H_MASK = 0x1C1C, //FSFS 21 | V_MASK = 0x2C2C, //,, 22 | 23 | V_DUMMY_DEADTIME = 0x1414, 24 | H_DUMMY_DEADTIME = 0x1424, 25 | 26 | V_BACKUP_DEADTIME = 0x2414, 27 | H_BACKUP_DEADTIME = 0x2424, 28 | 29 | V_STREAKER = 0x1818, 30 | H_STREAKER = 0x1919 31 | }; 32 | } 33 | -------------------------------------------------------------------------------- /xpms2d/class/Histogram.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Histogram.h 4 | 5 | FULL NAME: View Histogram Data 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 2000-2018 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef HISTOGRAM_H 12 | #define HISTOGRAM_H 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | /* -------------------------------------------------------------------- */ 20 | class Histogram : public TextWindow 21 | { 22 | public: 23 | Histogram(const Widget parent); 24 | 25 | void AddLineItem(OAP::P2d_rec * record, struct OAP::recStats & stats); 26 | 27 | }; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /hvpsdiag/global.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: global.c 4 | 5 | FULL NAME: Global Variable Definitions 6 | 7 | DESCRIPTION: extern.h should look just like this. 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #include "define.h" 12 | 13 | bool Grid, /* Overlay grid on graph? */ 14 | Frozen, 15 | FlashMode; 16 | 17 | char buffer[BUFFSIZE], DataPath[1024], *ProjectName, FlightNumber[32]; 18 | 19 | 20 | /* Vars related to data sets */ 21 | int NumberDataSets, NumberSeconds, CurrentDataSet, Aircraft; 22 | 23 | /* Data record pointers 24 | */ 25 | double *plotData, *xData; 26 | 27 | float HDRversion; 28 | 29 | int FlightDate[3]; // Dummy. Here to shut linker up. 30 | 31 | /* END GLOBAL.CC */ 32 | -------------------------------------------------------------------------------- /hvpsdiag/error.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: error.c 4 | 5 | FULL NAME: Handle Errors 6 | 7 | DESCRIPTION: This procudures displays errors based on wether we are in 8 | interactive mode or not. For interactive mode it displays 9 | an X window, otherwise a fprintf to stderr. The second 10 | parameter tells the procedure wether to return or do an 11 | exit. 12 | 13 | INPUT: Message, Weather to exit or return. 14 | 15 | OUTPUT: Error message. 16 | 17 | AUTHOR: websterc@ncar 18 | ------------------------------------------------------------------------- 19 | */ 20 | 21 | #include "define.h" 22 | 23 | void HandleError(char s[]) 24 | { 25 | fprintf(stderr, "%s\n", s); 26 | exit(1); 27 | 28 | } /* END HANDLERROR */ 29 | 30 | /* END ERROR.C */ 31 | -------------------------------------------------------------------------------- /xpms2d/class/Magnify.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Magnify.h 4 | 5 | FULL NAME: Magnify window and Zoom 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef MAGNIFY_H 12 | #define MAGNIFY_H 13 | 14 | #include 15 | 16 | 17 | /* -------------------------------------------------------------------- */ 18 | class Magnify { 19 | 20 | public: 21 | Magnify(); 22 | 23 | void DrawBox(XMotionEvent *evt); 24 | void ProcessInput(XmDrawingAreaCallbackStruct *evt); 25 | 26 | int startX, startY; 27 | int endX, endY; 28 | int width, height; 29 | 30 | 31 | private: 32 | void RemoveBox(); 33 | 34 | }; /* END MAGNIFY.H */ 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /translate2ds/XML_header.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "log.h" 5 | 6 | namespace sp 7 | { 8 | //UCAR XML header 9 | struct XMLHeader 10 | { 11 | std::string _header; 12 | }; 13 | 14 | template 15 | inline T& operator >> (T& reader, XMLHeader& in) 16 | { 17 | std::vector buf; 18 | const char* xml_end = "\n"; 19 | char t = 0; 20 | int max_loops = 100000; //so we don't go forever on invalid file 21 | 22 | while (max_loops-- && !reader.empty()) 23 | { 24 | reader.read(reinterpret_cast(&t),sizeof(t)); 25 | in._header += t; 26 | 27 | if(in._header.find(xml_end) != std::string::npos) 28 | { 29 | break; 30 | } 31 | } 32 | if(max_loops == 0 || reader.empty()) 33 | { 34 | g_Log <<"ERROR reading XML header, could not find end of XML\n"; 35 | } 36 | 37 | return reader; 38 | }; 39 | } 40 | -------------------------------------------------------------------------------- /xpms2d/class/PlotInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: PlotInfo.h 4 | 5 | FULL NAME: Plot Information 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef PLOTINFO_H 12 | #define PLOTINFO_H 13 | 14 | #include 15 | 16 | #define TITLESIZE 80 17 | 18 | 19 | /* -------------------------------------------------------------------- */ 20 | class PlotInfo { 21 | 22 | public: 23 | PlotInfo(); 24 | ~PlotInfo(); 25 | 26 | const char * Title() const { return(title); } 27 | const char * SubTitle() const { return(subTitle); } 28 | 29 | void GenerateDefaultTitles(); 30 | 31 | 32 | private: 33 | char title[TITLESIZE], subTitle[TITLESIZE]; 34 | 35 | 36 | }; /* END PLOTINFO.H */ 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /hvpsdiag/define.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: define.h 4 | 5 | FULL NAME: Include File to Include the Include Files 6 | 7 | DESCRIPTION: 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef DEFINE_H 12 | #define DEFINE_H 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #define CONSTANTS_H 22 | #define NAMLEN 13 23 | 24 | #define BUFFSIZE 2048 25 | #define PATH_LEN 1024 26 | 27 | #define SPACE ' ' 28 | 29 | #define TITLESIZE 128 30 | #define LEGENDSIZE (TITLESIZE<<1) 31 | 32 | #define NUMTICMARKS 10 33 | 34 | /* Defines for 'Mode' */ 35 | #define COUNTS 0 36 | #define VOLTS 1 37 | #define ENGINEERING 2 38 | 39 | #include "extern.h" 40 | 41 | #endif 42 | 43 | /* END DEFINE.H */ 44 | -------------------------------------------------------------------------------- /process2d/ProbeData.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | /** 5 | * Class to contain and manage data blocks for computed variables/data. 6 | */ 7 | class ProbeData 8 | { 9 | public: 10 | struct derived 11 | { 12 | std::vector accepted; // Counts of accepted particles. 13 | std::vector rejected; // Counts of rejected particles. 14 | std::vector total_conc, dbz, dbar, disp, lwc, eff_rad; 15 | std::vector total_conc100, total_conc150; 16 | }; 17 | 18 | ProbeData(size_t size); 19 | 20 | void ReplaceNANwithMissingData(); 21 | 22 | int size() const { return _size; } 23 | 24 | std::vector tas; 25 | std::vector cpoisson1, cpoisson2, cpoisson3; 26 | std::vector pcutoff, corrfac; 27 | 28 | struct derived all, round; 29 | 30 | protected: 31 | // Number of seconds we are processing / writing into the netCDF file. 32 | int _size; 33 | }; 34 | -------------------------------------------------------------------------------- /xpms2d/class/MagnifyWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: MagnifyWindow.h 4 | 5 | FULL NAME: Magnify window and Zoom 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef MAGWINDOW_H 12 | #define MAGWINDOW_H 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | 24 | /* -------------------------------------------------------------------- */ 25 | class MagnifyWindow : public WinForm { 26 | 27 | public: 28 | MagnifyWindow(Widget parent); 29 | 30 | Widget DrawingArea() const { return(drawA); } 31 | 32 | 33 | private: 34 | Widget drawA; 35 | 36 | }; /* END MAGNIFYWINDOW.H */ 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /xpms2d/class/CanvasWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: CanvasWindow.h 4 | 5 | FULL NAME: Create Main Canvas Window 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 1997 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef CANWINDOW_H 12 | #define CANWINDOW_H 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | /* -------------------------------------------------------------------- */ 26 | class CanvasWindow : public WinForm { 27 | 28 | public: 29 | CanvasWindow(const Widget parent); 30 | 31 | Widget DrawingArea() const 32 | { return(drawA); } 33 | 34 | 35 | private: 36 | Widget drawA; 37 | 38 | }; /* END CANVASWINDOW.H */ 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /hvpsdiag/hvpsdiag.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: rtplot.c 4 | 5 | FULL NAME: Real Time Plot (Counts & Volts). 6 | 7 | TYPE: X11/R6 Qt 8 | 9 | DESCRIPTION: See man page 10 | 11 | INPUT: Command line options 12 | 13 | COPYRIGHT: University Corporation for Atmospheric Research, 2003 14 | ------------------------------------------------------------------------- 15 | */ 16 | 17 | #include "CanvasWindow.h" 18 | 19 | #include 20 | 21 | CanvasWindow *canvasWindow; 22 | 23 | /* --------------------------------------------------------------------- */ 24 | int main(int argc, char *argv[]) 25 | { 26 | QApplication app(argc, argv); 27 | 28 | canvasWindow = new CanvasWindow(&app); 29 | canvasWindow->show(); 30 | 31 | app.setMainWidget(canvasWindow); 32 | canvasWindow->setCaption("hvpsdiag"); 33 | canvasWindow->resize(900, 525); 34 | 35 | app.exec(); 36 | 37 | return(0); 38 | 39 | } /* END MAIN */ 40 | 41 | /* END RTPLOT.CC */ 42 | -------------------------------------------------------------------------------- /usb2diag/DataPlot.h: -------------------------------------------------------------------------------- 1 | #ifndef _DataPlot_h_ 2 | #define _DataPlot_h_ 3 | 4 | #include "DataUsb2d64.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | 14 | /* -------------------------------------------------------------------- */ 15 | /** 16 | * Class to plot/draw PMS-2D ercords on a Qt Widget. 17 | */ 18 | class DataPlot: public QWidget 19 | { 20 | public: 21 | DataPlot(QWidget * parent, FILE * fp); 22 | virtual ~DataPlot() { if (dm !=NULL) {delete dm;}} 23 | 24 | void Plot(bool pnew=true); 25 | void ToggleFreeze(); 26 | void RstTimer(int s); 27 | void Prt(); 28 | 29 | protected: 30 | virtual void timerEvent(QTimerEvent * e); 31 | 32 | virtual void paintEvent(QPaintEvent * e); 33 | 34 | 35 | private: 36 | bool _freeze; 37 | DataUsb2d64* dm; 38 | void _drawIt(); 39 | 40 | QPrinter _printer; 41 | QPainter _painter; 42 | int _count; 43 | int _c; 44 | 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /SConstruct: -------------------------------------------------------------------------------- 1 | #!python 2 | 3 | # This SConstruct orchestrates building OAP programs. 4 | 5 | import os 6 | import sys 7 | sys.path.append(os.path.abspath('vardb/site_scons')) 8 | import eol_scons 9 | 10 | 11 | def OAP_utils(env): 12 | env.Require(['prefixoptions']) 13 | 14 | env = Environment(GLOBAL_TOOLS = [OAP_utils]) 15 | env['PUBLISH_PREFIX'] = '/net/www/docs/raf/Software' 16 | 17 | 18 | env.Require('vardb') 19 | 20 | subdirs = ['2dsdump', 'cip/pads2oap', 'cip/padsinfo', 'extract2ds', 'oapinfo', 'xpms2d', 'process2d'] 21 | 22 | for subdir in subdirs: 23 | SConscript(os.path.join(subdir, 'SConscript')) 24 | 25 | variables = env.GlobalVariables() 26 | variables.Update(env) 27 | Help(variables.GenerateHelpText(env)) 28 | 29 | if "xpms2d" in COMMAND_LINE_TARGETS: 30 | subdirs = ['xpms2d'] 31 | 32 | if "publish" in COMMAND_LINE_TARGETS: 33 | pub = env.Install('$PUBLISH_PREFIX', ["doc/OAPfiles.html"]) 34 | env.Alias('publish', pub) 35 | 36 | env.SetHelp() 37 | env.AddHelp(""" 38 | Targets: 39 | publish: Copy html documentation to EOL web space : $PUBLISH_PREFIX. 40 | """) 41 | -------------------------------------------------------------------------------- /xpms2d/src/ccb.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: ccb.c 4 | 5 | FULL NAME: Misc. Callback Wrappers 6 | 7 | ENTRY POINTS: DismissWindow() 8 | DestroyWindow() 9 | 10 | STATIC FNS: 11 | 12 | DESCRIPTION: 13 | 14 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 15 | ------------------------------------------------------------------------- 16 | */ 17 | 18 | #include "define.h" 19 | 20 | 21 | /* -------------------------------------------------------------------- */ 22 | void DestroyWindow(Widget w, XtPointer client, XtPointer call) 23 | { 24 | XtPopdown(XtParent((Widget)client)); 25 | XtUnmanageChild((Widget)client); 26 | 27 | XtDestroyWidget((Widget)client); 28 | 29 | } /* END DESTROYWINDOW */ 30 | 31 | /* -------------------------------------------------------------------- */ 32 | void DismissWindow(Widget w, XtPointer client, XtPointer call) 33 | { 34 | XtPopdown(XtParent((Widget)client)); 35 | XtUnmanageChild((Widget)client); 36 | 37 | } /* END DISMISSWINDOW */ 38 | 39 | /* END CCB.C */ 40 | -------------------------------------------------------------------------------- /translate2ds/MaskData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Packet.h" 3 | //#include 4 | namespace sp 5 | { 6 | struct MaskBits 7 | { 8 | Word one,two,three, four,five, six,seven, eight; 9 | }; 10 | 11 | // static_assert(sizeof(MaskBits) == 8*2, "MaskBits wrong size"); 12 | 13 | template 14 | inline T& operator >> (T& reader, MaskBits& in) 15 | { 16 | reader >> in.one >> in.two >> in.three >> in.four >> in.five >> in.six >> in.seven >> in.eight; 17 | return reader; 18 | } 19 | 20 | struct MaskData: public Packet 21 | { 22 | Timing Time; 23 | 24 | //enum 25 | //{ 26 | // BitWords = 11 - 4 27 | //}; 28 | // typedef std::bitset MaskBits; 29 | 30 | MaskBits Horizontal; 31 | MaskBits Vertical; 32 | Timing StartTime; 33 | Timing EndTime; 34 | 35 | }; 36 | 37 | 38 | //static_assert(sizeof(MaskData) == 24*2, "Mask Data wrong size"); 39 | 40 | template 41 | inline T& operator >> (T& reader, MaskData& in) 42 | { 43 | reader >> in.Time >> in.Horizontal >> in.Vertical >> in.StartTime >> in.EndTime; 44 | return reader; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /hvpsdiag/CanvasWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: CanvasWindow.h 4 | 5 | FULL NAME: Create Main Canvas Window 6 | 7 | TYPE: 8 | 9 | DESCRIPTION: 10 | 11 | NOTES: 12 | 13 | COPYRIGHT: University Corporation for Atmospheric Research, 2003 14 | ------------------------------------------------------------------------- 15 | */ 16 | 17 | #ifndef CANWINDOW_H 18 | #define CANWINDOW_H 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | #include "define.h" 32 | #include "DataPlot.h" 33 | 34 | 35 | /* -------------------------------------------------------------------- */ 36 | class CanvasWindow : public QMainWindow 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | CanvasWindow(QApplication *); 42 | 43 | protected slots: 44 | void Print(); 45 | 46 | private: 47 | DataPlot *plot; 48 | 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /translate2ds/timestamp_ucar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Packet.h" 4 | #include "log.h" 5 | 6 | namespace sp 7 | { 8 | //UCAR timestamp, data is in Big Endian Format 9 | struct TimestampUCAR 10 | { 11 | word CharacterCode; 12 | Word Hour; 13 | Word Minute; 14 | Word Second; 15 | Word Year; 16 | Word Month; 17 | Word Day; 18 | word TAS; 19 | Word Milliseconds; 20 | word overload; 21 | 22 | TimeStamp16 As2DSTimeStamp() const 23 | { 24 | TimeStamp16 ts; 25 | ts.wDay = swap_endian(Day); 26 | ts.wYear = swap_endian(Year); 27 | ts.wMonth = swap_endian(Month); 28 | ts.wSecond = swap_endian(Second); 29 | ts.wMilliseconds = swap_endian(Milliseconds); 30 | ts.wHour = swap_endian(Hour); 31 | ts.wMinute = swap_endian(Minute); 32 | ts.wDayOfWeek = 0; 33 | return ts; 34 | 35 | } 36 | }; 37 | 38 | template 39 | inline T& operator >> (T& reader, TimestampUCAR& in) 40 | { 41 | reader >> in.CharacterCode >> in.Hour >> in.Minute >> in.Second >> in .Year >> in.Month >> in.Day >> in.TAS >> in.Milliseconds >> in.overload; 42 | 43 | return reader; 44 | }; 45 | } 46 | -------------------------------------------------------------------------------- /usb2diag/CanvasWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: CanvasWindow.h 4 | 5 | COPYRIGHT: University Corporation for Atmospheric Research, 2007 6 | ------------------------------------------------------------------------- 7 | */ 8 | 9 | #ifndef _CanvasWindow_h_ 10 | #define _CanvasWindow_h_ 11 | 12 | #include "DataPlot.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | 25 | /* -------------------------------------------------------------------- */ 26 | class CanvasWindow : public QMainWindow 27 | { 28 | Q_OBJECT 29 | 30 | public: 31 | CanvasWindow(QApplication *, const char * file_name); 32 | 33 | protected slots: 34 | void _print(); 35 | void _openf(); 36 | void _rstTimer(); 37 | 38 | private: 39 | FILE * _fp; 40 | QApplication* _app; 41 | char* _fn; 42 | QPrinter _printer; 43 | 44 | DataPlot * _plot; 45 | void _startplot(); 46 | 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /xpms2d/class/FileMgr.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: FileMgr.h 4 | 5 | FULL NAME: Data File Manager 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef FILEMGR_H 12 | #define FILEMGR_H 13 | 14 | #include 15 | 16 | #include 17 | 18 | namespace OAP 19 | { 20 | class UserConfig; 21 | } 22 | 23 | /* -------------------------------------------------------------------- */ 24 | class FileManager { 25 | 26 | public: 27 | FileManager(); 28 | 29 | void NewFile(char fileName[], OAP::UserConfig &cfg); 30 | void AddFile(char fileName[], OAP::UserConfig &cfg); 31 | 32 | void SetCurrentFile(int newFile) { currentFile = newFile; } 33 | 34 | size_t NumberOfFiles() const { return(numberFiles); } 35 | 36 | ADS_DataFile *CurrentFile() 37 | { return(numberFiles == 0 ? (ADS_DataFile *)NULL : dataFile[currentFile]); } 38 | 39 | ADS_DataFile *dataFile[MAX_DATAFILES]; 40 | 41 | 42 | private: 43 | int numberFiles; 44 | int currentFile; 45 | 46 | }; /* END FILEMGR.H */ 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /extract2ds/config.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: config.cc 4 | 5 | COPYRIGHT: University Corporation for Atmospheric Research, 2023 6 | ------------------------------------------------------------------------- 7 | */ 8 | 9 | #include "config.h" 10 | 11 | #include 12 | 13 | 14 | 15 | /* -------------------------------------------------------------------- */ 16 | Config::Config() : _code("SH"), _type("F2DS"), _timeOffset(0), _stuckBitRejection(true), _storeCompressed(false), _resolution(10), _nDiodes(128), _clockFreq(20), _waveLength(785) 17 | 18 | { 19 | 20 | } 21 | 22 | void Config::SetType(std::string s) 23 | { 24 | _type = s; 25 | 26 | printf("Setting SPEC probe type to %s\n", s.c_str()); 27 | 28 | if (_type.compare("F2DS") == 0) 29 | { 30 | _code = "SH"; 31 | _resolution = 10; 32 | _nDiodes = 128; 33 | _clockFreq = 20; 34 | _waveLength = 785; 35 | _dataFormat = Type48; 36 | } 37 | 38 | if (_type.compare("HVPS") == 0) 39 | { 40 | _code = "H1"; 41 | _resolution = 150; 42 | _nDiodes = 128; 43 | _clockFreq = 20; 44 | _waveLength = 785; 45 | _dataFormat = Type32; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /xpms2d/class/Histogram.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Histogram.cc 4 | 5 | COPYRIGHT: University Corporation for Atmospheric Research, 2000-2018 6 | ------------------------------------------------------------------------- 7 | */ 8 | 9 | #include "Histogram.h" 10 | 11 | 12 | /* -------------------------------------------------------------------- */ 13 | Histogram::Histogram(const Widget parent) : TextWindow(parent, "histogram") 14 | { 15 | } 16 | 17 | /* -------------------------------------------------------------------- */ 18 | void Histogram::AddLineItem(OAP::P2d_rec * record, struct OAP::recStats & stats) 19 | { 20 | char buffer[2000]; 21 | 22 | snprintf(buffer, 2000, "%c%c %02d:%02d:%02d.%03d ", 23 | ((char *)&record->id)[0], ((char *)&record->id)[1], 24 | record->hour, record->minute, record->second, record->msec 25 | ); 26 | Append(buffer); 27 | 28 | size_t n = ((char *)&record->id)[1] > 51 ? 64 : 32; 29 | 30 | for (size_t i = 1; i <= n; ++i) 31 | { 32 | snprintf(buffer, 2000, "%4d", stats.accum[i]); 33 | Append(buffer); 34 | } 35 | snprintf(buffer, 2000, ", total=%6d, accepted=%6d\n", stats.nTimeBars, stats.nonRejectParticles); 36 | Append(buffer); 37 | } 38 | -------------------------------------------------------------------------------- /xpms2d/src/cb_printer.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: cb_printer.cc 4 | 5 | FULL NAME: Callbacks to PrinterSetup 6 | 7 | ENTRY POINTS: EditPrintParms() 8 | ApplyPrintParms() 9 | SetPrinterName() 10 | 11 | DESCRIPTION: none 12 | 13 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 14 | ------------------------------------------------------------------------- 15 | */ 16 | 17 | #include 18 | 19 | extern Printer *printerSetup; 20 | 21 | 22 | /* -------------------------------------------------------------------- */ 23 | void EditPrintParms(Widget w, XtPointer client, XtPointer call) 24 | { 25 | printerSetup->PopUp(); 26 | 27 | } /* END EDITPRINTPARMS */ 28 | 29 | /* -------------------------------------------------------------------- */ 30 | void ApplyPrintParms(Widget w, XtPointer client, XtPointer call) 31 | { 32 | printerSetup->ApplyParms(); 33 | 34 | } /* END APPLYPRINTPARMS */ 35 | 36 | /* -------------------------------------------------------------------- */ 37 | void SetPrinterName(Widget w, XtPointer client, XtPointer call) 38 | { 39 | printerSetup->SetPrinter((long)client); 40 | 41 | } /* END SETPRINTERNAME */ 42 | 43 | /* END CB_PRINTER.CC */ 44 | -------------------------------------------------------------------------------- /process2d/config.h: -------------------------------------------------------------------------------- 1 | #ifndef _config_h_ 2 | #define _config_h_ 3 | 4 | #include 5 | #include 6 | 7 | /** 8 | * Command line options / program configuration 9 | */ 10 | class Config 11 | { 12 | public: 13 | 14 | /** 15 | * Effective Area Width computation method, or rejection algorithm. 16 | */ 17 | enum Method { ENTIRE_IN, CENTER_IN, RECONSTRUCTION }; 18 | 19 | /** 20 | * Sizing method: along X, or Y axis, or perform circle fit (the default). 21 | */ 22 | enum SizeMethod { CIRCLE, X, Y, EQUIV_AREA_DIAM }; 23 | 24 | Config() : nInterarrivalBins(40), firstBin(0), shattercorrect(true), eawmethod(CENTER_IN), smethod(CIRCLE), verbose(false), debug(false) {} 25 | 26 | std::string inputFile; 27 | std::string outputFile; 28 | 29 | std::string platform; 30 | std::string project; 31 | std::string flightDate; 32 | std::string flightNumber; 33 | 34 | std::string user_starttime; 35 | std::string user_stoptime; 36 | 37 | time_t starttime; 38 | time_t stoptime; 39 | 40 | int nInterarrivalBins; 41 | 42 | int firstBin; 43 | 44 | bool shattercorrect; 45 | Method eawmethod; // Particle reconstruction, all-in, center-in 46 | SizeMethod smethod; // Sizing method. 47 | 48 | bool verbose; 49 | bool debug; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /translate2ds/merge_files.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "common.h" 5 | #include "log.h" 6 | 7 | namespace sp 8 | { 9 | void AppendFile(std::ifstream& in, std::ofstream& out) 10 | { 11 | enum 12 | { 13 | BYTES_PER_READ = 1000, 14 | }; 15 | 16 | byte buffer[BYTES_PER_READ]; 17 | 18 | while(true) 19 | { 20 | in.read(reinterpret_cast(buffer), BYTES_PER_READ); 21 | std::streamsize count = in.gcount(); 22 | out.write(reinterpret_cast(buffer),count); 23 | 24 | if(count != BYTES_PER_READ) 25 | break; 26 | } 27 | } 28 | 29 | bool MergeFiles(const std::string& file1, const std::string& file2, const std::string& new_file_name) 30 | { 31 | std::ifstream tf1(file1.c_str(), std::ios::binary); 32 | std::ifstream tf2(file2.c_str(), std::ios::binary); 33 | 34 | std::ofstream file(new_file_name.c_str(),std::ios::binary); 35 | 36 | std::cout << " Merging into : " << new_file_name << std::endl; 37 | 38 | if(!tf1.is_open() || !tf2.is_open() || !file.is_open()) 39 | { 40 | g_Log << "Merge files failed with " << file1 <<", "<< file2 <<", "<< new_file_name<<"\n"; 41 | return false; 42 | } 43 | 44 | AppendFile(tf1,file); 45 | AppendFile(tf2,file); 46 | 47 | return true; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /translate2ds/wordCounter.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int argc, char* argv[]) { 6 | int base_file; 7 | short word; 8 | int read_bytes = 1; 9 | 10 | short Housekeeping = 0; //0x484b; 11 | short Mask = 0; //0x4d4b; 12 | short Data = 0; //0x3253; 13 | short Flush = 0; //0x4e4c; 14 | short TAS_H = 0; //0x5454; 15 | short TAS_V = 0; //0x4141; 16 | 17 | 18 | 19 | base_file = open(argv[1], O_RDONLY); 20 | 21 | while (read_bytes > 0){ 22 | read_bytes = read(base_file, &word, sizeof(word)); 23 | //printf("%04x\n", word); 24 | 25 | switch(word){ 26 | 27 | case 0x484b: 28 | Housekeeping++; 29 | 30 | case 0x4d4b: 31 | Mask++; 32 | 33 | case 0x3253: 34 | Data++; 35 | 36 | case 0x4e4c: 37 | Flush++; 38 | 39 | case 0x5454: 40 | TAS_H++; 41 | 42 | case 0x4141: 43 | TAS_V++; 44 | } 45 | 46 | } 47 | 48 | close(base_file); 49 | 50 | printf("HouseKeeping Count: %d\n", Housekeeping); 51 | printf("Mask Count: %d\n", Mask); 52 | printf("Data Count: %d\n", Data); 53 | printf("Flush Count: %d\n", Flush); 54 | printf("TAS_H Count: %d\n", TAS_H); 55 | printf("TAS_V Count: %d\n", TAS_V); 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /translate2ds/directory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "log.h" 5 | 6 | namespace sp 7 | { 8 | void MakeDirectory(const std::string& name) 9 | { 10 | #ifdef _WIN32 11 | std::string n = "mkdir " + name; 12 | int result = system(n.c_str()); 13 | #else 14 | int result = mkdir(name.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); 15 | #endif 16 | 17 | if (result < 0) 18 | { 19 | g_Log << "Make Directory failed on \"" << name <<"\"\n"; 20 | } 21 | } 22 | 23 | int unlink_cb(const char *fpath, const struct stat *sb, int typeflag, struct FTW *ftwbuf) 24 | { 25 | int rv = remove(fpath); 26 | 27 | if (rv) 28 | perror(fpath); 29 | 30 | return rv; 31 | } 32 | 33 | int rmrf(const char *path) 34 | { 35 | return nftw(path, unlink_cb, 64, FTW_DEPTH | FTW_PHYS); 36 | } 37 | 38 | void DeleteDirectory(const std::string& name) 39 | { 40 | 41 | #ifdef _WIN32 42 | std::string n = "rmdir /s /q " + name; 43 | int result = system(n.c_str()); //windows delete temp directory 44 | // g_Log <<"WIN32\n"; 45 | #else 46 | std::string n = "rm -rf " + name; 47 | int result = rmrf(name.c_str()); 48 | // g_Log <<"NO WIN32\n"; 49 | #endif 50 | 51 | if (result < 0) 52 | { 53 | g_Log << "Delete Directory failed on \"" << name <<"\" result =" << result << "\n"; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /xpms2d/SConscript: -------------------------------------------------------------------------------- 1 | #!python 2 | 3 | env = Environment(tools = ['default', 'openmotif', 'raf']) 4 | 5 | 6 | env.Append(CPPPATH='class') 7 | env.Append(LIBPATH=["../lib"]) 8 | env['PUBLISH_PREFIX'] = '/net/www/docs/raf/Software' 9 | 10 | env.Append(CXXFLAGS='-std=c++11 -g -Wall -Wno-write-strings') 11 | 12 | env.Append(CPPDEFINES=['PNG']) 13 | 14 | # Change default fonts for Ubuntu as the adobe courier is not available. 15 | #env.Append(CPPDEFINES=['UBUNTU']) 16 | 17 | env.Append(LIBS=['png']) 18 | env.Append(LIBS=['z']) 19 | 20 | sources = Split(""" 21 | class/CanvasWindow.cc 22 | class/Colors.cc 23 | class/ControlWindow.cc 24 | class/DataFile.cc 25 | class/Enchilada.cc 26 | class/FileMgr.cc 27 | class/Hex.cc 28 | class/Histogram.cc 29 | class/Magnify.cc 30 | class/MagnifyCanvas.cc 31 | class/MagnifyWindow.cc 32 | class/MainCanvas.cc 33 | src/cb_canvas.cc 34 | src/cb_control.cc 35 | src/cb_mag.cc 36 | src/cb_menus.cc 37 | src/cb_printer.cc 38 | src/cb_text.cc 39 | src/ccb.cc 40 | src/global.cc 41 | src/xpms2d.cc 42 | """) 43 | 44 | ## src/process.cc 45 | 46 | xpms2d = env.Program(target = 'src/xpms2d', source = sources) 47 | env.Default(xpms2d) 48 | 49 | env.Install("$INSTALL_PREFIX/bin", 'src/xpms2d') 50 | 51 | if "publish" in COMMAND_LINE_TARGETS: 52 | pub = env.Install('$PUBLISH_PREFIX', ["src/xpms2d.html"]) 53 | env.Alias('publish', pub) 54 | -------------------------------------------------------------------------------- /xpms2d/src/cb_mag.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: cb_mag.cc 4 | 5 | FULL NAME: Callback Wrappers for the magnify canvas. 6 | 7 | DESCRIPTION: 8 | 9 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 10 | ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "define.h" 14 | 15 | #include 16 | 17 | extern MagnifyCanvas *magPlot; 18 | 19 | 20 | /* -------------------------------------------------------------------- */ 21 | void MagnifyExpose(Widget w, XtPointer client, XtPointer call) 22 | { 23 | magPlot->ExposeArea((XmDrawingAreaCallbackStruct *)call); 24 | 25 | } /* END MAGNIFYEXPOSE */ 26 | 27 | /* -------------------------------------------------------------------- */ 28 | void MagnifyResize(Widget w, XtPointer client, XtPointer call) 29 | { 30 | magPlot->Resize(); 31 | PageCurrent(); 32 | 33 | } /* END MAGNIFYRESIZE */ 34 | 35 | /* -------------------------------------------------------------------- */ 36 | void MagnifyInput(Widget w, XtPointer client, XtPointer call) 37 | { 38 | XmDrawingAreaCallbackStruct *evt; 39 | XAnyEvent *xe; 40 | 41 | evt = (XmDrawingAreaCallbackStruct *)call; 42 | xe = (XAnyEvent *)evt->event; 43 | 44 | } /* END MAGNIFYINPUT */ 45 | 46 | /* END CB_MAG.CC */ 47 | -------------------------------------------------------------------------------- /hvpsdiag/init.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: init.c 4 | 5 | FULL NAME: Initialize Procedures 6 | 7 | TYPE: X11/R5 application, motif 8 | 9 | DESCRIPTION: Inializiation routines run once at the beginning of main 10 | Initialize is used to set all global variables. 11 | Process_args does just that. 12 | 13 | AUTHOR: websterc@ncar.ucar.edu 14 | ------------------------------------------------------------------------- 15 | */ 16 | 17 | #include "define.h" 18 | #include 19 | 20 | 21 | /* --------------------------------------------------------------------- */ 22 | void Initialize() 23 | { 24 | FlashMode = Grid = Frozen = false; 25 | NumberSeconds = 10; 26 | 27 | } /* END INITIALIZE */ 28 | 29 | /* --------------------------------------------------------------------- */ 30 | void process_args(char **argv) 31 | { 32 | while (*++argv) 33 | if ((*argv)[0] == '-') 34 | switch ((*argv)[1]) 35 | { 36 | case 's': /* Number of seconds */ 37 | if (*++argv == NULL) 38 | return; 39 | 40 | NumberSeconds = atoi(*argv); 41 | break; 42 | 43 | default: 44 | fprintf(stderr, "Invalid option, Usage:\n"); 45 | fprintf(stderr, " rtplot [-s Seconds]\n"); 46 | } 47 | 48 | } /* END PROCESS_ARGS */ 49 | 50 | /* END INIT.CC */ 51 | -------------------------------------------------------------------------------- /translate2ds/HouseKeeping3VCPI.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Packet.h" 3 | #include 4 | 5 | namespace sp 6 | { 7 | struct HouseKeeping3VCPI: public Packet 8 | { 9 | // Skip ID, len, and check_sum 10 | word _data[80]; 11 | 12 | float true_airspeed() 13 | { 14 | float tas; 15 | short *s = (short *)&_data[73]; 16 | short *d = (short *)&tas; 17 | d[0] = s[1]; 18 | d[1] = s[0]; 19 | return tas; 20 | } 21 | 22 | float relative_humidity() 23 | { 24 | float rh = 0.002515185 * _data[26] - 28.02198; 25 | return rh; 26 | } 27 | 28 | /// 48 bit timing word / clock counter. 29 | long long fclk() 30 | { 31 | long long fclk = 0; 32 | short *s = (short *)&_data[70]; 33 | fclk += s[0]; fclk <<= 16; 34 | fclk += s[1]; fclk <<= 16; 35 | fclk += s[2]; 36 | return fclk; 37 | } 38 | 39 | /// First 26 shorts of the housekeeping packet are all temperatures. 40 | float temperature(int i) 41 | { 42 | if (i < 0 && i > 24) 43 | return NAN; 44 | 45 | float rt = 6.5536e9 * (1.0 - (float)_data[i]/65536.0) / (5.0*_data[i]); 46 | float t = -273.15 + pow(1.1117024e-3 + 237.02702e-6*log(rt)+75.78814e-9*pow(log(rt),3.0), -1.0); 47 | return t; 48 | } 49 | }; 50 | 51 | 52 | template 53 | inline T& operator >> (T& reader, HouseKeeping3VCPI& in) 54 | { 55 | reader.read(reinterpret_cast(&in._data[0]), sizeof(in._data)); 56 | in.PacketID = in._data[0]; 57 | return reader; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /xpms2d/class/FileMgr.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: FileMgr.cc 4 | 5 | FULL NAME: File Manager Class 6 | 7 | DESCRIPTION: 8 | 9 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 10 | ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "FileMgr.h" 14 | 15 | extern ADS_DataFile *dataFile[]; 16 | 17 | 18 | /* -------------------------------------------------------------------- */ 19 | FileManager::FileManager() 20 | { 21 | numberFiles = 0; 22 | currentFile = 0; 23 | 24 | } /* END CONTRUCTOR */ 25 | 26 | /* -------------------------------------------------------------------- */ 27 | void FileManager::NewFile(char fileName[], OAP::UserConfig &cfg) 28 | { 29 | int i; 30 | 31 | for (i = numberFiles-1; i >= 0; --i) 32 | delete dataFile[i]; 33 | 34 | numberFiles = 1; 35 | currentFile = 0; 36 | 37 | dataFile[0] = new ADS_DataFile(fileName, cfg); 38 | 39 | // Save off this data path for subsequent calls. 40 | strcpy(DataPath, fileName); 41 | char *p = strrchr(DataPath, '/'); 42 | if (p) 43 | strcpy(p, "/*2d*"); 44 | else 45 | strcpy(DataPath, "*2d*"); 46 | 47 | } /* END NEWFILE */ 48 | 49 | /* -------------------------------------------------------------------- */ 50 | void FileManager::AddFile(char fileName[], OAP::UserConfig &cfg) 51 | { 52 | dataFile[numberFiles++] = new ADS_DataFile(fileName, cfg); 53 | 54 | } /* END ADDFILE */ 55 | 56 | /* END FILEMGR.CC */ 57 | -------------------------------------------------------------------------------- /extract2ds/spec.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: spec.h 4 | 5 | FULL NAME: Translate SPEC to OAP 6 | 7 | DESCRIPTION: Structs for SPEC probes. 8 | 9 | COPYRIGHT: University Corporation for Atmospheric Research, 2023 10 | ------------------------------------------------------------------------- 11 | */ 12 | 13 | #ifndef _SPEC_H_ 14 | #define _SPEC_H_ 15 | 16 | #include 17 | 18 | enum PacketFormatType { Type32, Type48 }; 19 | 20 | // Key words in SPEC RLE input data files. 21 | static const uint16_t SyncWord = 0x3253; // Particle sync word '2S'. 22 | static const uint16_t MaskData = 0x4d4b; // MK Flush Buffer. 23 | static const uint16_t FlushWord = 0x4e4c; // NL Flush Buffer. 24 | static const uint16_t HousekeepWord = 0x484b; // HK Flush Buffer. 25 | 26 | //static const uint64_t Type32_TimingWordMask = 0x00000000FFFFFFFFL; // do I need this? 27 | static const uint64_t Type48_TimingWordMask = 0x0000FFFFFFFFFFFFL; 28 | 29 | 30 | struct imageBuf 31 | { 32 | int16_t year, month, dow, day, hour, minute, second, msecond; 33 | char rdf[4096]; 34 | uint16_t cksum; 35 | }; 36 | 37 | struct hk48Buf 38 | { 39 | int16_t year, month, dow, day, hour, minute, second, msecond; 40 | char rdf[164]; 41 | uint16_t cksum; 42 | }; 43 | 44 | struct maskBuf 45 | { 46 | int16_t year, month, dow, day, hour, minute, second, msecond; 47 | char rdf[54]; 48 | uint16_t cksum; 49 | }; 50 | 51 | // This is the index into the particle packet. 52 | enum PKT_IDX { H_CHN=1, V_CHN=2, PID=3, nSLICES=4 }; 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /xpms2d/class/Colors.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Colors.h 4 | 5 | FULL NAME: Colors 6 | 7 | DESCRIPTION: Provide a series of Colors that are always the same for 8 | both X & PostScript. 9 | 10 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2000 11 | ------------------------------------------------------------------------- 12 | */ 13 | 14 | #ifndef COLORS_H 15 | #define COLORS_H 16 | 17 | #include 18 | 19 | #define BLACK 0 20 | #define MAROON 1 21 | #define BLUE 2 22 | #define RED 3 23 | #define GREEN 4 24 | #define VIOLET 5 25 | #define PURPLE 6 26 | #define YELLOW 7 27 | #define BACKGROUND 8 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #ifdef PNG 34 | #include 35 | #endif 36 | 37 | /* -------------------------------------------------------------------- */ 38 | class Colors { 39 | 40 | public: 41 | Colors(const Widget w); 42 | 43 | int NumberOfColors() { return(numberColors); } 44 | void ResetColors() { colorIndex = 0; } 45 | 46 | uint32_t GetColor(int indx); 47 | uint32_t NextColor(); 48 | uint32_t CurrentColor(); 49 | 50 | float *GetColorPS(int indx); 51 | float *NextColorPS(); 52 | float *CurrentColorPS(); 53 | 54 | #ifdef PNG 55 | void SavePNG(const char outFile[], XImage *image); 56 | uint16_t *GetColorRGB_X(int idx); 57 | #endif 58 | 59 | 60 | private: 61 | #ifdef PNG 62 | void checkByteSwap(XImage *image); 63 | int getColorIndex(uint32_t pixel); 64 | #endif 65 | 66 | int colorIndex, numberColors; 67 | bool Color; 68 | 69 | }; /* END COLORS.H */ 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /process2d/probe.cpp: -------------------------------------------------------------------------------- 1 | #include "probe.h" 2 | 3 | void ProbeInfo::SetBinEndpoints(std::string input) 4 | { 5 | for(std::string::size_type p0 = 0, p1 = input.find(','); 6 | p1!=std::string::npos || p0!=std::string::npos; 7 | (p0=(p1==std::string::npos) ? p1 : ++p1),p1 = input.find(',', p0) ) 8 | { 9 | bin_endpoints.push_back( atof(input.c_str()+p0) ); 10 | } 11 | 12 | numBins = bin_endpoints.size() - 1; 13 | } 14 | 15 | 16 | void ProbeInfo::ComputeSamplearea(Config::Method eawmethod) 17 | { 18 | // if size greater than zero, then we've already set bin_endpoints. 19 | if (bin_endpoints.size() == 0) 20 | for (int i = 0; i < numBins+1; ++i) 21 | bin_endpoints.push_back((i+0.5) * resolution); 22 | 23 | for (int i = 0; i < numBins; ++i) 24 | { 25 | float sa, prht, DoF, eff_wid, diam; 26 | 27 | diam = (bin_endpoints[i] + bin_endpoints[i+1]) / 2.0; 28 | 29 | prht = armWidth * 1.0e4; //convert cm to microns 30 | DoF = std::min((dof_const * diam*diam), prht); // in microns, limit on dof is physical distance between arms 31 | 32 | // Reconstruction, from eq 17 in Heymsfield & Parrish 1978 33 | if (eawmethod == Config::RECONSTRUCTION) eff_wid = resolution*nDiodes+0.72*diam; 34 | //All-in, from eq 6 in HP78 35 | if (eawmethod == Config::ENTIRE_IN) eff_wid = std::max(resolution * (nDiodes-1)-diam, resolution); 36 | //Center-in 37 | if (eawmethod == Config::CENTER_IN) eff_wid = resolution*nDiodes; 38 | 39 | sa = DoF * eff_wid * 1e-12; //compute sa and convert to m^2 40 | 41 | bin_midpoints.push_back(diam); 42 | dof.push_back(DoF); 43 | eaw.push_back(eff_wid); 44 | samplearea.push_back(sa); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /xpms2d.spec: -------------------------------------------------------------------------------- 1 | Summary: Spec file for xpms2d 2 | Name: xpms2d 3 | Version: 3.0 4 | Release: 2 5 | License: GPL 6 | Group: System Environment/Daemons 7 | Url: http://www.eol.ucar.edu/ 8 | Packager: Chris Webster 9 | # becomes RPM_BUILD_ROOT 10 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) 11 | Vendor: UCAR 12 | BuildArch: x86_64 13 | 14 | BuildRequires: python3-scons 15 | Requires: libpng 16 | Requires: motif 17 | 18 | Source: %{name}.tar.gz 19 | 20 | %description 21 | Configuration for NCAR-EOL xpms2d display for OAP probes. 22 | 23 | %prep 24 | %setup -n %{name} 25 | 26 | %build 27 | scons 28 | 29 | %install 30 | rm -rf %{buildroot} 31 | mkdir -p %{buildroot}%{_bindir} 32 | cp xpms2d/src/%{name} %{buildroot}%{_bindir} 33 | 34 | %post 35 | 36 | 37 | %clean 38 | rm -rf %{buildroot} 39 | 40 | %files 41 | %defattr(-,root,root) 42 | %{_bindir}/%{name} 43 | 44 | %changelog 45 | 46 | * Sat Mar 13 2021 Chris Webster - 3.0-2 47 | - Try and get rpmbuild to work. Help Menu refactor. 48 | 49 | * Mon Jul 27 2015 Chris Webster - 2.7-1 50 | - Merge in 2DS branch. 51 | 52 | * Fri Dec 05 2014 Chris Webster - 2.7-0 53 | - Add support for CIP & PIP probes. Files still need to meet OAP format. I would call this beta support. 54 | 55 | * Thu Dec 12 2013 Chris Webster - 2.6-2 56 | - bug fixes. 57 | - Magnify box issue - XButtonEvent needed update, wasn't detecting if NumLock was off (or on). 58 | - Merge in branch file positioning. 59 | - Replace fopen64() freado64(), fseeko64(), etc with fopen() fread(), fseeko() 60 | - Clean up Mac build for Mountian Lion 61 | * Wed Jul 13 2011 Chris Webster - 2.6-1 62 | - initial version 63 | -------------------------------------------------------------------------------- /process2d/ProbeData.cpp: -------------------------------------------------------------------------------- 1 | #include "ProbeData.h" 2 | 3 | #include 4 | 5 | ProbeData::ProbeData(size_t size) : _size(size) 6 | { 7 | tas.resize(size, 0.0); 8 | cpoisson1.resize(size, 0.0); 9 | cpoisson2.resize(size, 0.0); 10 | cpoisson3.resize(size, 0.0); 11 | pcutoff.resize(size, 0.0); 12 | corrfac.resize(size, 0.0); 13 | 14 | all.accepted.resize(size, 0.0); 15 | all.rejected.resize(size, 0.0); 16 | all.total_conc.resize(size, 0.0); 17 | all.total_conc100.resize(size, 0.0); 18 | all.total_conc150.resize(size, 0.0); 19 | all.dbz.resize(size, -100.0); 20 | all.dbar.resize(size, 0.0); 21 | all.disp.resize(size, 0.0); 22 | all.lwc.resize(size, 0.0); 23 | all.eff_rad.resize(size, 0.0); 24 | 25 | round.accepted.resize(size, 0.0); 26 | round.rejected.resize(size, 0.0); 27 | round.total_conc.resize(size, 0.0); 28 | round.total_conc100.resize(size, 0.0); 29 | round.total_conc150.resize(size, 0.0); 30 | round.dbz.resize(size, -100.0); 31 | round.dbar.resize(size, 0.0); 32 | round.disp.resize(size, 0.0); 33 | round.lwc.resize(size, 0.0); 34 | round.eff_rad.resize(size, 0.0); 35 | } 36 | 37 | 38 | void ProbeData::ReplaceNANwithMissingData() 39 | { 40 | for (size_t i = 0; i < all.total_conc.size(); i++) 41 | { 42 | if (std::isnan(all.total_conc[i])) 43 | all.total_conc[i] = all.dbz[i] = all.dbar[i] = all.disp[i] = 44 | all.lwc[i] = all.eff_rad[i] = all.accepted[i] = 45 | all.rejected[i] = all.total_conc100[i] = all.total_conc150[i] = -32767.0; 46 | if (std::isnan(round.total_conc[i])) 47 | round.total_conc[i] = round.dbz[i] = round.dbar[i] = round.disp[i] = 48 | round.lwc[i] = round.eff_rad[i] = round.accepted[i] = 49 | round.rejected[i] = round.total_conc100[i] = round.total_conc150[i] = -32767.0; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /xpms2d/class/Enchilada.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Enchilada.cc 4 | 5 | COPYRIGHT: University Corporation for Atmospheric Research, 2000-2018 6 | ------------------------------------------------------------------------- 7 | */ 8 | 9 | #include "Enchilada.h" 10 | #include 11 | 12 | extern OAP::UserConfig userConfig; 13 | 14 | /* -------------------------------------------------------------------- */ 15 | Enchilada::Enchilada(const Widget parent) : TextWindow(parent, "enchilada") 16 | { 17 | } 18 | 19 | /* -------------------------------------------------------------------- */ 20 | void Enchilada::AddLineItem(int cnt, OAP::Particle *cp) 21 | { 22 | int h, m, s; 23 | char buffer[512]; 24 | 25 | if (cp == 0) 26 | return; 27 | 28 | if (cnt == 0) // Print title. 29 | { 30 | Append(" # Time timeWord iy ix ia dt rj dofRej"); 31 | switch (userConfig.GetConcentration()) 32 | { 33 | case OAP::BASIC: 34 | Append("theoretical"); 35 | break; 36 | 37 | case OAP::ENTIRE_IN: 38 | Append("Entire-in"); 39 | break; 40 | 41 | case OAP::CENTER_IN: 42 | Append("Center-in"); 43 | break; 44 | 45 | case OAP::RECONSTRUCTION: 46 | Append("Reconstruct"); 47 | break; 48 | } 49 | Append("\n"); 50 | } 51 | 52 | 53 | h = cp->time / 3600; 54 | m = (cp->time - (h*3600)) / 60; 55 | s = cp->time - (h*3600) - (m*60); 56 | 57 | // Particle #, time stamp, timeword, reject, h, w, a 58 | snprintf(buffer, 512, "%03d %02d:%02d:%02d.%03ld %8lu %3zu %3zu %3zu %6u %2d %2d\n", 59 | cnt, h, m, s, cp->msec, cp->timeWord, cp->h, cp->w, cp->area, 60 | cp->deltaTime, cp->reject, cp->dofReject); 61 | 62 | Append(buffer); 63 | 64 | } /* END ADDLINEITEM */ 65 | 66 | /* END ENCHILADA.CC */ 67 | -------------------------------------------------------------------------------- /xpms2d/src/cb_canvas.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: cb_canvas.cc 4 | 5 | FULL NAME: Callback Wrappers for the main canvas. 6 | 7 | ENTRY POINTS: CanvasExpose() 8 | CanvasInput() 9 | CanvasResize() 10 | DoTheBox() 11 | 12 | STATIC FNS: 13 | 14 | DESCRIPTION: 15 | 16 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 17 | ------------------------------------------------------------------------- 18 | */ 19 | 20 | #include "define.h" 21 | 22 | #include 23 | #include 24 | 25 | extern MainCanvas *mainPlot; 26 | extern Magnify *mag; 27 | 28 | 29 | /* -------------------------------------------------------------------- */ 30 | void CanvasExpose(Widget w, XtPointer client, XtPointer call) 31 | { 32 | mainPlot->ExposeArea((XmDrawingAreaCallbackStruct *)call); 33 | 34 | } /* END CANVASEXPOSE */ 35 | 36 | /* -------------------------------------------------------------------- */ 37 | void CanvasResize(Widget w, XtPointer client, XtPointer call) 38 | { 39 | mainPlot->Resize(); 40 | PageCurrent(); 41 | 42 | } /* END CANVASRESIZE */ 43 | 44 | /* -------------------------------------------------------------------- */ 45 | void CanvasInput(Widget w, XtPointer client, XtPointer call) 46 | { 47 | XmDrawingAreaCallbackStruct *evt; 48 | XAnyEvent *xe; 49 | 50 | evt = (XmDrawingAreaCallbackStruct *)call; 51 | xe = (XAnyEvent *)evt->event; 52 | 53 | if (xe->type == 4 || xe->type == 5) 54 | mag->ProcessInput(evt); 55 | 56 | } /* END CANVASINPUT */ 57 | 58 | /* -------------------------------------------------------------------- */ 59 | void DoTheBox(Widget w, XtPointer client, XMotionEvent *evt, Boolean cont2disp) 60 | { 61 | if (evt) 62 | mag->DrawBox(evt); 63 | 64 | } /* END DOTHEBOX */ 65 | 66 | /* END CB_CANVAS.CC */ 67 | -------------------------------------------------------------------------------- /xpms2d/class/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # xpms2d C++ class makefile 3 | # 4 | RAFINC= ${JLOCAL}/include 5 | O2D= ../obj 6 | 7 | OBJS= CanvasWindow.o Colors.o ControlWindow.o\ 8 | DataFile.o Enchilada.o FileMgr.o Hex.o\ 9 | Magnify.o MagnifyCanvas.o MagnifyWindow.o\ 10 | MainCanvas.o Probe.o Histogram.o PMS2D.o\ 11 | Fast2D.o TwoDS.o CIP.o HVPS.o Particle.o 12 | 13 | SRCS= CanvasWindow.cc Colors.cc ControlWindow.cc\ 14 | DataFile.cc Enchilada.cc FileMgr.cc Hex.cc\ 15 | Magnify.cc MagnifyCanvas.cc MagnifyWindow.cc\ 16 | MainCanvas.cc Probe.cc Histogram.cc PMS2D.cc\ 17 | Fast2D.cc TwoDS.cc CIP.cc HVPS.cc Particle.cc 18 | 19 | HDRS= define.h ${RAFINC}/raf/header.h 20 | 21 | all: ${OBJS} 22 | 23 | 24 | ${OBJS}: ${HDRS} 25 | 26 | CanvasWindow.o: CanvasWindow.h ${RAFINC}/raf/Window.h 27 | 28 | ControlWindow.o: ControlWindow.h FileMgr.h DataFile.h PMS2D.h Fast2D.h TwoDS.h CIP.h HVPS.h 29 | Colors.o: Colors.h MainCanvas.h 30 | 31 | DataFile.o: DataFile.h Probe.h ${RAFINC}/raf/hdrAPI.h 32 | 33 | Enchilada.o: Enchilada.h ${RAFINC}/raf/TextWindow.h 34 | FileMgr.o: FileMgr.h DataFile.h 35 | Hex.o: Hex.h FileMgr.h ${RAFINC}/raf/TextWindow.h 36 | Histogram.o: Histogram.h ${RAFINC}/raf/TextWindow.h 37 | Magnify.o: Magnify.h MainCanvas.h MagnifyCanvas.h Colors.h 38 | MagnifyCanvas.o: MagnifyCanvas.h ${RAFINC}/raf/Canvas.h ${RAFINC}/raf/Cursor.h 39 | MagnifyWindow.o: MagnifyWindow.h ${RAFINC}/raf/Window.h 40 | MainCanvas.o: MainCanvas.h DataFile.h Colors.h ${RAFINC}/raf/Canvas.h ${RAFINC}/raf/PostScript.h 41 | 42 | Probe.o: Probe.h ${RAFINC}/raf/hdrAPI.h 43 | PMS2D.o: PMS2D.h Probe.h ControlWindow.h ${RAFINC}/raf/hdrAPI.h 44 | Fast2D.o: Fast2D.h Probe.h ControlWindow.h 45 | TwoDS.o: TwoDS.h Probe.h ControlWindow.h 46 | CIP.o: CIP.h Probe.h ControlWindow.h 47 | HVPS.o: HVPS.h Probe.h ControlWindow.h ${RAFINC}/raf/hdrAPI.h 48 | Particle.o: Particle.h 49 | 50 | clean: 51 | ${RM} *.o 52 | -------------------------------------------------------------------------------- /usb2diag/DataMng.h: -------------------------------------------------------------------------------- 1 | #ifndef _DataMng_h_ 2 | #define _DataMng_h_ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | const unsigned short TBYTE = 4096; 11 | const int USECS_PER_SEC = 1000000; 12 | 13 | 14 | // This needs to go in a more global include file, say nidas/usbtwod.h 15 | typedef struct 16 | { 17 | unsigned long long timetag; 18 | unsigned long length; 19 | unsigned long sample_id; 20 | } nidas_hdr; 21 | 22 | typedef struct // Data, length = 4104 23 | { 24 | unsigned long id; // Data or Housekeeping. 25 | unsigned long tas; 26 | unsigned char data[TBYTE]; 27 | } usb2d_rec; 28 | 29 | typedef struct // length = 8 30 | { 31 | unsigned long id; 32 | unsigned long particle_count; 33 | } usb2d_hskp; 34 | 35 | 36 | /* -------------------------------------------------------------------- */ 37 | /** 38 | * Class to manage usb-2d data. 39 | */ 40 | class DataMng 41 | { 42 | public: 43 | DataMng( FILE * fp, short bitn); 44 | DataMng(); 45 | virtual ~DataMng(); 46 | virtual bool IsSameFSize(); 47 | virtual QPointArray* GetPArray() {return _pts;} 48 | virtual QPointArray* GetPtx() {return _ptstx;} 49 | virtual QPointArray* GetPln() {return _ptsln;} 50 | virtual QString GetTx() {return _text;} 51 | int GetFSize() {return _fsize;} 52 | void Setfp(FILE* fp) {_fp=fp;} 53 | void SetBt(short b ) {_bit_n=b;} 54 | void Init(); 55 | void Init(FILE* f, short b); 56 | protected: 57 | 58 | short _bit_n ; // = 64 32; 59 | short _byte_n; // = 8 4; 60 | short _slide_n; //= TBYTE/BYTE_N2D; 61 | short _row_n; //= 8 16; 62 | short _rcdpr_n; //= 2 1; 63 | short _byte_usb2d_rcd;// = 8 +TBYTE; 64 | 65 | nidas_hdr* _hdr; 66 | usb2d_rec* _twod_rec; 67 | 68 | FILE * _fp; 69 | fpos_t _pp; 70 | int _fsize; 71 | QPointArray* _pts; 72 | QPointArray* _ptstx; 73 | QPointArray* _ptsln; 74 | QString _text; 75 | size_t _cnt; 76 | 77 | bool _chkInit(); 78 | 79 | }; 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /xpms2d/class/ControlWindow.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: ControlWindow.h 4 | 5 | FULL NAME: Create Main Control Window 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef CONWINDOW_H 12 | #define CONWINDOW_H 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | 31 | /* -------------------------------------------------------------------- */ 32 | class ControlWindow : public WinForm { 33 | 34 | public: 35 | ControlWindow(Widget parent); 36 | void PopUp(); 37 | 38 | void SetFileNames(); 39 | void SetProbes(); 40 | 41 | Widget StartTime() const { return timeText; } 42 | 43 | void UpdateStartTime(OAP::P2d_rec *buff); 44 | void UpdateTimeScale(); 45 | 46 | float GetWaterDensity(int idx) const { return density[idx].density ; } 47 | float GetAreaRatioReject(int idx) const { return ratio[idx].density ; } 48 | OAP::Sizing GetSizingAlgo(int idx) const { return (OAP::Sizing)idx; } 49 | 50 | // bool RejectZeroAreaImage() const { return(true); } 51 | 52 | // void SetWaterDensity(int idx) { densIdx = idx; } 53 | // void SetAreaRatioReject(int idx) { ratioIdx = idx; } 54 | // void SetConcentrationCalc(int idx) { concIdx = idx; } 55 | void SetUserDensity(); 56 | void SetDelay(), PositionTime(bool), Start(), Stop(); 57 | 58 | 59 | private: 60 | Widget timeText, fileB[MAX_DATAFILES], butt[8], 61 | probeB[MAX_PROBES], densB[4], densTxt, 62 | delayScale, timeScale, cncB[4], ratioB[7]; 63 | 64 | int delay; 65 | bool movieRunning; 66 | 67 | struct _dens { 68 | const char *label; 69 | float density; 70 | } density[4]; 71 | 72 | struct _dens ratio[7]; 73 | 74 | }; /* END CONTROLWINDOW.H */ 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /xpms2d/class/MagnifyWindow.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: MagnifyWindow.cc 4 | 5 | FULL NAME: Data Set Class 6 | 7 | DESCRIPTION: 8 | 9 | COPYRIGHT: University Corporation for Atmospheric Research, 1997 10 | ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "MagnifyWindow.h" 14 | 15 | 16 | /* -------------------------------------------------------------------- */ 17 | MagnifyWindow::MagnifyWindow(Widget parent) : WinForm(parent, "mag", Form) 18 | { 19 | Widget frame, rc, b[3]; 20 | Cardinal n; 21 | Arg args[8]; 22 | 23 | n = 0; 24 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 25 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 26 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; 27 | frame = XmCreateFrame(Window(), (char *)"buttonFrame", args, n); 28 | XtManageChild(frame); 29 | 30 | n = 0; 31 | rc = XmCreateRowColumn(frame, (char *)"buttonRC", args, n); 32 | XtManageChild(rc); 33 | 34 | n = 0; 35 | b[0] = XmCreatePushButton(rc, (char *)"dismissButton", args, n); 36 | b[1] = XmCreatePushButton(rc, (char *)"printButton", args, n); 37 | XtManageChildren(b, 2); 38 | XtAddCallback(b[0], XmNactivateCallback, DismissWindow, Window()); 39 | // XtAddCallback(b[1], XmNactivateCallback, diffPostScript, NULL); 40 | XtSetSensitive(b[1], false); 41 | 42 | 43 | /* Create Graphics Canvas 44 | */ 45 | n = 0; 46 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; 47 | XtSetArg(args[n], XmNtopWidget, frame); n++; 48 | XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; 49 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; 50 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 51 | drawA = XmCreateDrawingArea(Window(), (char *)"magCanvas", args, n); 52 | XtManageChild(drawA); 53 | 54 | XtAddCallback(drawA, XmNexposeCallback, (XtCallbackProc)MagnifyExpose, NULL); 55 | // XtAddCallback(drawA, XmNinputCallback, (XtCallbackProc)MagnifyInput, NULL); 56 | XtAddCallback(drawA, XmNresizeCallback, (XtCallbackProc)MagnifyResize, NULL); 57 | 58 | } /* END CONSTRUCTOR */ 59 | 60 | /* END MAGNIFYWINDOW.CC */ 61 | -------------------------------------------------------------------------------- /xpms2d/class/Hex.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Hex.cc 4 | 5 | COPYRIGHT: University Corporation for Atmospheric Research, 2000-2018 6 | ------------------------------------------------------------------------- 7 | */ 8 | 9 | #include "Hex.h" 10 | #include "FileMgr.h" 11 | 12 | extern FileManager fileMgr; 13 | 14 | /* -------------------------------------------------------------------- */ 15 | Hex::Hex(const Widget parent) : TextWindow(parent, "hex") 16 | { 17 | 18 | } /* END CONSTRUCTOR */ 19 | 20 | /* -------------------------------------------------------------------- */ 21 | void Hex::Update(size_t nBuffs, OAP::P2d_rec sets[]) 22 | { 23 | char buffer[1024]; 24 | 25 | Clear(); 26 | 27 | /* Title */ 28 | strcpy(buffer, " "); 29 | for (size_t j = 0; j < nBuffs; ++j) 30 | { 31 | const char *p = (char *)&sets[j].id; 32 | 33 | if (((char *)&sets[j].id)[1] >= 'A') // 128 diode (2DS) 34 | snprintf(&buffer[strlen(buffer)], 36, " %c%c ", p[0], p[1]); 35 | else 36 | if (((char *)&sets[j].id)[1] >= '4') // 64 diode data, hex long-long 37 | snprintf(&buffer[strlen(buffer)], 36, " %c%c ", p[0], p[1]); 38 | else // 32 diode data, hex long. 39 | snprintf(&buffer[strlen(buffer)], 36, " %c%c ", p[0], p[1]); 40 | } 41 | 42 | strcat(buffer, "\n"); 43 | Append(buffer); 44 | 45 | 46 | /* Records */ 47 | const ProbeList & probes = fileMgr.CurrentFile()->Probes(); 48 | ProbeList::const_iterator iter; 49 | /* Display records in column format. 1024 is max slices per buffer 50 | * (old 32 diode 2d probe). 51 | */ 52 | for (size_t i = 0; i < 1024; ++i) 53 | { 54 | snprintf(buffer, 16, "%4zu ", i); 55 | 56 | for (size_t j = 0; j < nBuffs; ++j) 57 | { 58 | size_t nSlices = probes.find(sets[j].id)->second->nSlices(); 59 | size_t nBytes = P2D_DATA / nSlices; 60 | 61 | if (i < nSlices) 62 | { 63 | for (size_t k = 0; k < nBytes; ++k) 64 | snprintf(&buffer[strlen(buffer)], 4, "%02X", 65 | sets[j].data[(i*nBytes)+k]); 66 | strcat(buffer, " "); 67 | } 68 | } 69 | 70 | strcat(buffer, "\n"); 71 | Append(buffer); 72 | } 73 | 74 | MoveTo(0); 75 | 76 | } /* END UPDATE */ 77 | 78 | /* END HEX.CC */ 79 | -------------------------------------------------------------------------------- /hvpsdiag/DataPlot.cc: -------------------------------------------------------------------------------- 1 | #include "DataPlot.h" 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | P2d_rec hvpsRecord; 10 | 11 | 12 | /* -------------------------------------------------------------------- */ 13 | DataPlot::DataPlot(QWidget *parent, ADS_rtFile *f) : QwtPlot(parent) 14 | { 15 | file = f; 16 | freeze = false; 17 | 18 | setAxisTitle(QwtPlot::xBottom, "Diode #"); 19 | setAxisTitle(QwtPlot::yLeft, "Volts"); 20 | setMargin(10); 21 | // setAutoLegend(true); 22 | setCanvasBackground(QColor("white")); 23 | 24 | crv1 = new QwtPlotCurve("Masked"); 25 | crv2 = new QwtPlotCurve("Valid"); 26 | 27 | crv1->setPen(QPen(red)); 28 | crv2->setPen(QPen(green)); 29 | crv1->setStyle(QwtPlotCurve::Sticks); 30 | crv2->setStyle(QwtPlotCurve::Sticks); 31 | 32 | crv1->attach(this); 33 | crv2->attach(this); 34 | 35 | file->FirstPMS2dRecord(&hvpsRecord); 36 | 37 | (void)startTimer(10); 38 | 39 | } /* END CONSTRUCTOR */ 40 | 41 | /* -------------------------------------------------------------------- */ 42 | void DataPlot::ToggleFreeze() 43 | { 44 | freeze = 1 - freeze; 45 | 46 | } /* END TOGGLEFREEZE */ 47 | 48 | /* -------------------------------------------------------------------- */ 49 | void DataPlot::timerEvent(QTimerEvent *) 50 | { 51 | if (freeze || file->NextPMS2dRecord(&hvpsRecord) == false) 52 | return; 53 | 54 | Hdr_blk *hdr = (Hdr_blk *)&hvpsRecord; 55 | ushort *data = (ushort *)hvpsRecord.data; 56 | 57 | if (ntohs(data[0]) != 0xcaaa) 58 | return; 59 | 60 | ushort *mask = (ushort *)&hvpsRecord.data[4]; 61 | double xVal1[300], xVal2[300], yVal1[300], yVal2[300]; 62 | int rCnt, gCnt; 63 | 64 | snprintf(buffer, 32, "UTC (%02d:%02d:%02d)", 65 | ntohs(hdr->hour), ntohs(hdr->minute), ntohs(hdr->second)); 66 | setAxisTitle(QwtPlot::xBottom, buffer); 67 | 68 | rCnt = gCnt = 0; 69 | for (int i = 0; i < 256; ++i) 70 | { 71 | //printf("mask[%d]=%x i%16=%d = %d\n", i/16, mask[i/16], i%16, (0x8000 >> (i%16))); 72 | if ( mask[i/16] & (0x8000 >> (i%16)) ) 73 | { 74 | xVal2[gCnt] = i; 75 | yVal2[gCnt++] = data[28 + i]; 76 | } 77 | else 78 | { 79 | xVal1[rCnt] = i; 80 | yVal1[rCnt++] = data[28 + i]; 81 | } 82 | } 83 | 84 | crv1->setData(xVal1, yVal1, rCnt); 85 | crv2->setData(xVal2, yVal2, gCnt); 86 | 87 | replot(); 88 | sleep(1); 89 | 90 | } /* END TIMEREVENT */ 91 | 92 | /* END DATAPLOT.CC */ 93 | -------------------------------------------------------------------------------- /xpms2d/class/MagnifyCanvas.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: MagnifyCanvas.cc 4 | 5 | FULL NAME: Magnify canvas 6 | 7 | DESCRIPTION: 8 | 9 | NOTES: 10 | 11 | COPYRIGHT: University Corporation for Atmospheric Research, 1997 12 | ------------------------------------------------------------------------- 13 | */ 14 | 15 | #include "MagnifyCanvas.h" 16 | #include 17 | #include "Magnify.h" 18 | #include "MainCanvas.h" 19 | #include 20 | 21 | extern XCursor cursor; 22 | extern Magnify *mag; 23 | extern MainCanvas *mainPlot; 24 | extern XPen *pen; 25 | 26 | #include 27 | 28 | 29 | /* -------------------------------------------------------------------- */ 30 | MagnifyCanvas::MagnifyCanvas(Widget w) : Canvas(w) 31 | { 32 | 33 | } /* END CONSTRUCTOR */ 34 | 35 | /* -------------------------------------------------------------------- */ 36 | void MagnifyCanvas::draw() 37 | { 38 | int xIn, yIn, xOut, yOut, theWidth, theHeight; 39 | unsigned long pix, background; 40 | XImage *imageIn, *imageOut; 41 | 42 | if (mag->width <= 0 || mag->height <= 0) 43 | return; 44 | 45 | cursor.WaitCursor(mainPlot->Wdgt()); 46 | cursor.WaitCursor(Wdgt()); 47 | 48 | theWidth = std::min(mag->width, Width() >> 1); 49 | theHeight = std::min(mag->height, Height() >> 1); 50 | 51 | imageIn = pen->GetImage(mainPlot->Surface(), 52 | mag->startX, mag->startY, theWidth, theHeight); 53 | 54 | Clear(); 55 | imageOut = pen->GetImage(Surface(), 0, 0, theWidth << 1, theHeight << 1); 56 | 57 | background = pen->GetBackground();; 58 | 59 | for (yIn = 0; yIn < theHeight; ++yIn) 60 | for (xIn = 0; xIn < theWidth; ++xIn) 61 | { 62 | pix = XGetPixel(imageIn, xIn, yIn); 63 | 64 | if (pix != background) 65 | { 66 | xOut = xIn << 1; 67 | yOut = yIn << 1; 68 | 69 | XPutPixel(imageOut, xOut, yOut, pix); 70 | XPutPixel(imageOut, xOut+1, yOut, pix); 71 | XPutPixel(imageOut, xOut, yOut+1, pix); 72 | XPutPixel(imageOut, xOut+1, yOut+1, pix); 73 | } 74 | } 75 | 76 | pen->PutImage(Surface(), imageOut, 0, 0, 0, 0, theWidth << 1, theHeight << 1); 77 | 78 | ExposeAll(); 79 | 80 | XDestroyImage(imageIn); 81 | XDestroyImage(imageOut); 82 | 83 | cursor.PointerCursor(mainPlot->Wdgt()); 84 | cursor.PointerCursor(Wdgt()); 85 | 86 | } /* END DRAW */ 87 | 88 | /* END MAGNIFYCANVAS.CC */ 89 | -------------------------------------------------------------------------------- /translate2ds/File.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "common.h" 6 | 7 | namespace sp 8 | { 9 | class Log; 10 | 11 | class File 12 | { 13 | public: 14 | File(const std::string& path):_in(path.c_str(), std::fstream::binary) 15 | { 16 | _buffer.resize(BUFFER_SIZE); 17 | 18 | _in.seekg( 0, std::ios::end ); 19 | 20 | std::streamoff sizeBytes = _in.tellg(); 21 | _megabytes = float(sizeBytes >> 20); 22 | _in.seekg( 0, std::ios::beg ); 23 | 24 | 25 | 26 | // _in.open(path.c_str());//, std::ifstream::binary); 27 | 28 | // get_next_buffer(); 29 | 30 | _srcEnd = ENDIAN_LITTLE; 31 | _dstEnd = ENDIAN_LITTLE; 32 | } 33 | 34 | 35 | void process(); 36 | 37 | File& operator >> (float32& in) {return read(in);} 38 | File& operator >> (word& in) {return read(in);} 39 | 40 | template 41 | File& read (T& in) 42 | { 43 | read(reinterpret_cast(&in), sizeof(in)); 44 | return *this; 45 | } 46 | 47 | void read(byte* bytes, unsigned int size) 48 | { 49 | _in.read(reinterpret_cast(bytes), size); 50 | std::streamsize count = _in.gcount(); 51 | if(count != size) 52 | { 53 | printf("Partial buffer read - reject\n"); 54 | _buffer.clear(); 55 | } 56 | return; 57 | } 58 | 59 | Endianness SourceEndian()const{return _srcEnd;} 60 | Endianness DestinationEndian()const{return _dstEnd;} 61 | 62 | 63 | bool empty()const 64 | { return _buffer.empty(); } 65 | 66 | bool is_open()const{return const_cast(this)->_in.is_open();} //idiotically cygwin gcc appears to not have a const version of is_open... 67 | 68 | 69 | float MegaBytes()const 70 | { return _megabytes; } 71 | 72 | private: 73 | 74 | void get_next_buffer() 75 | { 76 | _in.read(&_buffer[0],_buffer.size()); 77 | std::streamsize count = _in.gcount(); 78 | //_buffer.size() is an unsigned int and count is a signed int. 79 | //Cast to signed longto ensure all values can be handled. 80 | if(long(count) < long(_buffer.size())) 81 | { 82 | _buffer.resize(count); 83 | } 84 | 85 | _location = 0; 86 | } 87 | 88 | std::ifstream _in; 89 | unsigned long long int _Length; 90 | 91 | enum 92 | { 93 | BUFFER_SIZE = 1024*1024 94 | }; 95 | 96 | typedef std::vector Buffer; 97 | Buffer _buffer; 98 | unsigned int _location; 99 | float _megabytes; 100 | 101 | 102 | Endianness _srcEnd,_dstEnd; 103 | 104 | }; 105 | } 106 | -------------------------------------------------------------------------------- /hvpsdiag/CanvasWindow.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: CanvasWindow.cc 4 | 5 | FULL NAME: 6 | 7 | ENTRY POINTS: CanvasWindow() 8 | 9 | STATIC FNS: 10 | 11 | DESCRIPTION: 12 | 13 | NOTES: 14 | 15 | COPYRIGHT: University Corporation for Atmospheric Research, 2003 16 | ------------------------------------------------------------------------- 17 | */ 18 | 19 | #include "CanvasWindow.h" 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | ADS_rtFile *file; 27 | 28 | /* -------------------------------------------------------------------- */ 29 | class PrintFilter: public QwtPlotPrintFilter 30 | { 31 | public: 32 | PrintFilter() {}; 33 | 34 | virtual QFont font(const QFont &f, Item, int) const 35 | { 36 | QFont f2 = f; 37 | f2.setPointSize((int)(f.pointSize() * 0.75)); 38 | return f2; 39 | } 40 | }; 41 | 42 | /* -------------------------------------------------------------------- */ 43 | CanvasWindow::CanvasWindow(QApplication *qApp) : QMainWindow(0, "canvas") 44 | { 45 | QToolBar *toolBar = new QToolBar(this, "options"); 46 | toolBar->setLabel( "File Operations" ); 47 | 48 | 49 | QToolButton *q = new QToolButton(toolBar); 50 | q->setTextLabel("Quit"); 51 | q->setUsesTextLabel(true); 52 | q->setUsesBigPixmap(false); 53 | connect(q, SIGNAL(clicked()), qApp, SLOT(quit())); 54 | 55 | QToolButton *p = new QToolButton(toolBar); 56 | p->setTextLabel("Print"); 57 | p->setUsesTextLabel(true); 58 | p->setUsesBigPixmap(false); 59 | connect(p, SIGNAL(clicked()), SLOT(Print())); 60 | 61 | 62 | QHBox *box = new QHBox(this); 63 | setCentralWidget((QWidget *)box); 64 | 65 | file = new ADS_rtFile(); 66 | plot = new DataPlot(box, file); 67 | 68 | plot->show(); 69 | 70 | statusBar()->message( "Ready", 2000 ); 71 | 72 | } /* END CONSTRUCTOR */ 73 | 74 | /* -------------------------------------------------------------------- */ 75 | void CanvasWindow::Print() 76 | { 77 | QPrinter printer; 78 | 79 | QString docName = plot->title().text(); 80 | if ( docName.isEmpty() ) 81 | { 82 | docName.replace(QRegExp (QString::fromLatin1 ("\n")), tr (" -- ")); 83 | printer.setDocName(docName); 84 | } 85 | 86 | printer.setCreator("hvpscal"); 87 | printer.setOrientation(QPrinter::Landscape); 88 | printer.setPageSize(QPrinter::Letter); 89 | printer.setPrintProgram("lpr"); 90 | 91 | if (printer.setup()) 92 | plot->print(printer); 93 | 94 | } /* END PRINT */ 95 | 96 | /* END CANVASWINDOW.CC */ 97 | -------------------------------------------------------------------------------- /extract2ds/particle.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ifndef _PARTICLE_H_ 4 | #define _PARTICLE_H_ 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #include "spec.h" 12 | 13 | 14 | class Config; 15 | 16 | /** 17 | * Class to decompress SPEC run length encoded data, place it in the RAF OAP 18 | * format and write that buffer out when it fills the 4k. There is one instance 19 | * of this class for each probe array. So one for an HVPS, but two for the 20 | * 2DS, one for H channel and one for V channel. 21 | */ 22 | class Particle 23 | { 24 | public: 25 | Particle(const char code[], FILE *outFile, Config *cfg); 26 | ~Particle(); 27 | 28 | void processParticle(uint16_t *wp, bool verbose); 29 | 30 | /** 31 | * Set timestamp. This should be the stamp from the previous record, which 32 | * would coorespond to the start of the upcoming record. We will then ADD 33 | * time words to get a final time stamp. 34 | */ 35 | void setHeader(const OAP::P2d_hdr &hdr, uint64_t ltw); 36 | void writeBuffer(); 37 | 38 | 39 | private: 40 | 41 | void particleHeaderSanityCheck(const uint16_t *hdr); 42 | void printParticleHeader(const uint16_t *hdr) const; 43 | void finishSlice(); 44 | void fixupTimeStamp(); 45 | bool diodeCountCheck(); 46 | 47 | Config *_config; 48 | 49 | FILE *_out_fp; 50 | unsigned char _code[8]; // only really need 2 bytes 51 | OAP::P2d_rec _compressedTime; // Header/timestamp from current compressed record. 52 | OAP::P2d_rec _output; // ...which gets compied into here and modified. 53 | unsigned char *_uncompressed; 54 | 55 | size_t _pos; // write position into output buffer. 56 | size_t _nBits; 57 | 58 | // Previous particle ID or seq number. For determining multi-packet particles 59 | uint16_t _prevID; 60 | // Timing word of current particle we are processing 61 | uint64_t _thisTimeWord; 62 | // Last timing word in the _compressedBuffer 63 | uint64_t _lastTimeWord; 64 | 65 | size_t _recordsOutputCnt; 66 | size_t _particlesProcessedCnt; 67 | size_t _rejectedRecordCnt; 68 | 69 | // positions in output buffer of first and last timing words...so can add padding 70 | // to deltaT of leading and trailing slices. 71 | int _posFTW, _posLTW; 72 | 73 | 74 | // Previous and this time stamps by datasystem. Providing bounding start 75 | // and end time records we generate. 76 | time_t _prevDAQtime, _thisDAQtime; 77 | int _prevMsec, _thisMsec; 78 | 79 | size_t _resolution; 80 | 81 | static const size_t _nDiodes; 82 | static const uint64_t _syncWord; 83 | static const unsigned char _syncString[3]; 84 | 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /process2d/netcdf.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | class Config; 8 | class ProbeInfo; 9 | class ProbeData; 10 | 11 | using namespace netCDF; 12 | 13 | /** 14 | * Class to handle opening/creating the netCDF file and writing 15 | * variable data. 16 | */ 17 | class NetCDF 18 | { 19 | public: 20 | NetCDF(Config & cfg); 21 | ~NetCDF(); 22 | 23 | NcFile *ncid() const { return _file; } 24 | 25 | void CreateNetCDFfile(const Config & cfg); 26 | 27 | void CreateDimensions(int numtimes, ProbeInfo &probe, const Config &cfg); 28 | 29 | /** 30 | * Add dimension to netCDF file. If dimension already exists, 31 | * then a pointer to that dimension is returned. 32 | */ 33 | NcDim addDimension(const char name[], int size); 34 | 35 | NcVar addTimeVariable(const Config & cfg, int size); 36 | 37 | bool hasTASX() 38 | { return _tas.isNull() ? false : true; } 39 | 40 | /** 41 | * Check for the existence of TASX. Read it into provided space. 42 | */ 43 | void readTrueAirspeed(float tas[], size_t n); 44 | 45 | int WriteData(ProbeInfo & probe, ProbeData & data); 46 | 47 | /* 48 | NcDim *timedim() const { return _timedim; } 49 | NcDim *spsdim() const { return _spsdim; } 50 | NcDim *bindim() const { return _bindim; } 51 | NcDim *bindim_plusone() const { return _bindim_plusone; } 52 | */ 53 | NcDim intbindim() const { return _intbindim; } 54 | 55 | NcVar addHistogram(std::string& vname, const ProbeInfo& probe, int binoffset); 56 | NcVar addVariable(std::string& name, std::string& serialNumber); 57 | 58 | void putGlobalAttribute(const char attrName[], float value); 59 | void putGlobalAttribute(const char attrName[], const char *value); 60 | void putGlobalAttribute(const char attrName[], const std::string value); 61 | void putVarAttribute(NcVar & var, const char attrName[], const char *value); 62 | void putVarAttribute(NcVar & var, const char attrName[], float value); 63 | void putVarAttribute(NcVar & var, const char attrName[], int value); 64 | void putVarAttribute(NcVar & var, const char attrName[], std::vector values); 65 | void putVarAttribute(NcVar & var, const char attrName[], const std::string value); 66 | 67 | static const int NC_ERR = 2; 68 | 69 | private: 70 | void InitVarDB(); 71 | 72 | void readStartEndTime(Config & cfg); 73 | 74 | std::string dateProcessed(); 75 | 76 | std::string _outputFile; 77 | 78 | NcFile *_file; 79 | NcFile::FileMode _mode; 80 | 81 | NcDim _timedim, _spsdim, _bindim, _bndsdim, _bindim_plusone, _intbindim; 82 | NcVar _timevar; 83 | NcVar _tas; 84 | 85 | static const char *ISO8601_Z; 86 | static const char *Category; 87 | }; 88 | -------------------------------------------------------------------------------- /usb2diag/DataMng.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "DataMng.h" 3 | 4 | #include 5 | 6 | 7 | /* -------------------------------------------------------------------- */ 8 | DataMng::DataMng(FILE * fp, short b) 9 | { 10 | _fp=fp; 11 | _bit_n=b; 12 | _fsize=0; 13 | Init(); 14 | } 15 | 16 | DataMng::DataMng() 17 | { 18 | _fsize=0; 19 | _bit_n=0; 20 | _fp=NULL; 21 | _pts=NULL; 22 | } 23 | 24 | 25 | DataMng::~DataMng() { 26 | _bit_n=0 ; 27 | 28 | if (_hdr!=NULL) { delete _hdr;} 29 | if (_twod_rec!=NULL) { delete _twod_rec;} 30 | 31 | if (_fp) { delete _fp;} 32 | if (_pts) { delete _pts;} 33 | if (_ptstx) { delete _ptstx;} 34 | if (_ptsln) { delete _ptsln;} 35 | } 36 | 37 | /* -------------------------------------------------------------------- */ 38 | bool DataMng::IsSameFSize() { 39 | if (!_chkInit()) {return false;} 40 | 41 | //get filesize 42 | fseeko(_fp, 0, SEEK_END); 43 | int size=ftello(_fp); 44 | 45 | //check if the same file size 46 | if (_fsize!=0 && size==_fsize) { 47 | QTime t =QTime::currentTime(); 48 | std::cout<<"\n Same file size! "< 4 | #include "common.h" 5 | #include "PacketTypes.h" 6 | 7 | namespace sp 8 | { 9 | 10 | struct block_incomplete: protected std::exception 11 | { 12 | 13 | }; 14 | 15 | class Block 16 | { 17 | public: 18 | Block(unsigned int lineSize, Endianness s, Endianness d) : _head(0), _lineSize(lineSize), _srcEnd(s), _dstEnd(d){_data.reserve(1024*1024*10);} 19 | 20 | Block& operator >> (float32& in) {return read(in);} 21 | Block& operator >> (word& in) {return read(in);} 22 | Block& operator >> (uint32_t& in) {return read(in);} 23 | Block& operator >> (uint64_t& in) {return read(in);} 24 | 25 | template 26 | Block& read(D& obj) 27 | { 28 | read(reinterpret_cast(&obj), sizeof(obj)); 29 | return *this; 30 | } 31 | 32 | 33 | void read( byte* pBytes, size_t length ) 34 | { 35 | size_t remains = remaining(); 36 | if(remains < length) 37 | { 38 | throw block_incomplete(); 39 | return; 40 | } 41 | 42 | memcpy(pBytes, &_data[_head], length); 43 | _head += length; 44 | } 45 | 46 | 47 | Endianness SourceEndian()const{return _srcEnd;} 48 | Endianness DestinationEndian()const{return _dstEnd;} 49 | 50 | 51 | void add_line() 52 | {_data.resize(_data.size() + _lineSize);} 53 | 54 | byte *fill_begin() 55 | {return &_data[_data.size() - _lineSize];} 56 | unsigned int fill_length() 57 | {return _lineSize;} 58 | 59 | int countParticles() 60 | { 61 | // Count the number of instances of DATA marker in block. This is equal to 62 | // the number of particles in the current record. 63 | int count = 0; 64 | unsigned short val; 65 | //_data.size() is an unsigned int, so cast to signed long 66 | //to ensure all values can be handled. 67 | for (long i = 0 ; i < long(_data.size()); i+=2) { 68 | // Byte swap next 4 bytes, cast to unsigned short, and 69 | // compare with DATA from PacketTypes.h 70 | val = (_data[i+1] <<8) | _data[i]; 71 | if (val == DATA) {count++;} 72 | } 73 | return count; 74 | } 75 | 76 | // Print the contents of a block (in hex). Useful for debugging. 77 | void print() const 78 | { 79 | //_data.size() is an unsigned int, so cast to signed long 80 | //to ensure all values can be handled. 81 | for (long i = 0 ; i < long(_data.size()); i++) { 82 | printf("%x ",_data[i]); 83 | } 84 | printf("\n"); 85 | } 86 | 87 | size_t size() const 88 | {return _data.size();} 89 | 90 | size_t remaining() const 91 | {return size() - _head;} 92 | 93 | void clear() 94 | {_data.erase(_data.begin(), _data.begin() + _head); _head = 0;} 95 | 96 | size_t head() const 97 | {return _head;} 98 | 99 | void go_to(size_t s) 100 | { _head = s;} 101 | 102 | 103 | void go_to_end() 104 | { _head = size(); } 105 | 106 | private: 107 | 108 | typedef std::vector Data; 109 | 110 | size_t _head; 111 | unsigned int _lineSize; 112 | Data _data; 113 | Endianness _srcEnd,_dstEnd; 114 | }; 115 | 116 | template 117 | inline T& operator >> (T& reader, Block& in) 118 | { 119 | in.add_line(); 120 | reader.read(in.fill_begin(), in.fill_length()); 121 | return reader; 122 | } 123 | 124 | } 125 | -------------------------------------------------------------------------------- /extract2ds/config.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: config.h 4 | 5 | DESCRIPTION: Header File declaring Variable and associated processing 6 | functions. 7 | 8 | COPYRIGHT: University Corporation for Atmospheric Research, 2023 9 | ------------------------------------------------------------------------- 10 | */ 11 | 12 | #ifndef _config_h_ 13 | #define _config_h_ 14 | 15 | #include 16 | #include "spec.h" 17 | 18 | class Config 19 | { 20 | public: 21 | 22 | Config(); 23 | 24 | const std::string& ProjectDirectory() const { return _projectDirectory; } 25 | const std::string& ProjectName() const { return _projectName; } 26 | const std::string& Platform() const { return _platform; } 27 | const std::string& FlightNumber() const { return _flightNumber; } 28 | const std::string& FlightDate() const { return _flightDate; } 29 | const std::string& Type() const { return _type; } 30 | const std::string& PacketID() const { return _code; } 31 | const std::string& SerialNumber() const { return _serialNumber; } 32 | const std::string& Suffix() const { return _suffix; } 33 | const std::string& OutputFilename() const { return _outputFilename; } 34 | int TimeOffset() const { return _timeOffset; } 35 | bool StoreCompressed() const { return _storeCompressed; } 36 | bool StuckBitRejection() const { return _stuckBitRejection; } 37 | 38 | int16_t PacketIDasInt() const { return *((int16_t *)_code.c_str()); } 39 | int Resolution() const { return _resolution; } 40 | int nDiodes() const { return _nDiodes; } 41 | int ClockFrequency() const { return _clockFreq; } 42 | int WaveLength() const { return _waveLength; } 43 | PacketFormatType DataFormat() const { return _dataFormat; } 44 | 45 | 46 | void SetProjectDirectory(const std::string s) { _projectDirectory = s; } 47 | void SetProjectName(const std::string s) { _projectName = s; } 48 | void SetPlatform(const std::string s) { _platform = s; } 49 | void SetFlightNumber(const std::string s) { _flightNumber = s; } 50 | void SetFlightDate(const std::string s) { _flightDate = s; } 51 | void SetType(const std::string s); 52 | void SetPacketID(const std::string s) { _code = s; } 53 | void SetSerialNumber(const std::string s) { _serialNumber = s; } 54 | void SetSuffix(const std::string s) { _suffix = s; } 55 | void SetTimeOffset(const std::string s) { _timeOffset = atoi(s.c_str()); } 56 | void SetOutputFilename(const std::string s) { _outputFilename = s; } 57 | void SetNoRejection() { _stuckBitRejection = false; } 58 | 59 | void SetResolution(int r) { _resolution = r; } 60 | void SetDiodes(int n) { _nDiodes = n; } 61 | void SetWaveLength(int l) { _waveLength = l; } 62 | void SetClockFreq(int f) { _clockFreq = f; } 63 | 64 | 65 | private: 66 | 67 | std::string _projectDirectory; 68 | std::string _projectName; 69 | std::string _platform; 70 | std::string _flightNumber; 71 | std::string _flightDate; 72 | std::string _code; 73 | std::string _type; 74 | std::string _serialNumber; 75 | std::string _suffix; 76 | std::string _outputFilename; 77 | 78 | int _timeOffset; 79 | 80 | bool _stuckBitRejection; 81 | bool _storeCompressed; 82 | 83 | int _resolution; 84 | int _nDiodes; 85 | int _clockFreq; 86 | int _waveLength; 87 | 88 | PacketFormatType _dataFormat; 89 | 90 | }; 91 | 92 | #endif 93 | 94 | // END CONFIG.H 95 | -------------------------------------------------------------------------------- /xpms2d/src/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for xpms2d 3 | # 4 | BIN = ${JLOCAL}/bin 5 | WWW = /net/www/docs/raf/Software 6 | RELEASE = ${JLOCAL}/xpms2d 7 | 8 | INC = ../class 9 | RAFINC = ${JLOCAL}/include 10 | C2D = ../class 11 | O2D = ../class 12 | 13 | # Linux 14 | # 15 | DEFINES = -D_FILE_OFFSET_BITS=64 -DPNG 16 | INCLUDES= -I../class -I${RAFINC} 17 | LIB_DIRS= -L${JLOCAL}/lib 18 | LIBS = -lraf -lXm -lXt -lX11 -lpng -lz 19 | ANONFTP = /net/ftp/pub/archive/RAF-src/bin.RHEL6 20 | 21 | # Mac OS X 22 | # 23 | # Requires XCode from Mac App Store, use Macports/porticus to get libpng and netcdf 24 | # and get OpenMotif from here (OpenMotif from Macports was not working for us): 25 | # http://www.ist-inc.com/downloads/motif_download.html 26 | # 27 | # Mountain Lion update. Need to get XQuartz download for X11, it is no longer bundled 28 | # with MacOS. Using Homebrew instead of MacPorts now. 29 | # 30 | # setenv JLOCAL /usr/local (or 'export JLOCAL=/usr/local'). 31 | # 32 | # Build libraf first. 33 | # 34 | #DEFINES = -D_FILE_OFFSET_BITS=64 -DPNG -DPNG15 35 | #INCLUDES= -I../class -I${INC} -I${RAFINC} -I/opt/X11/include -I/usr/OpenMotif/include 36 | #LIB_DIRS= -L/opt/X11/lib -L${JLOCAL}/lib -L/usr/OpenMotif/lib 37 | #LIBS = -lraf -lXm -lXt -lICE -lX11 -lpng -lz 38 | 39 | # Don't use optimization with gcc (2.95.2 and earlier) and C++. 40 | CXX = g++ 41 | CXXFLAGS= -Wall -Wno-write-strings -g -O ${INCLUDES} ${DEFINES} 42 | 43 | PROG = xpms2d 44 | HDRS = ../class/define.h 45 | 46 | SRCS= xpms2d.cc global.cc ccb.cc cb_canvas.cc cb_control.cc cb_mag.cc\ 47 | cb_menus.cc cb_printer.cc cb_text.cc xml.cc 48 | 49 | OBJS= xpms2d.o global.o ccb.o cb_canvas.o cb_control.o cb_mag.o\ 50 | cb_menus.o cb_printer.o cb_text.o xml.o 51 | 52 | 53 | O2DOB= ${O2D}/CanvasWindow.o\ 54 | ${O2D}/ControlWindow.o ${O2D}/Colors.o ${O2D}/Enchilada.o\ 55 | ${O2D}/DataFile.o ${O2D}/FileMgr.o ${O2D}/Hex.o\ 56 | ${O2D}/Magnify.o ${O2D}/MagnifyCanvas.o ${O2D}/MagnifyWindow.o\ 57 | ${O2D}/MainCanvas.o ${O2D}/Probe.o ${O2D}/Histogram.o ${O2D}/PMS2D.o\ 58 | ${O2D}/Fast2D.o ${O2D}/TwoDS.o ${O2D}/CIP.o ${O2D}/HVPS.o ${O2D}/Particle.o 59 | 60 | 61 | ${PROG}: ${OBJS} classDir 62 | ${CXX} ${CXXFLAGS} ${LIB_DIRS} ${OBJS} ${O2DOB} ${LIBS} -o $@ 63 | 64 | classDir: 65 | cd ${O2D}; make "CXXFLAGS=${CXXFLAGS}" 66 | 67 | install: ${PROG} 68 | test -d ${BIN} || mkdir ${BIN} 69 | cp ${PROG} ${BIN} 70 | 71 | publish: 72 | cp ${PROG} ${ANONFTP} 73 | cp ${PROG}.html ${WWW} 74 | 75 | clean: 76 | (cd ../class; make clean) 77 | ${RM} core* ${OBJS} ${PROG} 78 | 79 | print: 80 | enscript -2Gr -b${PROG} ${HDRS} ${SRCS} 81 | 82 | ${OBJS}: ${HDRS} 83 | 84 | xpms2d.o: ${RAFINC}/raf/Application.h ${INC}/CanvasWindow.h ${INC}/Colors.h ${INC}/ControlWindow.h ${RAFINC}/raf/Cursor.h ${INC}/FileMgr.h ${INC}/DataFile.h ${RAFINC}/raf/XFonts.h ${RAFINC}/raf/XPen.h ${INC}/MagnifyWindow.h ${INC}/MainCanvas.h ${RAFINC}/raf/Printer.h ${RAFINC}/raf/XmError.h ${RAFINC}/raf/XmFile.h ${RAFINC}/raf/XmWarn.h fbr.h 85 | 86 | cb_canvas.o: ${INC}/MainCanvas.h ${INC}/Magnify.h 87 | cb_control.o: ${RAFINC}/raf/Cursor.h ${INC}/FileMgr.h ${INC}/MainCanvas.h ${INC}/ControlWindow.h ${INC}/Colors.h 88 | cb_mag.o: ${INC}/MagnifyCanvas.h 89 | cb_menus.o: ${RAFINC}/raf/Application.h ${INC}/ControlWindow.h ${RAFINC}/raf/Cursor.h ${INC}/FileMgr.h ${INC}/MainCanvas.h ${RAFINC}/raf/PostScript.h ${RAFINC}/raf/Printer.h ${RAFINC}/raf/XmFile.h 90 | cb_printer.o: ${RAFINC}/raf/Printer.h 91 | cb_text.o: ${RAFINC}/raf/TextWindow.h 92 | process.o: ${INC}/ControlWindow.h 93 | -------------------------------------------------------------------------------- /cip/pads2oap/pads2oap.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _pads2oap_h_ 3 | #define _pads2oap_h_ 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #define TWOD_BUFF_SIZE 4096 10 | 11 | // Values currently in use for the 'id' field...at least by NCAR-RAF. 12 | #define PMS2D_C1 0x4331 // First PMS-2DC 13 | #define PMS2D_C2 0x4332 // Second PMS-2DC 14 | #define PMS2D_C4 0x4334 // First RAF 64 diode 25 um Fast 2DC 15 | #define PMS2D_C5 0x4335 // Second RAF 64 diode 25 um Fast 2DC 16 | #define PMS2D_C6 0x4336 // First RAF 64 diode 10 um Fast 2DC 17 | #define PMS2D_C8 0x4338 // First DMT CIP probe. 18 | #define PMS2D_G1 0x4731 // First 2D Greyscale; unused to date 19 | #define PMS2D_H1 0x4831 // SPEC HVPS 20 | #define PMS2D_P1 0x5031 // First PMS-2DP 21 | #define PMS2D_P2 0x5032 // Second PMS-2DP 22 | #define PMS2D_P4 0x5034 // First RAF 64 diode 200 um Fast 2DP 23 | #define PMS2D_P8 0x5038 // First DMT PIP probe 24 | #define PMS2D_3V 0x3348 // 3V-CPI 2DS Vertical 25 | #define PMS2D_3H 0x3356 // 3V-CPI 2DS Horizontal 26 | 27 | 28 | struct _oap_rec { 29 | int16_t id; // 'P1','C1','P2','C2', H1, etc 30 | int16_t hour; 31 | int16_t minute; 32 | int16_t second; 33 | int16_t year; // starting in 2007 w/ PACDEX 34 | int16_t month; // starting in 2007 w/ PACDEX 35 | int16_t day; // starting in 2007 w/ PACDEX 36 | int16_t tas; // true air speed, m/s 37 | int16_t msec; // msec of this record 38 | int16_t overld; // overload time, msec 39 | unsigned char data[TWOD_BUFF_SIZE]; // image buffer 40 | }; 41 | typedef struct _oap_rec OAP_rec; 42 | 43 | struct _pads_rec { 44 | uint16_t year; 45 | uint16_t month; 46 | uint16_t day; 47 | uint16_t hour; 48 | uint16_t minute; 49 | uint16_t second; 50 | uint16_t msec; 51 | uint16_t wday; 52 | unsigned char data[TWOD_BUFF_SIZE]; 53 | }; 54 | typedef struct _pads_rec PADS_rec; 55 | 56 | 57 | class Probe 58 | { 59 | public: 60 | Probe() : id(0), resolution(0), nDiodes(0) { } 61 | 62 | uint16_t id; 63 | int resolution; 64 | int nDiodes; 65 | std::string serialnumber; 66 | std::string suffix; 67 | }; 68 | 69 | 70 | 71 | class OAPfile 72 | { 73 | public: 74 | OAPfile() : _out(0) { }; 75 | ~OAPfile(); 76 | 77 | void open(const std::string& file_name); 78 | 79 | /** 80 | * @param id Probe ID, used to distinguish between multiple probes in the same file. 81 | * @param resolution probe resoultion in micrometers. 82 | * @param nDiodes is the number of diodes. 83 | * @param serialnumber is the probe serial number. Strictly meta-data. 84 | * @param suffix is used when merging data into a netCDF. All generated variables 85 | * will have this suffix. See process2d(1) program 86 | */ 87 | void AddProbe(uint16_t id, int resolution, int nDiodes, std::string serialnumber, std::string suffix); 88 | 89 | Probe ProbeData(size_t indx) { return _probelist[indx]; } 90 | 91 | void WriteHeader(); 92 | void WriteRecord(const OAP_rec&); 93 | 94 | void SetProject(std::string s) { _project = s; } 95 | void SetPlatform(std::string s) { _platform = s; } 96 | void SetFlightNumber(std::string s) { _flightnumber = s; } 97 | void SetFlightDate(std::string s) { _flightdate = s; } 98 | 99 | protected: 100 | FILE *_out; 101 | 102 | std::string _project; 103 | std::string _platform; 104 | std::string _flightnumber; 105 | std::string _flightdate; 106 | 107 | std::vector _probelist; 108 | }; 109 | 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /usb2diag/DataPlot.cc: -------------------------------------------------------------------------------- 1 | #include "DataPlot.h" 2 | 3 | 4 | /* -------------------------------------------------------------------- */ 5 | DataPlot::DataPlot(QWidget * parent, FILE * fp): QWidget(parent), _freeze(false) 6 | { 7 | //if find 64 8 | dm= new DataUsb2d64(fp); 9 | 10 | _freeze = 1; 11 | _count=0; 12 | _c=1; 13 | erase(rect()); 14 | Plot(); 15 | startTimer(2000); 16 | } 17 | 18 | /* -------------------------------------------------------------------- */ 19 | void DataPlot::ToggleFreeze() 20 | { 21 | _freeze = 1 - _freeze; 22 | 23 | } 24 | 25 | /* -------------------------------------------------------------------- */ 26 | void DataPlot::timerEvent(QTimerEvent *) 27 | { 28 | if (_freeze ||_count==0){ 29 | _count=1; 30 | return; 31 | } 32 | if (!dm->IsSameFSize()){ 33 | std::cout<<"\n timer plot...\n"; 34 | Plot(); 35 | } 36 | } 37 | 38 | /* -------------------------------------------------------------------- */ 39 | void DataPlot::RstTimer(int s) 40 | { 41 | killTimers(); 42 | startTimer(s*1000); 43 | } 44 | /* -------------------------------------------------------------------- */ 45 | void DataPlot::paintEvent(QPaintEvent * e) 46 | { 47 | QWidget::paintEvent(e); 48 | 49 | std::cout<<"\n repaint...\n"; 50 | Plot(false); 51 | } 52 | 53 | 54 | 55 | void DataPlot::Plot(bool pnew) 56 | { 57 | 58 | QTime t =QTime::currentTime(); 59 | std::cout<<"\n Plot... "<GetPoints(); std::cout<<"\nCall-GetPoints...\n"; 68 | } 69 | _drawIt(); 70 | _painter.end(); 71 | _freeze=0; 72 | 73 | t =QTime::currentTime(); 74 | std::cout<<" Plot end at... "<GetPArray(); 100 | 101 | if (pts->count() <= 0) { 102 | std::cout<<"\n _drawIt-- No plot points. \n"; 103 | _painter.setPen(Qt::black); 104 | _painter.drawText(20*_c, _c*35,"-- No plot points. \n"); 105 | //statusBar()->message( "Ready", 2000 ); 106 | _c++; 107 | if (_c>=10) {_c=1;} 108 | return; 109 | } 110 | _painter.setPen(Qt::blue); 111 | _painter.drawPoints(*pts, 0, pts->count()); 112 | 113 | QPointArray *ptsln=dm->GetPln(); 114 | _painter.setPen(Qt::green); 115 | for (unsigned int i=0; icount(); ++i) { 116 | QPoint p = (QPoint)ptsln->at(i); 117 | _painter.drawLine(p.x(), p.y(), p.x()+1024, p.y()); 118 | } 119 | 120 | _painter.setPen(Qt::black); 121 | QPointArray *ptstx=dm->GetPtx(); 122 | QString tx =dm->GetTx(); 123 | 124 | for (unsigned int i=0; icount(); ++i) { 125 | _painter.drawText(ptstx->at(i), tx.section( '~', i, i ) ); 126 | } 127 | // unsetCursor(); 128 | //QApplication::restoreOverrideCursor(); 129 | } 130 | 131 | -------------------------------------------------------------------------------- /xpms2d/class/define.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: define.h 4 | 5 | FULL NAME: Include File to Include the Include Files 6 | ------------------------------------------------------------------------- 7 | */ 8 | 9 | #ifndef DEFINE_H 10 | #define DEFINE_H 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | 25 | #define COMMENT '#' /* Comment character for textfiles */ 26 | 27 | #define SecondsSinceMidnite(t) (t[0] * 3600 + t[1] * 60 + t[2]) 28 | 29 | 30 | #define BUFFSIZE 4096 31 | #define PATH_LEN 1024 32 | 33 | const size_t MAX_DATAFILES = 2; 34 | const size_t MAX_PROBES = 4; 35 | 36 | 37 | #include 38 | 39 | 40 | /* Values for "displayLevel" */ 41 | enum { NORMAL, DIAGNOSTIC, RAW_RECORD }; 42 | 43 | /* Values for "HandleError" */ 44 | enum { RETURN, EXIT, IRET }; 45 | 46 | extern char *outFile, DataPath[], *timeSeg, pngPath[], psPath[]; 47 | 48 | extern bool Interactive, DataChanged, UTCseconds; 49 | 50 | void GetDataFileName(Widget, XtPointer, XtPointer), 51 | NewDataFile(Widget, XtPointer, XtPointer), 52 | AddDataFile(Widget, XtPointer, XtPointer), 53 | EditPrintParms(Widget, XtPointer, XtPointer), 54 | PrintSave(Widget, XtPointer, XtPointer), 55 | SavePNG(Widget, XtPointer, XtPointer), 56 | Quit(Widget, XtPointer, XtPointer); 57 | 58 | void CanvasExpose(Widget, XtPointer, XtPointer), 59 | CanvasInput(Widget, XtPointer, XtPointer), 60 | CanvasResize(Widget, XtPointer, XtPointer); 61 | 62 | void MagnifyExpose(Widget, XtPointer, XtPointer), 63 | MagnifyInput(Widget, XtPointer, XtPointer), 64 | MagnifyResize(Widget, XtPointer, XtPointer); 65 | 66 | void ApplyTimeChange(Widget, XtPointer, XtPointer), 67 | ModifyActiveVars(Widget, XtPointer, XtPointer), 68 | PageForward(Widget, XtPointer, XtPointer), 69 | PageBackward(Widget, XtPointer, XtPointer), 70 | ToggleWrap(Widget, XtPointer, XtPointer), 71 | ToggleTiming(Widget, XtPointer, XtPointer), 72 | ToggleHistogram(Widget, XtPointer, XtPointer), 73 | PageCurrent(), 74 | SetCurrentFile(Widget, XtPointer, XtPointer), 75 | ViewHex(Widget, XtPointer, XtPointer), 76 | ViewEnchilada(Widget, XtPointer, XtPointer), 77 | ViewHistogram(Widget, XtPointer, XtPointer), 78 | SetDensity(Widget, XtPointer, XtPointer), 79 | SetAreaRatioRej(Widget, XtPointer, XtPointer), 80 | SetConcentration(Widget, XtPointer, XtPointer), 81 | OpenURL(Widget, XtPointer, XtPointer), 82 | SetScaleTime(Widget, XtPointer, XtPointer), 83 | StartMovie(Widget, XtPointer, XtPointer), 84 | StopMovie(Widget, XtPointer, XtPointer), 85 | SetScaleSpeed(Widget, XtPointer, XtPointer), 86 | SetProbe(Widget, XtPointer, XtPointer), 87 | SetPanel(Widget, XtPointer, XtPointer); 88 | 89 | void DismissWindow(Widget, XtPointer, XtPointer), 90 | DestroyWindow(Widget, XtPointer, XtPointer), 91 | ToggleDisplay(Widget, XtPointer, XtPointer), 92 | ToggleSynthetic(Widget, XtPointer, XtPointer), 93 | 94 | ValidateTime(Widget w, XtPointer client, XtPointer call), 95 | ValidateFloat(Widget w, XtPointer client, XtPointer call), 96 | ValidateInteger(Widget w, XtPointer client, XtPointer call); 97 | 98 | void ErrorMsg(const char msg[]), FlushEvents(), 99 | WarnMsg(const char msg[], XtCallbackProc okCB, XtCallbackProc cancelCB); 100 | 101 | #endif 102 | 103 | /* END DEFINE.H */ 104 | -------------------------------------------------------------------------------- /xpms2d/class/Magnify.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: Magnify.cc 4 | 5 | FULL NAME: Magnify box control 6 | 7 | DESCRIPTION: 8 | 9 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 10 | ------------------------------------------------------------------------- 11 | */ 12 | 13 | #include "Magnify.h" 14 | #include "Colors.h" 15 | #include 16 | #include "MainCanvas.h" 17 | #include "MagnifyWindow.h" 18 | #include "MagnifyCanvas.h" 19 | 20 | void DoTheBox(Widget w, XtPointer client, XMotionEvent *evt, Boolean cont2disp); 21 | 22 | extern Colors *color; 23 | extern MainCanvas *mainPlot; 24 | extern MagnifyWindow *magWindow; 25 | extern MagnifyCanvas *magPlot; 26 | extern XPen *pen; 27 | 28 | 29 | /* -------------------------------------------------------------------- */ 30 | Magnify::Magnify() 31 | { 32 | startX = startY = endX = endY = 0; 33 | width = height = 0; 34 | 35 | } /* END CONSTRUCTOR */ 36 | 37 | /* -------------------------------------------------------------------- */ 38 | void Magnify::ProcessInput(XmDrawingAreaCallbackStruct *evt) 39 | { 40 | XButtonEvent *xb = (XButtonEvent *)evt->event; 41 | static bool cancel = false; 42 | 43 | if (xb->button != Button1) 44 | return; 45 | 46 | if ((xb->state & Button1Mask) == 0) 47 | startX = startY = endX = endY = 0; 48 | 49 | if ((xb->state & Button1Mask) == Button1Mask) 50 | { 51 | XtRemoveEventHandler(mainPlot->Wdgt(), Button1MotionMask, False, 52 | (XtEventHandler)DoTheBox, NULL); 53 | RemoveBox(); 54 | pen->SetFunction(GXcopy); 55 | } 56 | 57 | if ((xb->state & Button1Mask) != 0) 58 | if (cancel || endX < startX || endY < startY) 59 | return; 60 | 61 | if ((xb->state & Button1Mask) == 0) 62 | { 63 | cancel = false; 64 | 65 | startX = xb->x; 66 | startY = xb->y; 67 | 68 | pen->SetColor(color->GetColor(2)); 69 | pen->SetLineWidth(1); 70 | pen->SetFunction(GXxor); 71 | XtAddEventHandler(mainPlot->Wdgt(), Button1MotionMask, False, 72 | (XtEventHandler)DoTheBox, NULL); 73 | } 74 | else if ((xb->state & Button1Mask) == Button1Mask) 75 | { 76 | if (abs(startX - xb->x) < 10 || abs(startY - xb->y) < 10) 77 | return; 78 | 79 | endX = xb->x; 80 | endY = xb->y; 81 | 82 | width = endX - startX; 83 | height = endY - startY; 84 | 85 | magWindow->PopUp(); 86 | 87 | if (magPlot == NULL) 88 | magPlot = new MagnifyCanvas(magWindow->DrawingArea()); 89 | 90 | magPlot->draw(); 91 | } 92 | 93 | } /* END MAGNIFY */ 94 | 95 | /* -------------------------------------------------------------------- */ 96 | void Magnify::DrawBox(XMotionEvent *evt) 97 | { 98 | pen->SetColor(color->GetColor(2)); 99 | pen->SetLineWidth(1); 100 | 101 | if (endX != 0 && endY != 0) 102 | pen->DrawRectangle(mainPlot->Surface(), 103 | startX, startY, endX - startX, endY - startY); 104 | 105 | endX = evt->x; 106 | endY = evt->y; 107 | 108 | pen->DrawRectangle(mainPlot->Surface(), 109 | startX, startY, endX - startX, endY - startY); 110 | 111 | } /* END DRAWBOX */ 112 | 113 | /* -------------------------------------------------------------------- */ 114 | void Magnify::RemoveBox() 115 | { 116 | if (endX != 0 && endY != 0) 117 | pen->DrawRectangle(mainPlot->Surface(), 118 | startX, startY, endX - startX, endY - startY); 119 | 120 | } /* END REMOVEBOX */ 121 | 122 | /* END MAGNIFY.CC */ 123 | -------------------------------------------------------------------------------- /xpms2d/class/MainCanvas.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: MainCanvas.h 4 | 5 | FULL NAME: Main canvas 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef MAINCANVAS_H 12 | #define MAINCANVAS_H 13 | 14 | #include 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | 21 | /* -------------------------------------------------------------------- */ 22 | class MainCanvas : public Canvas { 23 | 24 | public: 25 | MainCanvas(Widget w); 26 | 27 | void SetDisplayMode(int mode); 28 | void SetWrapDisplay() { _wrap = 1 - _wrap; } 29 | void SetHistograms() { _histograms = 1 - _histograms; } 30 | void SetTimingWords() { _showTimingWords = 1 - _showTimingWords; } 31 | 32 | void reset(ADS_DataFile *file, OAP::P2d_rec *rec); 33 | void draw(OAP::P2d_rec *record, OAP::Probe *probe, float hdrVer, int probeNum, PostScript *ps); 34 | size_t maxRecords() const { return(_maxRecs); } 35 | int SpaceAvailable() const { return(Height() - y); } 36 | 37 | /** 38 | * Test if string s1 is all of same charcter c. Similar to memcmp, but testing 39 | * for a fixed value as if s1 was created by memset(3). 40 | * @returns 0 if nBytes of s1 matches c, else returns 1 for non-match. 41 | */ 42 | int memchrcmp(const void *s1, const int c, size_t n); 43 | 44 | 45 | protected: 46 | void setTitle(ADS_DataFile *file, OAP::P2d_rec *rec); 47 | 48 | void drawPMS2D(OAP::P2d_rec *record, OAP::Probe *probe, float hdrVer, int probeNum, PostScript *ps); 49 | void drawFast2D(OAP::P2d_rec *record, OAP::Probe *probe, float hdrVer, int probeNum, PostScript *ps); 50 | void draw2DS(OAP::P2d_rec *record, OAP::Probe *probe, float hdrVer, int probeNum, PostScript *ps); 51 | void drawHVPS(OAP::P2d_rec *record, OAP::Probe *probe, float hdrVer, int probeNum, PostScript *ps); 52 | void drawCIP(OAP::P2d_rec *record, OAP::Probe *probe, float hdrVer, int probeNum, PostScript *ps); 53 | 54 | void drawSlice(PostScript *ps, int i, const unsigned char *slice, OAP::Probe *probe); 55 | void drawSlice(PostScript *ps, int i, uint32_t slice); 56 | 57 | /** 58 | * Degrade a 25um Fast2DC probe to a 200um 2DP looking data. Done byr 59 | * looking at each 8x8 square and if more than 35 pixels are shadowed 60 | * then generate a pixel in the degraded image. This particles are shown 61 | * to the right of the regular data. 62 | */ 63 | void draw_2DC_as_2DP(OAP::P2d_rec *record); 64 | 65 | void drawRawRecord(const unsigned char *p, OAP::Probe *probe, PostScript *ps); 66 | 67 | /** 68 | * Count all shadowed diodes across the flight track and display histogram. 69 | * Routine needs to skip any sync and/or timing words. 70 | */ 71 | void drawDiodeHistogram(const unsigned char *data, OAP::Probe *probe); 72 | void drawDiodeHistogram(const unsigned char *data, OAP::Probe *probe, uint32_t sync); 73 | 74 | void drawAccumHistogram(struct OAP::recStats &stats, size_t xOffset); 75 | 76 | size_t uncompressCIP(unsigned char *dest, const unsigned char src[], int nbytes); 77 | 78 | int y, _maxRecs; 79 | int _displayMode; 80 | /// Number of pixels per row, nDiodes+38 for text. 81 | int _pixelsPerY; 82 | 83 | /// Wrap display around (HVPS mostly) 84 | bool _wrap; 85 | /// Display timing words or not. 86 | bool _showTimingWords; 87 | /// Display histograms on canvas (not Histogram Window). 88 | bool _histograms; 89 | 90 | }; /* END MAINCANVAS.H */ 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /process2d/probe.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Probe List: 3 | * 4 | * Fast2DC, Fast2DP (C4, C6 P4) 5 | * Fast2DC_v2, Fast2DP_v2 6 | * 2DS (SH, SV) 7 | * 3V-CPI (3H, 3V) 8 | * CIP, PIP (C8, P8) 9 | */ 10 | 11 | #ifndef _probeinfo_h_ 12 | #define _probeinfo_h_ 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include "config.h" 19 | 20 | 21 | /** 22 | * Probe information. 23 | */ 24 | class ProbeInfo 25 | { 26 | public: 27 | enum ProbeType { UNKNOWN, PMS2D, FAST2D, F2DS, HVPS, GREYSCALE, CIP }; 28 | enum ClockType { FIXED, TAS }; 29 | 30 | ProbeInfo(std::string tp, std::string new_id, std::string sn, int ndiodes, float res, 31 | std::string sfx, int binoffset, int numbins) 32 | 33 | : type(tp), id(new_id), serialNumber(sn), suffix(sfx), nDiodes(ndiodes), resolution(res), 34 | numBins(numbins), firstBin(binoffset), lastBin(numbins), armWidth(6.1), 35 | dof_const(2.37), clockMhz(1.0), dofMask(0x01), rle(false), clockType(TAS) 36 | { 37 | 38 | if (type.find("Fast2D") != std::string::npos) 39 | { 40 | clockType = FIXED; 41 | clockMhz = 12.0e+06; 42 | timingMask = 0x000000ffffffffffULL; 43 | 44 | if (type.find("_v2") != std::string::npos) 45 | { 46 | clockMhz = 33.33333333e+06; 47 | timingMask = 0x000003ffffffffffULL; 48 | } 49 | } 50 | 51 | if (id[0] == 'P') { // 2DP (P1 - P4) 52 | armWidth = 26.1; 53 | } 54 | 55 | if (id[0] == '3') // 3V-CPI 56 | { 57 | armWidth = 5.08; 58 | dof_const = 5.13; 59 | clockMhz = 20.0e+06; 60 | timingMask = 0x0000ffffffffffffULL; 61 | } 62 | 63 | if (id[0] == 'S') // 2DS 64 | { 65 | armWidth = 6.3; 66 | dof_const = 5.13; 67 | clockMhz = 20.0e+06; 68 | timingMask = 0x0000ffffffffffffULL; 69 | } 70 | 71 | if (id[0] == 'H') // HVPS 72 | { 73 | armWidth = 16.25; 74 | dof_const = 5.13; 75 | clockMhz = 20.0e+06; 76 | timingMask = 0x00000000ffffffffULL; 77 | } 78 | 79 | if (type.find("CIP") != std::string::npos || 80 | type.find("PIP") != std::string::npos) // DMT CIP/PIP 81 | { 82 | clockType = FIXED; 83 | clockMhz = 1.0e+06; 84 | rle = true; 85 | armWidth = 10.0; 86 | //armWidth = 7.0; // FAAM 100um CIP. 87 | if (type.find("PIP") != std::string::npos) 88 | { 89 | resolution = 100.0; 90 | armWidth = 26.0; // PIP (P8) 91 | } 92 | } 93 | } 94 | 95 | 96 | /** 97 | * User supplied BIN_EDGES, found in the PMSspecs file most likely. 98 | */ 99 | void SetBinEndpoints(std::string input); 100 | 101 | /** 102 | * Compute sample area of a probe for given diameter. 103 | * The sample area unit should be meter^2 for all probes. 104 | * @param eawmethod Are we doing particle reconstruction, center-in, or all-in. 105 | */ 106 | void ComputeSamplearea(Config::Method eawmethod); 107 | 108 | std::string type; // string probe name/type 109 | std::string id; // Two byte ID at the front of the data-record. 110 | std::string serialNumber; 111 | std::string suffix; 112 | int nDiodes; // 32, 64, or 128 at this time. 113 | float resolution; // micrometers 114 | int numBins; 115 | int firstBin, lastBin; 116 | float armWidth; // cm 117 | float dof_const; 118 | float clockMhz; // for timing words. 119 | unsigned long long timingMask; 120 | unsigned char dofMask;// Mask for dofReject flag. CIP/PIP, and Fast2D will use. 121 | bool rle; // Data buffers are Run Length Encoded. CIP/PIP are. 122 | ClockType clockType; // Timing words use fixed clock or tas based frequency. 123 | 124 | std::vector bin_endpoints; 125 | std::vector bin_midpoints; 126 | std::vector dof; // Depth Of Field 127 | std::vector eaw; // Effective Area Width 128 | std::vector samplearea; 129 | 130 | // Blank these times per $PROJ_DIR/$PROJECT/$PLATFORM/Production/BlankOAP_rf## 131 | std::vector > blank_out; 132 | }; 133 | 134 | #endif 135 | -------------------------------------------------------------------------------- /translate2ds/2DS.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "log.h" 3 | 4 | namespace sp 5 | { 6 | class File; 7 | class Block; 8 | //16 byte timestamp 9 | //4096 byte block 10 | //2 byte checksum 11 | //blocks can contain any of: verticle particle, horizontal particle, housekeeping, or mask 12 | class Device2DS 13 | { 14 | public: 15 | template 16 | void Process(Reader& f, Writer& writer); 17 | 18 | 19 | private: 20 | template 21 | void process_block( Block &block, Writer& writer ); 22 | 23 | 24 | Log _log; 25 | 26 | }; 27 | } 28 | 29 | #include "2DS.h" 30 | #include "File.h" 31 | #include "block.h" 32 | #include "PacketTypes.h" 33 | #include "HouseKeeping.h" 34 | #include "MaskData.h" 35 | #include "2DSParticle.h" 36 | 37 | namespace sp 38 | { 39 | static int nHouses = 0; 40 | 41 | template 42 | void Device2DS::Process( Reader& f, Writer& writer ) 43 | { 44 | TimeStamp16 time_stamp; 45 | Word check_sum; 46 | Block block(SIZE_DATA_BUF, f.SourceEndian(), f.DestinationEndian()); 47 | 48 | while(!f.empty()) 49 | { 50 | f >> time_stamp; 51 | writer << time_stamp; 52 | f >> block; 53 | f >> check_sum; 54 | 55 | process_block(block, writer); 56 | } 57 | _log <<"\nTotal Housekeeping packets: " << nHouses <<"\n"; 58 | } 59 | 60 | template< class Writer> 61 | void Device2DS::process_block( Block &block, Writer& writer ) 62 | { 63 | // _log << "\n\n+++++++++++++++++NEW BLOCK++++++++++++++++++++\n\n"; 64 | size_t head = 0; 65 | static ParticleRecord particle; 66 | try 67 | { 68 | Word w; 69 | while(block.remaining() >= sizeof(Word)) 70 | { 71 | head = block.head(); 72 | 73 | block >> w; 74 | 75 | 76 | switch(w) 77 | { 78 | case HOUSEKEEPING: 79 | { 80 | HouseKeeping hk; 81 | block >> hk; 82 | writer << hk; 83 | // _log << hk; 84 | nHouses++; 85 | // _log << "HouseK\n"; 86 | }break; 87 | case MASK: 88 | { 89 | MaskData md; 90 | block >>md; 91 | // _log << "(:Mask:)\n"; 92 | // _log << md; 93 | }break; 94 | case DATA: 95 | { 96 | static int PC =0; 97 | 98 | particle.clear(); 99 | 100 | block >> particle; 101 | writer << particle; 102 | PC++; 103 | /*if(word(particle.NumSlicesInParticle) > particle.HorizontalImage._data.size()) 104 | { 105 | _log <<"BAD\n"; 106 | }*/ 107 | // _log << particle2; 108 | 109 | // _log << "**ParticleFrame**\n"; 110 | }break; 111 | case FLUSH: 112 | { 113 | // _log << "FLUSH FRAME\n"; 114 | block.go_to_end(); 115 | }break; 116 | case 0: //indicates the end of the file it seems? 117 | { 118 | // _log << "END OF FILE\n"; 119 | block.go_to_end(); 120 | }break; 121 | default: 122 | { 123 | static int count = 0; 124 | block.clear(); 125 | word val= w; 126 | char first = val >> 8; // Push of last 8, so only first 8 remain 127 | char second = val & 0x00ff; // Select second 8 using mask 0000000011111111 128 | 129 | _log <<"\n2DS (" <> w; 136 | // word val= w; 137 | // char first = val >> 8; 138 | // char second = val & 0x00ff; 139 | 140 | // _log <<"\nGot a packet header that isn't recognized : " << word(w) << " ASCII: " << first << " " << second; 141 | //} 142 | // throw std::exception("bad"); 143 | 144 | }break; 145 | 146 | } 147 | } 148 | } 149 | catch (block_incomplete&) 150 | { 151 | // _log <<"\nBAD READ: " << "head: " << head << "cur: " << block.head(); 152 | //this means we ran into the end of the block before reading finished 153 | block.go_to(head); 154 | 155 | } 156 | 157 | block.clear(); 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /usb2diag/CanvasWindow.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: CanvasWindow.cc 4 | 5 | COPYRIGHT: University Corporation for Atmospheric Research, 2007 6 | ------------------------------------------------------------------------- 7 | */ 8 | 9 | #include "CanvasWindow.h" 10 | 11 | #include 12 | 13 | /* -------------------------------------------------------------------- */ 14 | CanvasWindow::CanvasWindow(QApplication *qApp, const char * file_name) : QMainWindow(0, "canvas"), _app(qApp), _fn((char*)file_name) 15 | { 16 | 17 | QToolBar *toolBar = new QToolBar(this, "options"); 18 | toolBar->setLabel( "" ); 19 | 20 | 21 | QToolButton *f = new QToolButton(toolBar); 22 | f->setTextLabel("OpenFile"); 23 | f->setUsesTextLabel(true); 24 | f->setUsesBigPixmap(false); 25 | connect(f, SIGNAL(clicked()), SLOT(_openf())); 26 | 27 | //QPopupMenu *o = new QPopupMenu( toolBar, "Option"); 28 | QToolButton *t = new QToolButton(toolBar); 29 | t->setTextLabel("TimeInterval"); 30 | t->setUsesTextLabel(true); 31 | t->setUsesBigPixmap(false); 32 | connect(t, SIGNAL(clicked()), SLOT(_rstTimer())); 33 | 34 | 35 | QToolButton *p = new QToolButton(toolBar); 36 | p->setTextLabel("Print"); 37 | p->setUsesTextLabel(true); 38 | p->setUsesBigPixmap(false); 39 | connect(p, SIGNAL(clicked()), SLOT(_print())); 40 | 41 | 42 | QToolButton *q = new QToolButton(toolBar); 43 | q->setTextLabel("Quit"); 44 | q->setUsesTextLabel(true); 45 | q->setUsesBigPixmap(false); 46 | connect(q, SIGNAL(clicked()), qApp, SLOT(quit())); 47 | 48 | _startplot(); 49 | statusBar()->message( "Ready", 2000 ); 50 | 51 | } /* END CONSTRUCTOR */ 52 | 53 | /* -------------------------------------------------------------------- */ 54 | void CanvasWindow::_openf() 55 | { 56 | QFileDialog *dlg = new QFileDialog(getenv("DATA_DIR"), QString::null, 0, 0, TRUE ); 57 | dlg->setCaption( QFileDialog::tr( "Open Data File" ) ); 58 | dlg->setMode( QFileDialog::ExistingFile ); 59 | 60 | QString file_name; 61 | if ( dlg->exec() == QDialog::Accepted ) { 62 | file_name = dlg->selectedFile(); 63 | std::cout << "selected name:" << file_name <<"\n"<show(); 88 | unsetCursor(); 89 | // QApplication::restoreOverrideCursor(); 90 | 91 | } 92 | /* END _startplot */ 93 | 94 | /* -------------------------------------------------------------------- */ 95 | void CanvasWindow::_rstTimer() 96 | { 97 | if (_fp==NULL) 98 | { 99 | QMessageBox::warning( this, "Time Interval", 100 | "Please open a data file first.\n" 101 | "", 0, 0, 1 ) ; 102 | return; 103 | } 104 | 105 | bool ok; 106 | int res = QInputDialog::getInteger( 107 | "Reset Timer", "Please enter a time interval (seconds):", 2, 0, 500, 2, 108 | &ok, this ); 109 | if ( !ok ) { 110 | std::cerr << "No Timer Interval entered. \n"<< std::endl; 111 | return; 112 | } 113 | std::cout << "Input t_interval:" << res <<"\n"<< std::endl; 114 | _plot->RstTimer(res); 115 | } /* END RstTimer */ 116 | 117 | 118 | /* -------------------------------------------------------------------- */ 119 | void CanvasWindow::_print() 120 | { 121 | if (_fp==NULL) 122 | { 123 | QMessageBox::warning( this, " Print", 124 | "Please open a data file first.\n" 125 | "", 0, 0, 1 ) ; 126 | return; 127 | } 128 | 129 | _plot->Prt(); 130 | } /* END PRINT */ 131 | 132 | 133 | 134 | /* END CANVASWINDOW.CC */ 135 | -------------------------------------------------------------------------------- /xpms2d/src/cb_text.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: cb_text.cc 4 | 5 | FULL NAME: Callbacks to TextWindow(s) 6 | 7 | ENTRY POINTS: ViewHex() 8 | DismissText() 9 | SaveText() 10 | PrintText() 11 | 12 | DESCRIPTION: SaveText2() 13 | 14 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 15 | ------------------------------------------------------------------------- 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | extern Application *application; 30 | extern Printer *printerSetup; 31 | extern XCursor cursor; 32 | extern XmFile *fileSel; 33 | 34 | static Hex *hexWin = NULL; 35 | Enchilada *enchiladaWin = NULL; 36 | Histogram *histogramWin = NULL; 37 | 38 | extern int nBuffs; 39 | extern OAP::P2d_rec pgFbuff[]; 40 | 41 | /* -------------------------------------------------------------------- */ 42 | void ViewEnchilada(Widget w, XtPointer client, XtPointer call) 43 | { 44 | if (nBuffs == 0) 45 | return; 46 | 47 | if (!enchiladaWin) 48 | enchiladaWin = new Enchilada(application->Shell()); 49 | 50 | enchiladaWin->PopUp(); 51 | PageCurrent(); 52 | } 53 | 54 | /* -------------------------------------------------------------------- */ 55 | void ViewHistogram(Widget w, XtPointer client, XtPointer call) 56 | { 57 | if (nBuffs == 0) 58 | return; 59 | 60 | if (!histogramWin) 61 | histogramWin = new Histogram(application->Shell()); 62 | 63 | histogramWin->PopUp(); 64 | PageCurrent(); 65 | } 66 | 67 | /* -------------------------------------------------------------------- */ 68 | void ViewHex(Widget w, XtPointer client, XtPointer call) 69 | { 70 | if (nBuffs == 0) 71 | return; 72 | 73 | if (!hexWin) 74 | hexWin = new Hex(application->Shell()); 75 | 76 | hexWin->Update(nBuffs, pgFbuff); 77 | hexWin->PopUp(); 78 | } 79 | 80 | /* -------------------------------------------------------------------- */ 81 | void DismissText(Widget w, XtPointer client, XtPointer call) 82 | { 83 | TextWindow *obj = (TextWindow *)client; 84 | 85 | obj->Clear(); 86 | obj->PopDown(); 87 | } 88 | 89 | /* -------------------------------------------------------------------- */ 90 | void PrintText(Widget w, XtPointer client, XtPointer call) 91 | { 92 | FILE *fp; 93 | char *p; 94 | 95 | // cursor.WaitCursor(application->Shell()); 96 | cursor.WaitCursor((Widget)client); 97 | 98 | if ((fp = popen(printerSetup->lpCommand(), "w")) == NULL) 99 | { 100 | ErrorMsg("Print: can't open pipe to 'lp'"); 101 | return; 102 | } 103 | 104 | p = XmTextGetString((Widget)client); 105 | 106 | fprintf(fp, "%s\n", p); 107 | XtFree(p); 108 | 109 | pclose(fp); 110 | 111 | cursor.PointerCursor((Widget)client); 112 | // cursor.PointerCursor(application->Shell()); 113 | } 114 | 115 | /* -------------------------------------------------------------------- */ 116 | static Widget tmpText; 117 | 118 | void SaveText2(Widget w, XtPointer client, XtPointer call) 119 | { 120 | FILE *fp; 121 | char *p, *dataFile; 122 | 123 | fileSel->ExtractFileName( 124 | ((XmFileSelectionBoxCallbackStruct *)call)->value, &dataFile); 125 | 126 | if ((fp = fopen(dataFile, "w")) == NULL) 127 | { 128 | char buffer[256]; 129 | snprintf(buffer, 256, "SaveText: can't open %s.", dataFile); 130 | ErrorMsg(buffer); 131 | return; 132 | } 133 | 134 | p = XmTextGetString(tmpText); 135 | fprintf(fp, "%s\n", p); 136 | XtFree(p); 137 | 138 | fclose(fp); 139 | } 140 | 141 | /* -------------------------------------------------------------------- */ 142 | void SearchText(Widget w, XtPointer client, XtPointer call) 143 | { 144 | ((TextWindow *)client)->Search(); 145 | } 146 | 147 | /* -------------------------------------------------------------------- */ 148 | void SaveText(Widget w, XtPointer client, XtPointer call) 149 | { 150 | tmpText = (Widget)client; 151 | 152 | fileSel->QueryFile("Enter file name to save as:", DataPath, (XtCallbackProc)SaveText2); 153 | } 154 | -------------------------------------------------------------------------------- /xpms2d/src/xpms2d.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: xpms2d.cc 4 | 5 | FULL NAME: X PMS 2D 6 | 7 | ENTRY POINTS: main() 8 | ErrorMsg() 9 | 10 | STATIC FNS: Initialize() 11 | ProcessArgs() 12 | 13 | DESCRIPTION: See man page. 14 | 15 | INPUT: Command line options 16 | 17 | AUTHOR: cjw@ucar.edu 18 | 19 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 20 | ------------------------------------------------------------------------- 21 | */ 22 | 23 | #include 24 | 25 | #include "define.h" 26 | #include "fbr.h" 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include "DataFile.h" 34 | #include "FileMgr.h" 35 | #include "Magnify.h" 36 | #include "MagnifyWindow.h" 37 | #include "MagnifyCanvas.h" 38 | #include "MainCanvas.h" 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | Application *application; 48 | CanvasWindow *canvasWindow; 49 | ControlWindow *controlWindow; 50 | Magnify *mag; 51 | MagnifyWindow *magWindow; 52 | MagnifyCanvas *magPlot = NULL; 53 | MainCanvas *mainPlot = NULL; 54 | OAP::UserConfig userConfig; 55 | XCursor cursor; 56 | Printer *printerSetup; 57 | Colors *color; 58 | 59 | FileManager fileMgr; 60 | 61 | XFonts *fonts; 62 | XPen *pen; 63 | XmFile *fileSel; 64 | 65 | 66 | static void Initialize(); 67 | static void ProcessArgs(char *argv[]); 68 | 69 | 70 | /* --------------------------------------------------------------------- */ 71 | int main(int argc, char *argv[]) 72 | { 73 | application = new Application("XmPMS2D", &argc, argv, fallback_resources); 74 | canvasWindow = new CanvasWindow(application->Shell()); 75 | controlWindow = new ControlWindow(application->Shell()); 76 | magWindow = new MagnifyWindow(application->Shell()); 77 | 78 | printerSetup = new Printer(application->Shell()); 79 | mag = new Magnify(); 80 | 81 | Initialize(); 82 | ProcessArgs(argv); 83 | 84 | fileSel = new XmFile(application->Shell()); 85 | 86 | canvasWindow->PopUp(); 87 | controlWindow->PopUp(); 88 | 89 | fonts = new XFonts(application->Shell()); 90 | pen = new XPen(canvasWindow->DrawingArea()); 91 | color = new Colors(canvasWindow->DrawingArea()); 92 | mainPlot = new MainCanvas(canvasWindow->DrawingArea()); 93 | 94 | XtAppMainLoop(application->Context()); 95 | 96 | return(0); 97 | 98 | } /* END MAIN */ 99 | 100 | /* --------------------------------------------------------------------- */ 101 | static void Initialize() 102 | { 103 | char *p; 104 | 105 | DataChanged = true; 106 | UTCseconds = false; 107 | 108 | if ((p = (char *)getenv("RAW_DATA_DIR")) == NULL) 109 | p = (char *)getenv("DATA_DIR"); 110 | 111 | if (p != NULL) 112 | { 113 | strcpy(DataPath, p); 114 | strcat(DataPath, "/*2d*"); 115 | } 116 | else 117 | strcpy(DataPath, "*2d*"); 118 | 119 | strcpy(pngPath, "*.png"); 120 | strcpy(psPath, "*.ps"); 121 | 122 | } /* END INITIALIZE */ 123 | 124 | /* --------------------------------------------------------------------- */ 125 | static void ProcessArgs(char **argv) 126 | { 127 | while (*++argv) 128 | if ((*argv)[0] == '-') 129 | switch ((*argv)[1]) 130 | { 131 | } 132 | else 133 | { 134 | if (access(*argv, R_OK) == 0) 135 | fileMgr.NewFile(*argv, userConfig); 136 | } 137 | 138 | } /* END PROCESSARGS */ 139 | 140 | /* --------------------------------------------------------------------- */ 141 | void ErrorMsg(const char msg[]) 142 | { 143 | new XmError(application->Shell(), msg); 144 | 145 | } /* END ERRORMSG */ 146 | 147 | /* --------------------------------------------------------------------- */ 148 | void WarnMsg(const char msg[], XtCallbackProc okCB, XtCallbackProc cancelCB) 149 | { 150 | new XmWarn(application->Shell(), msg, okCB, cancelCB); 151 | 152 | } /* END WARNMSG */ 153 | 154 | /* --------------------------------------------------------------------- */ 155 | void FlushEvents() 156 | { 157 | application->FlushEvents(); 158 | 159 | } /* END FLUSHEVENTS */ 160 | 161 | /* END XPMS2D.CC */ 162 | -------------------------------------------------------------------------------- /xpms2d/class/CanvasWindow.cc: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: CanvasWindow.cc 4 | 5 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 6 | ------------------------------------------------------------------------- 7 | */ 8 | 9 | #include "CanvasWindow.h" 10 | 11 | struct menu 12 | { 13 | const char *title; 14 | void (*callback)(Widget, XtPointer, XtPointer); 15 | XtPointer callData; 16 | } ; 17 | 18 | static struct menu fileMenu[] = { 19 | { "newFile", GetDataFileName, (XtPointer)NewDataFile, }, 20 | // { "addFile", GetDataFileName, (XtPointer)AddDataFile, }, 21 | { "separator", NULL, NULL, }, 22 | { "printSetup", EditPrintParms, (XtPointer)NULL, }, 23 | { "savePS", PrintSave, (XtPointer)1, }, 24 | { "print", PrintSave, NULL, }, 25 | #ifdef PNG 26 | { "separator", NULL, NULL, }, 27 | { "savePNG", SavePNG, NULL, }, 28 | #endif 29 | { "separator", NULL, NULL, }, 30 | { "quit", Quit, NULL, }, 31 | { NULL, NULL, NULL }}; 32 | 33 | static struct menu legendMenu[] = { 34 | // { "editParms", EditMainParms, NULL, }, 35 | { NULL, NULL, NULL }}; 36 | 37 | static struct menu viewMenu[] = { 38 | { "viewHex", ViewHex, NULL, }, 39 | { "viewHisto", ViewHistogram, NULL, }, 40 | { "viewAll", ViewEnchilada, NULL, }, 41 | { "separator", NULL, NULL, }, 42 | { "viewData", ToggleDisplay, (XtPointer)NORMAL, }, 43 | { "viewDiag", ToggleDisplay, (XtPointer)DIAGNOSTIC, }, 44 | { "viewRaw", ToggleDisplay, (XtPointer)RAW_RECORD, }, 45 | { NULL, NULL, NULL }}; 46 | 47 | static struct menu optMenu[] = { 48 | { "toggleTiming", ToggleTiming, (XtPointer)NULL, }, 49 | { "toggleHisto", ToggleHistogram, (XtPointer)NULL, }, 50 | { "wrapDisplay", ToggleWrap, (XtPointer)NULL, }, 51 | { "synthetic", ToggleSynthetic, (XtPointer)NULL, }, 52 | { NULL, NULL, NULL }}; 53 | 54 | static struct menu helpMenu[] = { 55 | { "EOL Homepage", OpenURL, (XtPointer)1 }, 56 | { "RAF Software Page", OpenURL, (XtPointer)2 }, 57 | { "xpms2d User's Manual", OpenURL, (XtPointer)3 }, 58 | { NULL, NULL, NULL }}; 59 | 60 | static struct 61 | { 62 | const char *title; 63 | struct menu *sub; 64 | } main_menu[] = { 65 | { "File", fileMenu, }, 66 | // { "Edit", legendMenu, }, 67 | { "View", viewMenu, }, 68 | { "Options", optMenu, }, 69 | { "Help", helpMenu, }, 70 | { NULL, NULL }}; 71 | 72 | 73 | /* -------------------------------------------------------------------- */ 74 | CanvasWindow::CanvasWindow(Widget parent) : WinForm(parent, "canvas", Form) 75 | { 76 | int i, j; 77 | Cardinal n; 78 | Arg args[8]; 79 | Widget menubar, menu[5], bttn[16], menu_button[5]; 80 | 81 | 82 | n = 0; 83 | menubar = XmCreateMenuBar(Window(), (char *)"menuBar", args, n); 84 | XtManageChild(menubar); 85 | 86 | for (i = 0; main_menu[i].title; ++i) 87 | { 88 | n = 0; 89 | menu[i] = XmCreatePulldownMenu(menubar, (char *)main_menu[i].title, args, n); 90 | 91 | n = 0; 92 | XtSetArg(args[n], XmNsubMenuId, menu[i]); ++n; 93 | menu_button[i] = XmCreateCascadeButton(menubar, (char *)main_menu[i].title, args,n); 94 | 95 | for (j = 0; main_menu[i].sub[j].title; ++j) 96 | { 97 | n = 0; 98 | 99 | if (main_menu[i].sub[j].callback == NULL) 100 | { 101 | bttn[j] = XmCreateSeparator(menu[i], (char *)main_menu[i].sub[j].title, args,n); 102 | continue; 103 | } 104 | 105 | bttn[j] = XmCreatePushButton(menu[i], (char *)main_menu[i].sub[j].title, args, n); 106 | XtAddCallback(bttn[j], XmNactivateCallback, 107 | main_menu[i].sub[j].callback, (void *)main_menu[i].sub[j].callData); 108 | } 109 | 110 | XtManageChildren(bttn, j); 111 | } 112 | 113 | XtManageChildren(menu_button, i); 114 | 115 | 116 | 117 | /* Create Graphics Canvas 118 | */ 119 | n = 0; 120 | XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; 121 | XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; 122 | XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; 123 | XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; 124 | drawA = XmCreateDrawingArea(Window(), (char *)"canvas", args, n); 125 | 126 | XtAddCallback(drawA, XmNexposeCallback, (XtCallbackProc)CanvasExpose, NULL); 127 | XtAddCallback(drawA, XmNinputCallback, (XtCallbackProc)CanvasInput, NULL); 128 | XtAddCallback(drawA, XmNresizeCallback, (XtCallbackProc)CanvasResize, NULL); 129 | 130 | XtManageChild(drawA); 131 | 132 | } /* END CONSTRUCTOR */ 133 | 134 | /* END CANVASWINDOW.CC */ 135 | -------------------------------------------------------------------------------- /xpms2d/class/DataFile.h: -------------------------------------------------------------------------------- 1 | /* 2 | ------------------------------------------------------------------------- 3 | OBJECT NAME: DataFile.h 4 | 5 | FULL NAME: Data File Class 6 | 7 | COPYRIGHT: University Corporation for Atmospheric Research, 1997-2018 8 | ------------------------------------------------------------------------- 9 | */ 10 | 11 | #ifndef _OAP_DATAFILE_H_ 12 | #define _OAP_DATAFILE_H_ 13 | 14 | #ifdef PNG 15 | #include 16 | #endif 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | // ADS image record types 29 | #define ADS_WORD 0x4144 30 | #define HDR_WORD 0x5448 31 | #define SDI_WORD 0x8681 32 | #define AVAPS_WORD 0x4156 33 | 34 | #define PMS2_SIZE 4116 35 | #define PMS2_RECSIZE (0x8000 / PMS2_SIZE) * PMS2_SIZE 36 | 37 | namespace OAP 38 | { 39 | class UserConfig; 40 | } 41 | 42 | 43 | /** 44 | * Probe mapping uses the 2 byte key/id in every data record. Once 45 | * you have a record, you can get the Probe info from the ProbeList. 46 | */ 47 | typedef std::map ProbeList; 48 | 49 | 50 | /* -------------------------------------------------------------------- */ 51 | class ADS_DataFile { 52 | 53 | public: 54 | ADS_DataFile(const char fName[], OAP::UserConfig &cfg); 55 | ~ADS_DataFile(); 56 | 57 | const std::string & 58 | FileName() const { return _fileName; } 59 | 60 | /** 61 | * For ADS2, this will be the ADS2 header version number; up to 3.5. 62 | * For ADS3 and the new OAP file format we force this to start at 5. 63 | * add the OAP version to 5. 64 | */ 65 | const char * 66 | HeaderVersion() const { return _version; } 67 | 68 | const std::string & 69 | ProjectNumber() const { return _projectName; } 70 | 71 | const std::string & 72 | FlightNumber() const { return _flightNumber; } 73 | 74 | const std::string & 75 | FlightDate() const { return _flightDate; } 76 | 77 | void SetPosition(int position); 78 | 79 | int 80 | GetPosition() const { return(_indices.size() == 0 ? 0 : 100 * currPhys / _indices.size()); } 81 | 82 | // int NextSyncRecord(char buff[]); 83 | bool LocatePMS2dRecord(OAP::P2d_rec *buff, int h, int m, int s); 84 | bool FirstPMS2dRecord(OAP::P2d_rec *buff); 85 | bool NextPMS2dRecord(OAP::P2d_rec *buff); 86 | bool PrevPMS2dRecord(OAP::P2d_rec *buff); 87 | 88 | int NextPhysicalRecord(unsigned char buff[]); 89 | 90 | void ToggleSyntheticData(); 91 | 92 | bool isValidProbe(const unsigned char *pr) const; 93 | 94 | OAP::Probe *ProbeP(uint32_t id) { return _probeList[id]; } 95 | 96 | const ProbeList& 97 | Probes() const { return _probeList; } 98 | 99 | 100 | protected: 101 | enum HeaderType { NoHeader, ADS2, OAP }; 102 | 103 | struct Index { uint64_t index; int16_t time[4]; }; 104 | 105 | void initADS2(OAP::UserConfig *cfg); 106 | void initADS3(const char *hdrString, OAP::UserConfig *cfg); 107 | 108 | /* Add probe based on id word in old ADS2 header. These are really 109 | * old files, or from University of Wyoming 110 | */ 111 | void AddToProbeList(const char *id, OAP::UserConfig *cfg); 112 | /* Add probe based on the XML entry in an OAP file. 113 | */ 114 | void AddToProbeListFromXML(const char *id, OAP::UserConfig *cfg); 115 | 116 | uint64_t posOfPhysicalRecord(size_t i) { 117 | if (i > _indices.size()) fprintf(stderr, "currPhys exceeds nIndices\n"); 118 | return _indices[i].index; 119 | } 120 | 121 | void buildIndices(OAP::UserConfig *cfg), sort_the_table(int, int), SortIndices(int); 122 | time_t getFileModifyTime(const char *path); 123 | 124 | void SwapPMS2D(OAP::P2d_rec *); 125 | void check_rico_half_buff(OAP::P2d_rec *buff, size_t start, size_t end); 126 | 127 | std::string _fileName; 128 | 129 | std::string _projectName; 130 | std::string _flightNumber; 131 | std::string _flightDate; 132 | 133 | Header *_hdr; 134 | #ifdef PNG 135 | gzFile gz_fd; 136 | #else 137 | int gz_fd; 138 | #endif 139 | FILE *fp; 140 | uint64_t _savePos; 141 | 142 | ProbeList _probeList; 143 | 144 | bool _gzipped, _useTestRecord; 145 | HeaderType _fileHeaderType; 146 | 147 | /** 148 | * For ADS2, this will be the ADS2 header version number; up to 3.5. 149 | * For ADS3 and the new OAP file format we force this to start at 5. 150 | * add the OAP version to 5. 151 | */ 152 | char _version[16]; 153 | 154 | std::vector _indices; 155 | int currPhys; 156 | int currLR; 157 | 158 | OAP::P2d_rec physRecord[P2DLRPR], *testRecP; 159 | 160 | }; /* END DATAFILE.H */ 161 | 162 | #endif 163 | -------------------------------------------------------------------------------- /usb2diag/DataUsb2d64.cc: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "DataUsb2d64.h" 4 | 5 | 6 | const unsigned long long DataUsb2d64::_syncWord = 0xAAAAAA0000000000LL; 7 | const unsigned long long DataUsb2d64::_syncMask = 0xFFFFFF0000000000LL; 8 | 9 | /* -------------------------------------------------------------------- */ 10 | DataUsb2d64::DataUsb2d64 (FILE * fp) :DataMng(fp, 64) 11 | { 12 | SetBt(64); 13 | Setfp(fp); 14 | Init(); 15 | } 16 | 17 | /* -------------------------------------------------------------------- */ 18 | QPointArray* DataUsb2d64::GetPoints() 19 | { 20 | if (!_chkInit()) {return NULL;} 21 | _pts= new QPointArray(TBYTE*8*_row_n*_rcdpr_n); 22 | _ptstx= new QPointArray(_row_n*_rcdpr_n); 23 | _ptsln= new QPointArray(_row_n); 24 | _text =""; 25 | _get2drec(); 26 | 27 | if (_hdr==NULL && _twod_rec==NULL) {_pts->resize(0); return _pts;} 28 | size_t xleft =5, ytop =8, rheight=27; 29 | size_t x, y = ytop; 30 | _cnt = 0; 31 | for (int i = 0; i < _row_n; ++i) 32 | { 33 | x = xleft; 34 | for (int j = 0; j< _rcdpr_n; ++j) 35 | { 36 | _getRecord(x, y, (unsigned char*)_twod_rec[i*_rcdpr_n+j].data); 37 | x += _slide_n; 38 | _text =_text +"Time:" + _gettw(_hdr[i*_rcdpr_n+j].timetag) 39 | +" Tas:" +QString().setNum(_twod_rec[i*_rcdpr_n+j].tas) + "~"; 40 | _ptstx->setPoint(i*_rcdpr_n+j, xleft+j*_slide_n, y+_bit_n+14); 41 | } 42 | _ptsln->setPoint(i, xleft, y-1); 43 | y += _bit_n+rheight; 44 | } 45 | 46 | _pts->resize(_cnt ); 47 | return _pts; 48 | } 49 | 50 | /* -------------------------------------------------------------------- */ 51 | void DataUsb2d64::_getRecord(int start_x, int start_y, unsigned char * data_p) 52 | { 53 | for (int i = 0; i < _slide_n; ++i) 54 | { 55 | //get and flip slide 56 | unsigned char s1[_byte_n];//_byte_n=8 57 | for (int n=0; n<_byte_n; ++n) { 58 | s1[7-n]=*data_p; data_p++; 59 | } 60 | 61 | unsigned long long slide = *(unsigned long long*)s1; 62 | //if ((slide & _syncMask) == _syncWord) 63 | // printf("\ntime_wd:%llu\n", slide & ~_syncMask); // Print timing word. 64 | 65 | slide = ~slide; 66 | //check every bit 67 | unsigned long long mask =1; 68 | for (int b=0; b<_bit_n; ++b) { //_bit_n=64 69 | if (mask & slide) { 70 | _pts->setPoint(_cnt, start_x + i, start_y + _bit_n-b); 71 | ++_cnt; 72 | } 73 | mask*=2; 74 | }//b 75 | }//i 76 | } 77 | 78 | 79 | /* -------------------------------------------------------------------- */ 80 | void DataUsb2d64::_get2drec() { 81 | int trcd = _row_n*_rcdpr_n; 82 | _hdr = new nidas_hdr[trcd]; 83 | _twod_rec = new usb2d_rec[trcd]; 84 | 85 | fsetpos(_fp, &_pp); 86 | fpos_t tmp=_pp; 87 | int c = 0, tc=0; 88 | //get the last few records 89 | while (!feof(_fp)){ 90 | nidas_hdr h; 91 | usb2d_rec d; 92 | 93 | fread(&h, sizeof(nidas_hdr), 1, _fp); 94 | if (h.length==(unsigned short)_byte_usb2d_rcd) 95 | { 96 | fread(&d, h.length, 1, _fp); 97 | _hdr[c]=h; 98 | _twod_rec[c]=d; 99 | //printf("-----%llu %lu %lu %lx %lx\n", h.timetag, h.length, 100 | // h.sample_id, d.tas, d.id); 101 | c++; tc++; 102 | if (c>=trcd) { 103 | c=0; 104 | _pp=tmp; 105 | fgetpos(_fp, &tmp); 106 | }//if 107 | 108 | } else { 109 | //fseek (_fp, h.length, SEEK_CUR ); 110 | unsigned char dd[h.length]; 111 | fread(&dd, h.length, 1, _fp); 112 | } 113 | } //while 114 | 115 | if (tc==0) {_hdr=NULL; _twod_rec=NULL; return;} 116 | //put cycled buff back to the order 117 | nidas_hdr hdr[trcd]; 118 | usb2d_rec twod_rec[trcd]; 119 | 120 | if ((c> 0)&& (_hdr[c].length>0)) { 121 | for (int i =0; i=trcd) {c=0;} 126 | } 127 | //back to _hdr and _twod_rec 128 | for (int i =0; i 4 | #include 5 | 6 | namespace sp 7 | { 8 | struct ParticleInfo 9 | { 10 | struct Bits 11 | { 12 | word NumDataWords:12; 13 | word TimingWordsNotFound:1; //bit 12 14 | word TimingWordMismatch:1; //only seems to be used on the vertical part..? 15 | word FIFO_Empty:1; 16 | word HasOverloadTimingWords:1; //indicates that last two words of data record are timing words 17 | }; 18 | union 19 | { 20 | word All; 21 | Bits bits; 22 | }; 23 | 24 | bool HasTimingWord()const{return bits.TimingWordsNotFound == 0;}//bits.HasOverloadTimingWords == 1;} 25 | }; 26 | 27 | template 28 | inline T& operator >> (T& reader, ParticleInfo& in) 29 | { 30 | reader.read(in.All); 31 | return reader; 32 | }; 33 | 34 | template 35 | inline T& operator << (T& writer, ParticleInfo& in) 36 | { 37 | writer.write(reinterpret_cast(&in.All),sizeof(in.All)); 38 | return writer; 39 | }; 40 | 41 | inline Log& operator << (Log& log, ParticleInfo& out) 42 | { 43 | return log << "\nNumDataWords: " << out.bits.NumDataWords << 44 | "\nTimingWordsNotFound: " << out.bits.TimingWordsNotFound; 45 | }; 46 | 47 | struct ImageChunk 48 | { 49 | word GetClearCount()const 50 | { 51 | const word* all = reinterpret_cast(this); 52 | if(0x7FFF == *all) 53 | { 54 | return 128; 55 | } 56 | else if(0x4000 == *all) 57 | { 58 | return 0; 59 | } 60 | return NumClearPixels; 61 | } 62 | 63 | word GetShadedCount()const 64 | { 65 | const word* all = reinterpret_cast(this); 66 | if(0x4000 == *all) 67 | { 68 | return 128; 69 | } 70 | else if(0x7FFF == *all) 71 | { 72 | return 0; 73 | } 74 | return NumShadedPixels; 75 | } 76 | 77 | void SetMaxShade() 78 | { *reinterpret_cast(this) = 0x4000; } 79 | 80 | void SetMaxClear() 81 | { *reinterpret_cast(this) = 0x7FFF; } 82 | 83 | bool IsUncompressed() const 84 | { return *reinterpret_cast(this) == 0x7FFF; } 85 | 86 | bool IsStartOfSlice() const 87 | { return StartOfSlice == 1; } 88 | 89 | void swapEndian() 90 | { swap_endian_force(reinterpret_cast(this),sizeof(ImageChunk)); } 91 | 92 | 93 | word NumClearPixels:7; 94 | word NumShadedPixels:7; 95 | word StartOfSlice:1; //1 for start of slice, 0 for continuation 96 | word ImageWord:1; //0 indicates image word..? 97 | }; 98 | 99 | template 100 | inline T& operator << (T& writer, ImageChunk& im) 101 | { 102 | writer.write(reinterpret_cast(&im),sizeof(word)); 103 | return writer; 104 | } 105 | struct ImageData 106 | { 107 | ParticleInfo _Description; 108 | typedef std::vector Data; 109 | Data _data; 110 | Timing _time; 111 | 112 | void clear() { _data.clear(); } 113 | 114 | Timing Time() const 115 | { 116 | return _time; 117 | } 118 | }; 119 | 120 | inline Log& operator << (Log& log, ImageData& out) 121 | { 122 | return log; 123 | //return log << "\nImageWord: " << out.bits.ImageWord << 124 | // "\nStartOfSlice: " << out.bits.StartOfSlice << 125 | // "\nNumShadedPixels: " << out.bits.NumShadedPixels << 126 | // "\nNumClearPixels: " << out.bits.NumClearPixels; 127 | }; 128 | 129 | template 130 | inline T& operator >> (T& reader, ImageData& in) 131 | { 132 | int WordsToRead = in._Description.bits.NumDataWords; 133 | 134 | if(WordsToRead == 0) 135 | { 136 | return reader; 137 | } 138 | 139 | bool HasTiming = in._Description.HasTimingWord(); 140 | if(HasTiming) 141 | { 142 | assert(WordsToRead >1); 143 | WordsToRead -= 2; 144 | } 145 | 146 | if(WordsToRead > 0) 147 | { 148 | in._data.resize(WordsToRead); 149 | reader.read(reinterpret_cast(&in._data[0]),WordsToRead*sizeof(word) ); 150 | } 151 | 152 | if(HasTiming) 153 | { 154 | reader >> in._time; 155 | } 156 | 157 | return reader; 158 | }; 159 | 160 | template 161 | inline T& operator << (T& writer, ImageData& im) 162 | { 163 | for(size_t i = 0;i 187 | inline T& operator >> (T& reader, ParticleRecord& in) 188 | { 189 | reader >> in.HorizontalImage._Description >> in. VerticalImage._Description >> 190 | in.ParticleCount >> in.NumSlicesInParticle; 191 | 192 | // if(in.HorizontalImage._Description.bits.NumDataWords > 0) 193 | { 194 | reader >> in.HorizontalImage; 195 | } 196 | // if(in.VerticalImage._Description.bits.NumDataWords > 0) 197 | { 198 | reader >> in.VerticalImage; 199 | } 200 | return reader; 201 | // in.HorizontalImage >> in.VerticalImage; 202 | }; 203 | 204 | 205 | template 206 | inline T& operator << (T& writer, ParticleRecord& pr) 207 | { 208 | writer << pr.PacketID << pr.HorizontalImage._Description 209 | << pr. VerticalImage._Description 210 | << pr.ParticleCount << pr.NumSlicesInParticle; 211 | 212 | writer << pr.HorizontalImage; 213 | writer << pr.VerticalImage; 214 | 215 | return writer; 216 | }; 217 | 218 | 219 | //inline Log& operator << (Log& log, ParticleRecord& out) 220 | //{ 221 | // return log << "\n\n***Horizontal Image***:" << out.HorizontalImage._Description << 222 | // "\n\n***Vertical Image***:" << out.VerticalImage._Description << 223 | // "\nHParticleCount:\t" << out.ParticleCount << 224 | // "\nNumSlicesInParticle:\t" << out.NumSlicesInParticle << 225 | // "\n\n***Horizontal Image***:" < 4 | #include 5 | 6 | namespace sp 7 | { 8 | struct ParticleInfo3VCPI 9 | { 10 | struct Bits 11 | { 12 | word NumDataWords:12; 13 | word ExceededMaxSize:1; 14 | word Unused:1; //always 0 15 | word ParticleTriggered:1; 16 | word FIFO_Overflow:1; 17 | }; 18 | union 19 | { 20 | word All; 21 | 22 | Bits bits; 23 | }; 24 | 25 | bool HasTimingWord() const 26 | { 27 | return bits.ExceededMaxSize == 0 || bits.ParticleTriggered == 1; 28 | } 29 | 30 | bool HasData() const 31 | { 32 | return bits.FIFO_Overflow == 0; 33 | } 34 | }; 35 | 36 | template 37 | inline T& operator >> (T& reader, ParticleInfo3VCPI& in) 38 | { 39 | reader.read(in.All); 40 | return reader; 41 | }; 42 | 43 | template 44 | inline T& operator << (T& writer, ParticleInfo3VCPI& in) 45 | { 46 | writer.write(reinterpret_cast(&in.All),sizeof(in.All)); 47 | return writer; 48 | }; 49 | 50 | struct ImageChunk3VCPI 51 | { 52 | word GetClearCount()const 53 | { 54 | const word* all = reinterpret_cast(this); 55 | if(0x4000 == *all) 56 | { 57 | return 0; 58 | } 59 | else if(0x7FFF == *all) 60 | { 61 | return -1; // signal uncompressed data 62 | } 63 | 64 | return NumClearPixels; 65 | } 66 | 67 | word GetShadedCount()const 68 | { 69 | const word* all = reinterpret_cast(this); 70 | if(0x4000 == *all) 71 | { 72 | return 128; 73 | } 74 | else if(0x7FFF == *all) 75 | { 76 | return -1; // signal uncompressed data 77 | } 78 | return NumShadedPixels; 79 | } 80 | 81 | void SetMaxShade() 82 | { 83 | *reinterpret_cast(this) = 0x4000; 84 | } 85 | 86 | void SetMaxClear() 87 | { 88 | *reinterpret_cast(this) = 0x7FFF; 89 | } 90 | bool IsUncompressed() const 91 | { 92 | return *reinterpret_cast(this) == 0x7FFF; 93 | } 94 | bool IsStartOfSlice() const 95 | { 96 | return StartOfSlice == 1; 97 | } 98 | void swapEndian() 99 | { 100 | swap_endian_force(reinterpret_cast(this),sizeof(ImageChunk)); 101 | } 102 | 103 | 104 | word NumClearPixels:7; 105 | word NumShadedPixels:7; 106 | word StartOfSlice:1; //1 for start of slice, 0 for continuation 107 | word ImageWord:1; //0 indicates image word..? 108 | }; 109 | 110 | template 111 | inline T& operator << (T& writer, ImageChunk3VCPI& im) 112 | { 113 | writer.write(reinterpret_cast(&im),sizeof(word)); 114 | return writer; 115 | } 116 | struct ImageData3VCPI 117 | { 118 | ParticleInfo3VCPI _Description; 119 | typedef std::vector Data; 120 | Data _data; 121 | bool hasData; 122 | 123 | word _TimingWords[3]; 124 | 125 | Timing Time()const 126 | { return *reinterpret_cast(&_TimingWords[0]); } 127 | 128 | void clear() 129 | {_data.clear();} 130 | 131 | bool HasData()const 132 | { return hasData /*&& _Description.HasData(*/; } 133 | }; 134 | 135 | inline Log& operator << (Log& log, ImageData3VCPI& out) 136 | { 137 | return log; 138 | //return log << "\nImageWord: " << out.bits.ImageWord << 139 | // "\nStartOfSlice: " << out.bits.StartOfSlice << 140 | // "\nNumShadedPixels: " << out.bits.NumShadedPixels << 141 | // "\nNumClearPixels: " << out.bits.NumClearPixels; 142 | }; 143 | 144 | template 145 | inline T& operator >> (T& reader, ImageData3VCPI& in) 146 | { 147 | int WordsToRead = in._Description.bits.NumDataWords; 148 | 149 | if(WordsToRead == 0) 150 | { 151 | return reader; 152 | } 153 | 154 | bool HasTiming = in._Description.HasTimingWord() && WordsToRead >= 3; 155 | if(HasTiming) 156 | { 157 | assert(WordsToRead > 2); 158 | WordsToRead -= 3; 159 | } 160 | 161 | if(WordsToRead > 0 && in.HasData()) 162 | { 163 | in._data.resize(WordsToRead); 164 | reader.read(reinterpret_cast(&in._data[0]),WordsToRead*sizeof(word) ); 165 | 166 | } 167 | 168 | if(HasTiming) 169 | { 170 | reader.read(reinterpret_cast(&in._TimingWords[0]), sizeof(in._TimingWords)); 171 | } 172 | 173 | return reader; 174 | }; 175 | 176 | template 177 | inline T& operator << (T& writer, ImageData3VCPI& im) 178 | { 179 | for(size_t i = 0;i(&im._TimingWords[0]), sizeof(im._TimingWords)); 186 | } 187 | return writer; 188 | } 189 | 190 | 191 | struct ParticleRecord3VCPI: public Packet 192 | { 193 | Word ParticleCount; 194 | Word NumSlicesInParticle; 195 | 196 | ImageData3VCPI HorizontalImage; 197 | ImageData3VCPI VerticalImage; 198 | 199 | void clear() 200 | {HorizontalImage.clear(); VerticalImage.clear();} 201 | 202 | void setData(bool hasData) 203 | { 204 | HorizontalImage.hasData = hasData; 205 | VerticalImage.hasData = hasData; 206 | } 207 | }; 208 | 209 | 210 | template 211 | inline T& operator >> (T& reader, ParticleRecord3VCPI& in) 212 | { 213 | reader >> in.HorizontalImage._Description >> in. VerticalImage._Description >> 214 | in.ParticleCount >> in.NumSlicesInParticle; 215 | 216 | // if(in.HorizontalImage._Description.bits.NumDataWords > 0) 217 | { 218 | reader >> in.HorizontalImage; 219 | } 220 | // if(in.VerticalImage._Description.bits.NumDataWords > 0) 221 | { 222 | reader >> in.VerticalImage; 223 | } 224 | return reader; 225 | // in.HorizontalImage >> in.VerticalImage; 226 | }; 227 | 228 | 229 | template 230 | inline T& operator << (T& writer, ParticleRecord3VCPI& pr) 231 | { 232 | writer << pr.PacketID << pr.HorizontalImage._Description << pr. VerticalImage._Description << 233 | pr.ParticleCount << pr.NumSlicesInParticle; 234 | 235 | writer << pr.HorizontalImage; 236 | 237 | writer << pr.VerticalImage; 238 | 239 | return writer; 240 | }; 241 | 242 | 243 | //inline Log& operator << (Log& log, ParticleRecord& out) 244 | //{ 245 | // return log << "\n\n***Horizontal Image***:" << out.HorizontalImage._Description << 246 | // "\n\n***Vertical Image***:" << out.VerticalImage._Description << 247 | // "\nHParticleCount:\t" << out.ParticleCount << 248 | // "\nNumSlicesInParticle:\t" << out.NumSlicesInParticle << 249 | // "\n\n***Horizontal Image***:" < 19 | void ProcessData(Reader& f, Writer& writer); 20 | 21 | private: 22 | template 23 | void process_block( Block &block, Writer& writer ); 24 | 25 | Log _log; 26 | 27 | Options& _options; 28 | }; 29 | } 30 | 31 | 32 | #include "File.h" 33 | #include "block.h" 34 | #include "PacketTypes.h" 35 | #include "HouseKeeping3VCPI.h" 36 | #include "Mask3VCPI.h" 37 | #include "Particle3VCPI.h" 38 | #include "ctime" 39 | 40 | namespace sp 41 | { 42 | 43 | template 44 | void Device3VCPI::ProcessData( Reader& f, Writer& writer ) 45 | { 46 | TimeStamp16 time_stamp; 47 | Word check_sum; 48 | Block block(SIZE_DATA_BUF, f.SourceEndian(), f.DestinationEndian()); 49 | size_t numParticlesInRecord; 50 | 51 | while (!f.empty()) 52 | { 53 | f >> time_stamp; 54 | if (f.empty()) break; 55 | 56 | // If a time offset was given on the command line, apply it here. Save 57 | // time to tm struct so can use built-in time conversions to handle 58 | // day/month/year rollover, etc. Can't use tm everywhere because it doesn't 59 | // include milli-seconds, which are critical for this data. 60 | 61 | // Log time. Useful for debugging. 62 | //_log <<"\nTime before offset: " << time_stamp.toSimpleString().c_str() <<"\n"; 63 | 64 | // Create a tm struct to copy time info too. 65 | struct tm timeinfo; 66 | 67 | // Overwrite the initialized time with the record time. 68 | //printf("%d\n",_options.TimeOffset); 69 | timeinfo.tm_year = time_stamp.wYear - 1900; 70 | timeinfo.tm_mon = time_stamp.wMonth -1; 71 | timeinfo.tm_mday = time_stamp.wDay; 72 | timeinfo.tm_hour = time_stamp.wHour; 73 | timeinfo.tm_min = time_stamp.wMinute; 74 | timeinfo.tm_sec = time_stamp.wSecond + _options.TimeOffset; 75 | 76 | // Let struct tm do it's magic (propogate offset to day/month/year as needed) 77 | time_t t = mktime(&timeinfo); // mktime returns the time as localtime... 78 | struct tm *tout = localtime(&t);// so use localtime to convert it back. 79 | 80 | // Put the adjusted time back into the 2D time struct 81 | time_stamp.wSecond = tout->tm_sec; 82 | time_stamp.wMinute = tout->tm_min; 83 | time_stamp.wHour = tout->tm_hour; 84 | time_stamp.wDay = tout->tm_mday; 85 | time_stamp.wMonth = tout->tm_mon + 1; 86 | time_stamp.wYear = tout->tm_year + 1900; 87 | 88 | writer << time_stamp; 89 | // Log time of block. Useful for debugging. 90 | //_log <<"Time after offset: " << time_stamp.toSimpleString().c_str() <<"\n"; 91 | f >> block; // read in a block of data from the file 92 | f >> check_sum; 93 | 94 | // block should contain 4096 bytes, but this print statement shows it 95 | // gets more if in a high-particle area. Not sure what this indicates, 96 | // if anything. 97 | //_log << "Block size: " << block.size() <<"\n"; 98 | 99 | // This will print out the contents of the block in hex. 100 | // Useful for debugging 101 | //block.print(); 102 | 103 | // Only process records with more than 5 particles. A count of <5 104 | // particles indicates a stuck bit. This was added to eliminate 105 | // runaway stuck bits that make the output file huge. 106 | numParticlesInRecord = block.countParticles(); 107 | //_log << "Found " << block.countParticles() << " particles in this record.\n"; 108 | if (numParticlesInRecord > 5) { 109 | process_block(block, writer); 110 | } else { 111 | // If don't process block, need to clear it before read next one. 112 | block.go_to_end(); 113 | block.clear(); 114 | } 115 | } 116 | //_log <<"\nTotal Housekeeping packets: " << nHouses <<"\n"; 117 | } 118 | 119 | template< class Writer> 120 | void Device3VCPI::process_block( Block &block, Writer& writer ) 121 | { 122 | int PC = 0; 123 | static int NL = 0; 124 | 125 | //_log << "\n\n+++++++++++++++++NEW BLOCK++++++++++++++++++++\n\n"; 126 | size_t head = 0; 127 | static ParticleRecord3VCPI particle; 128 | try 129 | { 130 | Word w; 131 | while(block.remaining() > 0) 132 | { 133 | head = block.head(); 134 | 135 | block >> w; // Read a word and swap endian 136 | 137 | 138 | switch(w) 139 | { 140 | case HOUSEKEEPING: 141 | { 142 | HouseKeeping3VCPI hk; 143 | block >> hk; 144 | writer << hk; 145 | //_log << "HouseK\n"; 146 | } break; 147 | 148 | case MASK: 149 | { 150 | MaskData3VCPI md; 151 | block >>md; 152 | //_log << "(:Mask:)\n"; 153 | } break; 154 | 155 | case DATA: 156 | { 157 | particle.clear(); 158 | particle.setData(true); 159 | block >> particle; 160 | writer << particle; 161 | PC++; 162 | /*if(word(particle.NumSlicesInParticle) > particle.HorizontalImage._data.size()) 163 | { 164 | _log <<"BAD\n"; 165 | }*/ 166 | // _log << particle2; 167 | 168 | //_log << "**ParticleFrame**\n"; 169 | } break; 170 | 171 | case FLUSH: 172 | { 173 | /* if(NL == 185) 174 | { 175 | NL++; 176 | }*/ 177 | particle.clear(); 178 | particle.setData(false); 179 | block >> particle; 180 | NL++; 181 | //_log << "UNUSED FRAME\n"; 182 | //block.go_to_end(); 183 | } break; 184 | 185 | case 0: // No data. After a flush. 186 | { 187 | //_log << "END OF FRAME\n"; 188 | } break; 189 | 190 | default: 191 | { 192 | /*static int count = 0; 193 | block.clear(); 194 | word val= w; 195 | char first = val >> 8; 196 | char second = val & 0x00ff; 197 | 198 | _log <<"\n3VCPI (" <> w; 205 | // word val= w; 206 | // char first = val >> 8; 207 | // char second = val & 0x00ff; 208 | 209 | // _log <<"\nGot a packet header that isn't recognized : " << word(w) << " ASCI: " << first << " " << second; 210 | //} 211 | // throw std::exception("bad"); 212 | 213 | } break; 214 | } 215 | } 216 | } 217 | catch (block_incomplete&) 218 | { 219 | // _log <<"\nBAD READ: " << "head: " << head << "cur: " << block.head(); 220 | //this means we ran into the end of the block before reading finished 221 | block.go_to(head); 222 | } 223 | // Independent particle count from during processing - sanity check. 224 | //_log <<"Total Particle Count for this record: "<< PC <<"\n"; 225 | 226 | block.clear(); 227 | } 228 | } 229 | -------------------------------------------------------------------------------- /translate2ds/CommandLine.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "common.h" 5 | #include 6 | #include 7 | #include 8 | #include "log.h" 9 | #include "directory.h" 10 | #undef UNICODE 11 | #include "dirent.h" 12 | 13 | 14 | namespace sp 15 | { 16 | class CommandLine 17 | { 18 | enum State 19 | { 20 | FILES, 21 | DIRECTORY, 22 | DATE_START, 23 | DATE_END, 24 | OUT_DIR, 25 | PROJECT, 26 | PLATFORM, 27 | FLIGHT_NUMBER, 28 | SERIALNUMBER, 29 | MINPARTICLE, 30 | MAXPARTICLE, 31 | TIME_OFFSET, 32 | NONE 33 | }; 34 | 35 | public: 36 | CommandLine(int args,const char* argv[]) 37 | { 38 | g_Log < 127 | void for_each_file(Op op) 128 | { 129 | op.options = &_options; 130 | std::for_each(_Files.begin(),_Files.end(), op); 131 | } 132 | 133 | template 134 | struct OpDir 135 | { 136 | T* _op; 137 | 138 | OpDir(T& o):_op(&o){} 139 | 140 | void operator () (std::string& dirName) 141 | { 142 | DIR *dir; 143 | struct dirent *ent; 144 | 145 | dir = opendir (dirName.c_str()); 146 | if (dir != NULL) 147 | { 148 | std::vector file_list; 149 | 150 | while ((ent = readdir (dir)) != NULL) 151 | { 152 | std::string final_file = dirName + "/" + std::string(ent->d_name); 153 | file_list.push_back(final_file); 154 | } 155 | 156 | std::sort(file_list.begin(), file_list.end()); 157 | 158 | std::vector::iterator it; 159 | for (it = file_list.begin(); it != file_list.end(); ++it) 160 | { 161 | (*_op)(*it); 162 | } 163 | closedir (dir); 164 | } else { 165 | g_Log << "Could not open directory: " << dirName << "\n"; 166 | perror (""); 167 | } 168 | 169 | } 170 | }; 171 | template 172 | void for_each_directory(Op op) 173 | { 174 | op.options = &_options; 175 | OpDir dirDoer(op); 176 | std::for_each(_Directories.begin(),_Directories.end(), dirDoer); 177 | } 178 | 179 | 180 | private: 181 | 182 | void ProcessArg(const std::string& op, State state) 183 | { 184 | switch (state) 185 | { 186 | case FILES:{ 187 | _Files.push_back(op); 188 | }break; 189 | case DIRECTORY:{ 190 | _Directories.push_back(op); 191 | }break; 192 | case OUT_DIR:{ 193 | _options.OutputDir = op; 194 | MakeDirectory(op); 195 | }break; 196 | case DATE_START:{ 197 | ProcessDate(op, _options.StartTime); 198 | }break; 199 | case DATE_END:{ 200 | ProcessDate(op, _options.EndTime); 201 | }break; 202 | case MINPARTICLE:{ 203 | _options.MinParticle = atoi(op.c_str()); 204 | }break; 205 | case MAXPARTICLE:{ 206 | _options.MaxParticle = atoi(op.c_str()); 207 | }break; 208 | case PROJECT:{ 209 | _options.Project = op; 210 | }break; 211 | case PLATFORM:{ 212 | _options.Platform = op; 213 | }break; 214 | case FLIGHT_NUMBER:{ 215 | _options.FlightNumber = op; 216 | }break; 217 | case TIME_OFFSET:{ 218 | _options.TimeOffset = atoi(op.c_str()); 219 | g_Log << "Applying a time offset of: " << _options.TimeOffset << " seconds\n"; 220 | }break; 221 | case SERIALNUMBER:{ 222 | _options.SerialNumber = op; 223 | }break; 224 | default:{ 225 | 226 | }break; 227 | } 228 | } 229 | 230 | void ProcessDate(const std::string& date, TimeStamp16& stamp) 231 | { 232 | word val = atoi(date.c_str()); 233 | switch (_dateSlot) 234 | { 235 | case 0: {stamp.wYear = val;} break; 236 | case 1: {stamp.wMonth = val;} break; 237 | case 2: {stamp.wDay = val;} break; 238 | case 3: {stamp.wHour = val;} break; 239 | case 4: {stamp.wMinute = val;} break; 240 | case 5: {stamp.wSecond = val;} break; 241 | case 6: {stamp.wMilliseconds = val;} break; 242 | } 243 | _dateSlot++; 244 | } 245 | 246 | typedef std::vector Names; 247 | 248 | Names _Files; 249 | Names _Directories; 250 | Options _options; 251 | 252 | int _dateSlot; 253 | 254 | 255 | void PrintCommandLineOptions() 256 | { 257 | std::cout << "Spec Data Converter Options:\n\n" << "Process specific files: <-f> <...>\n" << 258 | "Process Directory: <-d> <...>\n" << 259 | "Start Time: <-start_time> \n" << 260 | "End Time: <-end_time> \n" << 261 | "Time Offset: <-offset> \n" << 262 | "Set Output Directory: <-o> \n" << 263 | "Set Project: <-project> \n" << 264 | "Set Platform: <-platform> \n"<< 265 | "Set Flight Number: <-flight> \n"<< 266 | "Set Serial Number: <-sn> \n"<< 267 | "Set Min Particle #: <-minparticle> \n"<< 268 | "Set Max Particle #: <-maxparticle> \n"<< 269 | "ASCII art debug: <-asciiart>\n"; 270 | } 271 | }; 272 | } 273 | -------------------------------------------------------------------------------- /translate2ds/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "File.h" 5 | #include "2DS.h" 6 | #include "2DS_reverse.h" 7 | #include "3VCPI.h" 8 | #include "UCAR_Writer.h" 9 | #include "CommandLine.h" 10 | #include "directory.h" 11 | 12 | sp::Log g_Log("program.log"); 13 | 14 | 15 | struct DoF2DS 16 | { 17 | sp::Options* options; 18 | 19 | void operator () (const std::string& file_name) const 20 | { 21 | sp::Device3VCPI device(*options); 22 | sp::File file(file_name); 23 | sp::File file_hk(file_name+"HK"); 24 | 25 | if (file.is_open() == false) { return; } 26 | 27 | g_Log << "Generating NCAR OAP .2d from Fast2DS file \"" << file_name << "\" of size " 28 | << file.MegaBytes() << " MB.\n"; 29 | 30 | std::string outfile = file_name; 31 | outfile.erase(0, outfile.find("base")); 32 | outfile.erase(outfile.end() - 5, outfile.end()); //remove .F2DS 33 | 34 | sp::UCAR_Writer writer(outfile, *options, sp::HORIZONTAL_2DS, sp::VERTICAL_2DS, 35 | "F2DS", "10", "128", "_2H", "_2V"); 36 | /* 37 | if (file_hk.is_open()) 38 | { 39 | std::cout << "Processing housekeeping file.\n"; 40 | device.ProcessHK(file_hk, writer); 41 | } 42 | */ 43 | device.ProcessData(file, writer); 44 | } 45 | }; 46 | 47 | struct Do3VCPI 48 | { 49 | sp::Options* options; 50 | 51 | void operator () (const std::string& file_name) const 52 | { 53 | sp::Device3VCPI device(*options); 54 | sp::File file(file_name); 55 | sp::File file_hk(file_name+"HK"); 56 | 57 | if (file.is_open() == false) { return; } 58 | 59 | g_Log << "Generating NCAR OAP .2d from 3V-CPI/2DS file \"" << file_name << "\" of size " 60 | << file.MegaBytes() << " MB.\n"; 61 | 62 | std::string outfile = file_name; 63 | outfile.erase(0, outfile.find("base")); 64 | outfile.erase(outfile.end() - 7, outfile.end()); //remove .2dscpi 65 | 66 | sp::UCAR_Writer writer(outfile, *options, sp::HORIZONTAL_3VCPI, sp::VERTICAL_3VCPI, 67 | "3V-CPI", "10", "128", "_3H", "_3V"); 68 | /* 69 | if (file_hk.is_open()) 70 | { 71 | std::cout << "Processing housekeeping file.\n"; 72 | device.ProcessHK(file_hk, writer); 73 | } 74 | */ 75 | device.ProcessData(file, writer); 76 | } 77 | }; 78 | 79 | struct DoHVPS 80 | { 81 | sp::Options* options; 82 | 83 | void operator () (const std::string& file_name) const 84 | { 85 | sp::Device2DS device; 86 | sp::File file(file_name); 87 | 88 | if (file.is_open() == false) { return; } 89 | 90 | g_Log << "Generating NCAR OAP .2d from HVPS file \"" << file_name << "\" of size " 91 | << file.MegaBytes() << " MB.\n"; 92 | 93 | std::string outfile = file_name; 94 | outfile.erase(0, outfile.find("base")); 95 | outfile.erase(outfile.end() - 5, outfile.end()); // remove .hvps 96 | 97 | sp::UCAR_Writer writer(outfile, *options, 0, sp::HVPS, 98 | "HVPS", "150", "128", "", "_H1"); 99 | device.Process(file, writer); 100 | } 101 | }; 102 | 103 | struct Do2DS 104 | { 105 | sp::Options* options; 106 | 107 | void operator () (const std::string& file_name) const 108 | { 109 | // I wonder if the real issue is we were trying to process Fast2DS data in here, and that is same 110 | // format as 3V-CPI. I've since added a DoF2DS(). --cjw 6/2022 111 | 112 | //sp::Device2DS device; 113 | sp::Device3VCPI device(*options); 114 | sp::File file(file_name); 115 | 116 | if (file.is_open() == false) { return; } 117 | 118 | g_Log << "Generating NCAR OAP .2d from 2DS file \"" << file_name << "\" of size " 119 | << file.MegaBytes() << " MB.\n"; 120 | 121 | std::string outfile = file_name; 122 | outfile.erase(0, outfile.find("base")); 123 | outfile.erase(outfile.end() - 4, outfile.end()); // remove .2ds 124 | 125 | // The 2DS processor doesn't correctly process 2DS data, but the 2DSCPI 126 | // processor seems to process the 2DS data correctly, so just use that 127 | // routine for this data. 128 | sp::UCAR_Writer writer(outfile, *options, sp::HORIZONTAL_2DS, sp::VERTICAL_2DS, 129 | "2DS", "10", "128", "_2H", "_2V"); 130 | device.ProcessData(file, writer); 131 | // This is the call to the 2DS processor. 132 | //sp::UCAR_Writer writer(outfile, *options, sp::HORIZONTAL_2DS, sp::VERTICAL_2DS, 133 | // "2DS", "10", "128", "_2H", "_2V"); 134 | //device.Process(file, writer); 135 | } 136 | }; 137 | 138 | struct Do2DS_Reverse 139 | { 140 | sp::Options* options; 141 | 142 | void operator () (const std::string& file_name) const 143 | { 144 | sp::Device2DS_reverse device(*options); 145 | sp::File file(file_name); 146 | 147 | if (file.is_open() == false) { return; } 148 | 149 | g_Log << "Generating Reverse .2DS from file \"" << file_name << "\" of size " 150 | << file.MegaBytes() << " MB's\n"; 151 | 152 | std::string outfile = file_name; 153 | outfile.erase(0, outfile.find("base")); 154 | outfile.erase(outfile.end() - 4, outfile.end()); 155 | outfile += ".2ds"; 156 | 157 | std::string file_full_path = options->OutputDir + "/" + outfile.c_str(); 158 | std::ofstream writer(file_full_path.c_str(), std::ios::binary); 159 | 160 | device.Process(file, writer); 161 | } 162 | }; 163 | 164 | 165 | struct ProcessFile 166 | { 167 | sp::Options* options; 168 | 169 | bool contains(const std::string& fName, const char* match)const 170 | { 171 | std::string copy(match); 172 | if(fName.length() < copy.length()) 173 | return false; 174 | std::cout << "In=" << fName << ", " << match <<'\n'; 175 | std::transform(fName.end()-strlen(match), fName.end(), copy.begin(), ::tolower); 176 | std::cout << "Copy=" << copy << ", " << match <<'\n'; 177 | 178 | return copy.find(match) != std::string::npos; 179 | } 180 | 181 | void operator () (const std::string& file_name) const 182 | { 183 | if (contains(file_name, ".2dscpi") && file_name.find("base") != std::string::npos) 184 | { 185 | Do3VCPI doit = {options}; 186 | doit(file_name); 187 | } 188 | else if(contains(file_name, ".f2ds") && file_name.find("base") != std::string::npos) 189 | { 190 | DoF2DS doit = {options}; 191 | doit(file_name); 192 | } 193 | else if(contains(file_name, ".2ds") && file_name.find("base") != std::string::npos) 194 | { 195 | Do2DS doit = {options}; 196 | doit(file_name); 197 | } 198 | else if(contains(file_name, ".hvps") && file_name.find("base") != std::string::npos) 199 | { 200 | DoHVPS doit = {options}; 201 | doit(file_name); 202 | } 203 | else if(contains(file_name, "2d")) 204 | { 205 | Do2DS_Reverse doit = {options}; 206 | doit(file_name); 207 | } 208 | } 209 | }; 210 | 211 | 212 | /** 213 | * -d 2ds -o Spec2d -date_end 2011 10 31 22 3 214 | * -d Spec2d -o 2ds_dup -program SpecTest -platform spec -date_end 2013 10 31 22 3 215 | * -d 3v-cpi -asciiart -o Spec2d -date_end 2013 10 31 22 25 -minparticle 100 -maxparticle 10000 216 | */ 217 | int main(int argc, const char* argv[]) 218 | { 219 | g_Log << "Starting up\n"; 220 | 221 | sp::CommandLine cl(argc, argv); 222 | sp::MakeDirectory("temp"); 223 | 224 | { 225 | cl.for_each_file(ProcessFile()); 226 | cl.for_each_directory(ProcessFile()); 227 | } 228 | sp::DeleteDirectory("temp"); 229 | 230 | g_Log <<"Shutting down\n"; 231 | } 232 | -------------------------------------------------------------------------------- /2dssim/2dsend.py: -------------------------------------------------------------------------------- 1 | import struct 2 | from datetime import datetime 3 | import socket 4 | import time 5 | import struct 6 | import argparse 7 | import os 8 | import sys 9 | 10 | class P2dRec: 11 | """Class to represent a 4114-byte record with metadata.""" 12 | HEADER_SIZE = 16 # Size of the header in bytes 13 | RECORD_SIZE = 4096 # Size of the record data in bytes 14 | CHECKSUM_SIZE = 2 # Size of the checksum in bytes 15 | TOTAL_SIZE = HEADER_SIZE + RECORD_SIZE + CHECKSUM_SIZE # 4114 bytes total 16 | 17 | def __init__(self, record_data): 18 | """ 19 | Initialize the P2dRec object by parsing the record header, data, and checksum. 20 | :param record_data: A 4,114-byte record. 21 | """ 22 | self.year = None 23 | self.month = None 24 | self.day_of_week = None 25 | self.day = None 26 | self.hour = None 27 | self.minute = None 28 | self.second = None 29 | self.millisecond = None 30 | self.binary_data = None 31 | self.checksum = None 32 | self.timestamp = None 33 | 34 | self._parse_record(record_data) 35 | 36 | def _parse_record(self, record_data): 37 | """ 38 | Parse the record with timestamp, data, and checksum. 39 | :param record_data: A 4,114-byte record. 40 | """ 41 | if len(record_data) < self.TOTAL_SIZE: 42 | raise ValueError(f"Record data is too small: {len(record_data)} bytes, expected {self.TOTAL_SIZE}") 43 | 44 | # Parse the 8 timestamp fields (16 bytes total) using LITTLE ENDIAN format 45 | timestamp_data = struct.unpack('<8H', record_data[:self.HEADER_SIZE]) 46 | 47 | # Assign timestamp fields 48 | (self.year, self.month, self.day_of_week, self.day, 49 | self.hour, self.minute, self.second, self.millisecond) = timestamp_data 50 | 51 | # For debugging purposes 52 | print(f"Timestamp values: {timestamp_data}") 53 | 54 | # Create datetime object 55 | try: 56 | # Keep millisecond within valid range (0-999) 57 | ms = min(self.millisecond, 999) 58 | 59 | self.timestamp = datetime( 60 | year=self.year, 61 | month=self.month, 62 | day=self.day, 63 | hour=self.hour, 64 | minute=self.minute, 65 | second=self.second, 66 | microsecond=ms * 1000 67 | ) 68 | except ValueError as e: 69 | # Handle invalid date values 70 | self.timestamp = None 71 | print(f"Warning: Invalid timestamp values: {timestamp_data}") 72 | print(f"Error details: {e}") 73 | 74 | # Extract binary data (4096 bytes) 75 | data_start = self.HEADER_SIZE 76 | data_end = data_start + self.RECORD_SIZE 77 | raw_data = record_data[data_start:data_end] 78 | self.binary_data = ''.join(format(byte, '08b') for byte in raw_data) 79 | 80 | # Extract checksum (2 bytes) 81 | checksum_bytes = record_data[data_end:data_end + self.CHECKSUM_SIZE] 82 | self.checksum = struct.unpack(' 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | // for byte swapping routines ntohs() & htons() 16 | #include 17 | 18 | enum ProbeType { CIP, PIP }; 19 | 20 | ProbeType pType = CIP; // Default to CIP 21 | 22 | 23 | void ProcessArgs(char *argv[], OAPfile& oap, std::string& pfn, std::string& ofn); 24 | void ConvertPADStoOAP(const PADS_rec&, OAP_rec&, uint16_t); 25 | std::string DateStamp(const PADS_rec&), TimeStamp(const PADS_rec&); 26 | 27 | 28 | /* ----------------------------------------------------------------------- */ 29 | void defineProbes(OAPfile& oap, ProbeType type) 30 | { 31 | // Need a way to pass in probe list on command line.... 32 | 33 | // DYNAMO setup; P4, 100um, 64 diodes, guessing serial#. 34 | // oap.AddProbe(PMS2D_P4, 100, 64, "2DP100", "_RWI"); 35 | 36 | 37 | if (type == CIP) 38 | oap.AddProbe(PMS2D_C8, 25, 64, "CIP001", "_CIP"); 39 | else 40 | if (type == PIP) 41 | oap.AddProbe(PMS2D_P8, 100, 64, "PIP001", "_PIP"); 42 | 43 | // NCAR RAL - processing workshop. 44 | // oap.AddProbe(PMS2D_C8, 25, 64, "CIP001", "_RWI"); 45 | 46 | // IDEAS-4 47 | // oap.AddProbe(PMS2D_C4, 25, 64, "F2DC001", "_LWI"); 48 | // oap.AddProbe(PMS2D_C6, 10, 64, "F2DC002", "_RWO"); 49 | 50 | } 51 | 52 | /* ----------------------------------------------------------------------- */ 53 | void usage() 54 | { 55 | std::cerr << "pads2oap [-flight num] [-project name] [-platform name] -i pads_file -o oap_file\n"; 56 | std::cerr << " -cip | -pip : Set probe type to CIP or PIP. Default is CIP\n"; 57 | std::cerr << " -project : is for project name. e.g. TORERO\n"; 58 | std::cerr << " -platform : is for platform name. e.g. GV_N677F or P3_N43RF\n"; 59 | std::cerr << " -flight : is for flight number, this is a string, not necessarily a number. e.g. rf03\n"; 60 | std::cerr << " -i : input filename; PADS format.\n"; 61 | std::cerr << " -o : output filename; will be OAP format.\n"; 62 | exit(1); 63 | } 64 | 65 | /* ----------------------------------------------------------------------- */ 66 | int main(int argc, char *argv[]) 67 | { 68 | FILE *in; 69 | OAPfile oap; 70 | std::string pads_filename, oap_filename; 71 | 72 | ProcessArgs(argv, oap, pads_filename, oap_filename); 73 | 74 | if (pads_filename.length() == 0 || oap_filename.length() == 0) 75 | usage(); 76 | 77 | 78 | if ((in = fopen(pads_filename.c_str(), "rb")) == NULL) 79 | { 80 | std::cerr << "Can't open input file " << argv[1] << std::endl; 81 | exit(1); 82 | } 83 | 84 | oap.open(oap_filename); 85 | defineProbes(oap, pType); 86 | 87 | 88 | int cnt = 0; 89 | PADS_rec pads_rec; 90 | OAP_rec oap_rec; 91 | 92 | for (cnt = 0; fread(&pads_rec, sizeof(PADS_rec), 1, in); ++cnt) 93 | { 94 | ConvertPADStoOAP(pads_rec, oap_rec, oap.ProbeData(0).id); 95 | 96 | if (cnt == 0) 97 | { 98 | std::string s = DateStamp(pads_rec); 99 | oap.SetFlightDate(s); // This was outside the loop, but here for auto-detect of date. 100 | oap.WriteHeader(); 101 | std::cout << "First record " << DateStamp(pads_rec) << " " << TimeStamp(pads_rec) << std::endl; 102 | } 103 | 104 | oap.WriteRecord(oap_rec); 105 | } 106 | 107 | fclose(in); 108 | 109 | std::cout << "Last record " << DateStamp(pads_rec) << " " << TimeStamp(pads_rec) << std::endl; 110 | std::cout << cnt << " records transferred." << std::endl; 111 | } 112 | 113 | /* ----------------------------------------------------------------------- */ 114 | void ConvertPADStoOAP(const PADS_rec& pads_rec, OAP_rec& oap_rec, uint16_t id) 115 | { 116 | memset(&oap_rec, 0, sizeof(OAP_rec)); 117 | oap_rec.id = htons(id); 118 | oap_rec.year = htons(pads_rec.year); 119 | oap_rec.month = htons(pads_rec.month); 120 | oap_rec.day = htons(pads_rec.day); 121 | oap_rec.hour = htons(pads_rec.hour); 122 | oap_rec.minute= htons(pads_rec.minute); 123 | oap_rec.second= htons(pads_rec.second); 124 | oap_rec.msec = htons(pads_rec.msec); 125 | memcpy(oap_rec.data, pads_rec.data, TWOD_BUFF_SIZE); 126 | } 127 | 128 | /* ----------------------------------------------------------------------- */ 129 | std::string DateStamp(const PADS_rec& pads_rec) 130 | { 131 | std::string s; 132 | char msg[1024]; 133 | snprintf(msg, 1024, "%04d/%02d/%02d", pads_rec.year, pads_rec.month, pads_rec.day); 134 | s = msg; 135 | return s; 136 | } 137 | 138 | /* ----------------------------------------------------------------------- */ 139 | std::string TimeStamp(const PADS_rec& pads_rec) 140 | { 141 | std::string s; 142 | char msg[1024]; 143 | snprintf(msg, 1024, "%02d:%02d:%02d.%d", pads_rec.hour, pads_rec.minute, pads_rec.second, pads_rec.msec); 144 | s = msg; 145 | return s; 146 | } 147 | 148 | 149 | /* ----------------------------------------------------------------------- */ 150 | void OAPfile::open(const std::string& filename) 151 | { 152 | if (filename.length() == 0) 153 | usage(); 154 | 155 | if ((_out = fopen(filename.c_str(), "w+b")) == NULL) 156 | { 157 | std::cerr << "Can't open output file " << filename << std::endl; 158 | exit(1); 159 | } 160 | } 161 | 162 | OAPfile::~OAPfile() 163 | { 164 | if (_out) 165 | fclose(_out); 166 | } 167 | 168 | void OAPfile::WriteRecord(const OAP_rec& oap_rec) 169 | { 170 | if (!_out) 171 | return; 172 | 173 | if (fwrite(&oap_rec, sizeof(OAP_rec), 1, _out) != 1) 174 | { 175 | std::cerr << "Write error, exiting." << std::endl; 176 | fclose(_out); 177 | exit(1); 178 | } 179 | } 180 | 181 | /* ----------------------------------------------------------------------- */ 182 | void OAPfile::WriteHeader() 183 | { 184 | std::stringstream header; 185 | 186 | header 187 | << "\n" 188 | << "\n" 189 | << " NOAA Aircraft Operations Center\n" 190 | << " http://www.eol.ucar.edu/raf/Software/OAPfiles.html\n"; 191 | 192 | if (_project.length()) 193 | header << " " << _project << "\n"; 194 | 195 | if (_platform.length()) 196 | header << " " << _platform << "\n"; 197 | 198 | if (_flightnumber.length()) 199 | header << " " << _flightnumber << "\n"; 200 | 201 | if (_flightdate.length()) 202 | header << " " << _flightdate << "\n"; 203 | 204 | for (size_t i = 0; i < _probelist.size(); ++i) 205 | { 206 | const char *id = (char *)&_probelist[i].id; 207 | header << " \n"; 213 | } 214 | 215 | header << "\n"; 216 | 217 | if (_out) 218 | fwrite(header.str().c_str(), header.str().length(), 1, _out); 219 | } 220 | 221 | /* ----------------------------------------------------------------------- */ 222 | void OAPfile::AddProbe(uint16_t id, int resolution, int nDiodes, std::string serialnumber, std::string suffix) 223 | { 224 | Probe p; 225 | 226 | p.id = id; 227 | p.resolution = resolution; 228 | p.nDiodes = nDiodes; 229 | p.serialnumber = serialnumber; 230 | p.suffix = suffix; 231 | 232 | _probelist.push_back(p); 233 | 234 | printf("Adding probe; %c%c res=%d\n", ((char *)&id)[1], ((char *)&id)[0], resolution); 235 | printf(" Use editor to adjust ASCII header of output as needed.\n"); 236 | } 237 | 238 | /* ----------------------------------------------------------------------- */ 239 | void ProcessArgs(char *argv[], OAPfile& oap, std::string& pfn, std::string& ofn) 240 | { 241 | while (*++argv) 242 | { 243 | if (strcmp(*argv, "-cip") == 0) 244 | { 245 | ; 246 | } 247 | else 248 | if (strcmp(*argv, "-pip") == 0) 249 | { 250 | pType = PIP; 251 | } 252 | else 253 | if (strcmp(*argv, "-project") == 0) 254 | { 255 | oap.SetProject(*++argv); 256 | } 257 | else 258 | if (strcmp(*argv, "-platform") == 0) 259 | { 260 | oap.SetPlatform(*++argv); 261 | } 262 | else 263 | if (strcmp(*argv, "-flight") == 0) 264 | { 265 | oap.SetFlightNumber(*++argv); 266 | } 267 | else 268 | if (strcmp(*argv, "-i") == 0) 269 | { 270 | pfn = *++argv; 271 | } 272 | else 273 | if (strcmp(*argv, "-o") == 0) 274 | { 275 | ofn = *++argv; 276 | } 277 | else 278 | usage(); 279 | } 280 | } 281 | 282 | --------------------------------------------------------------------------------