@@ -1725,7 +1725,9 @@ WFILE::~WFILE()
17251725
17261726 record::Copy ( pSrc, options); // verifies class (rt) same, copies whole derived class record. ancrec.cpp.
17271727
1728+ loc.FixAfterCopy ();
17281729 wf_TDVFileTitle.FixAfterCopy ();
1730+ wf_TDVFileTimeStamp.FixAfterCopy ();
17291731
17301732 yac = new YACAM (); // overwrite yac pointer, if any
17311733 yacTDV = new YACAM ();
@@ -1739,8 +1741,9 @@ void WFILE::wf_Init() // WFILE initialization function to call before each run
17391741// DO NOT memset to 0 here: would destroy record base class header members.
17401742{
17411743 wFileFormat = UNK;
1742- VZero ( loc, sizeof ( loc));
1743- VZero ( lid, sizeof ( lid));
1744+ loc.Release ();
1745+ lid.Release ();
1746+ loc2.Release ();
17441747 yr = -1 ;
17451748 jd1 = -1 ;
17461749 jdl = -1 ;
@@ -1750,7 +1753,6 @@ void WFILE::wf_Init() // WFILE initialization function to call before each run
17501753 elev = 0 .f ;
17511754 taDbAvgYr = -999 .f ;
17521755 solartime = FALSE ;
1753- VZero ( loc2, sizeof ( loc2));
17541756 isLeap = 0 ;
17551757 firstDdm = 0 ;
17561758 lastDdm = 0 ;
@@ -1773,6 +1775,8 @@ void WFILE::wf_Init() // WFILE initialization function to call before each run
17731775 { yac->close (); // insurance
17741776 yac->init (); // say no file open
17751777 }
1778+
1779+ wf_TDVInitHdrInfo ();
17761780 if (yacTDV)
17771781 { yacTDV->close ();
17781782 yacTDV->init ();
@@ -1892,7 +1896,7 @@ struct WFHTAB
18921896 USI hdrOffset; // offset to data item in header
18931897 UCH hdrLen; // length of data item in header
18941898 USI wfileOffset; // offset to data item in WFILE struct
1895- UCH wfileLen; // length of item in WFILE struct -- added 10-94 to facilitate multiple header formats
1899+ UCH wfileLen; // length of item in WFILE struct
18961900};
18971901#define WFO (m ) offsetof(WFILE,m) // WFILE member offset macro for use for WFHTAB.wfileOffeeset
18981902#define WFS (m ) (sizeof ( ((WFILE *)0L )->m )) // WFILE member size macro for use for WFHTAB.wfileLen
@@ -1972,8 +1976,8 @@ static WFHTAB wfhTab_BSGS[] =
19721976// ---header--- ---WFILE----
19731977// dataType [#] offset & len offset & len
19741978{
1975- { DTCH, 1 , 53 , 30 , WFOS (loc), }, // location
1976- { DTCH, 1 , 83 , 11 , WFOS (lid), }, // location id
1979+ { DTCULSTR, 1 , 53 , 30 , WFOS (loc), }, // location
1980+ { DTCULSTR, 1 , 83 , 11 , WFOS (lid), }, // location id
19771981{ DTSI, 1 , 94 , 2 , WFOS (yr), }, // year, 2 digits
19781982{ DTFLOAT,1 , 96 , 6 , WFOS (lat), }, // latitude
19791983{ DTFLOAT,1 , 102 , 7 , WFOS (lon), }, // longitude
@@ -2012,9 +2016,9 @@ static WFHTAB wfhTab_ET1[] =
20122016// -----header------ ---WFILE----
20132017// dataType [#] offset & length offset & len
20142018{
2015- { DTCH, 1 , E1OS (location1), WFOS (loc), }, // location 1
2016- { DTCH, 1 , E1OS (location2), WFOS (loc2), }, // location 2
2017- { DTCH, 1 , E1OS (locationID), WFOS (lid), }, // location id
2019+ { DTCULSTR, 1 , E1OS (location1), WFOS (loc), }, // location 1
2020+ { DTCULSTR, 1 , E1OS (location2), WFOS (loc2), }, // location 2
2021+ { DTCULSTR, 1 , E1OS (locationID), WFOS (lid), }, // location id
20182022{ DTSI, 1 , E1OS (wthrYear), WFOS (yr), }, // year, 4 digits
20192023{ DTFLOAT,1 , E1OS (latitude), WFOS (lat), }, // latitude
20202024{ DTFLOAT,1 , E1OS (longitude), WFOS (lon), }, // longitude
@@ -2108,16 +2112,22 @@ LOCAL RC FC decodeFld( // decode one by-column-number field to internal -- pot
21082112 char * pEnd = pBeg + srcLen; // ptr to 1st char after source data
21092113 while (pEnd > pBeg && (!pEnd[-1 ] || isspaceW (pEnd[-1 ]))) // deblank end
21102114 pEnd--;
2111- char cSave = *pEnd; // save char after data
2115+ char cSave = *pEnd; // save char after data
21122116 *pEnd = ' \0 ' ; // and replace it with terminull -- given fields are not terminated.
2113- while (isspaceW (*pBeg)) // deblank start
2117+ while (isspaceW (*pBeg)) // deblank start
21142118 pBeg++;
21152119
21162120 if (dt==DTCH) // if a character field
21172121 {
21182122 strncpy ( (char *)dest, pBeg, destLen-1 ); // copy to dest with \0 at end
21192123 ((char *)dest)[destLen-1 ] = ' \0 ' ; // ..
21202124 }
2125+ else if (dt == DTCULSTR)
2126+ {
2127+ CULSTR* pS = static_cast <CULSTR*>(dest);
2128+ pS->Set (pBeg);
2129+
2130+ }
21212131 else // DTSI or DTFLOAT -- numeric
21222132 {
21232133 // initial syntax check
@@ -2435,9 +2445,10 @@ RC WFILE::wf_CSWOpen( // open California CSW weather file
24352445 if (!rc)
24362446 { wFileFormat = CSW; // accept that the format is CSW
24372447 // transfer location info (could be refined/improved)
2438- strncpy0 ( loc, city.c_str (), sizeof ( loc));
2439- strncpy0 ( loc2, state.c_str (), sizeof ( loc2));
2440- strCatIf ( loc2, sizeof ( loc2), " , " , country.c_str ());
2448+ loc = city.c_str ();
2449+ char sTemp [200 ];
2450+ strncpy0 ( sTemp , state.c_str (), sizeof ( sTemp ));
2451+ loc2 = strCatIf ( sTemp , sizeof ( sTemp ), " , " , country.c_str ());
24412452 }
24422453 else
24432454 { yac->close ( erOp); // close file if open, nop if not open
@@ -2515,7 +2526,8 @@ RC WFILE::wf_TDVOpen( // open California Time of Day Valuation (TDV) file
25152526#define _C ( s ) s,sizeof ( s) // helper re getLineCSV calls
25162527// ----------------------------------------------------------------------------
25172528void WFILE::wf_TDVInitHdrInfo ()
2518- { memset ( wf_TDVFileTimeStamp, 0 , sizeof ( wf_TDVFileTimeStamp));
2529+ {
2530+ wf_TDVFileTimeStamp.Release ();
25192531 wf_TDVFileTitle.Release ();
25202532} // WFILE::wf_TDVInitHdrInfo
25212533// ----------------------------------------------------------------------------
@@ -2540,7 +2552,7 @@ RC WFILE::wf_TDVReadHdr( int erOp) // read / decode TDV file header
25402552 rc |= yacTDV->checkExpected ( T1, " TDV Data (TDV/Btu)" );
25412553 if (!rc)
25422554 // time stamp
2543- rc = yacTDV->getLineCSV ( erOp, 0 , " C " , _C ( wf_TDVFileTimeStamp) , NULL );
2555+ rc = yacTDV->getLineCSV ( erOp, 0 , " S " , & wf_TDVFileTimeStamp, NULL );
25442556 if (!rc)
25452557 { // title
25462558 rc = yacTDV->getLineCSV ( erOp, 0 , " SC" , &wf_TDVFileTitle, _C ( T2), NULL );
@@ -2679,9 +2691,9 @@ RC WFILE::wf_EPWOpen( // open EnergyPlus weather file
26792691 RC rc = RCOK;
26802692
26812693 // location (1st line)
2682- char lineTag[ 200 ], xCity[ 100 ], xState[ 100 ], xCountry[ 100 ], xSource[ 100 ], xWMO[ 100 ];
2683- rc = yac->getLineCSV ( erOp, isLeap, " CCCCCCFFFF " ,
2684- _C ( lineTag), _C ( xCity) , _C ( xState), _C ( xCountry),
2694+ char lineTag[ 200 ], xState[ 100 ], xCountry[ 100 ], xSource[ 100 ], xWMO[ 100 ];
2695+ rc = yac->getLineCSV ( erOp, isLeap, " CSCCCCFFFF " ,
2696+ _C ( lineTag), &loc , _C ( xState), _C ( xCountry),
26852697 _C ( xSource), _C ( xWMO),
26862698 &lat, &lon, &tz, &elev, NULL );
26872699 elev = LSItoIP ( elev); // m -> ft
@@ -2698,9 +2710,10 @@ RC WFILE::wf_EPWOpen( // open EnergyPlus weather file
26982710 if (!rc)
26992711 { wFileFormat = EPW; // accept that the format is CSW
27002712 // transfer location info (could be refined/improved)
2701- strncpy0 ( loc, xCity, sizeof ( loc));
2702- strncpy0 ( loc2, xState, sizeof ( loc2));
2703- strCatIf ( loc2, sizeof ( loc2), " , " , xCountry);
2713+ // loc, xCity, sizeof( loc));
2714+ char sTemp [200 ];
2715+ strncpy0 ( sTemp , xState, sizeof ( sTemp ));
2716+ loc2.Set (strCatIf (sTemp , sizeof (sTemp ), " , " , xCountry));
27042717 }
27052718 else
27062719 { yac->close ( erOp); // close file if open, nop if not open
0 commit comments