示例#1
0
 public static function parseSLMFromString($theData, $loggerDB)
 {
     $loggerDB->info("Now into parsing method");
     $COLS = new ArrayObject();
     $COLS[0] = "DATE";
     $COLS[1] = "TIME";
     $COLS[2] = "LEQ";
     $COLS[3] = "MIN";
     $COLS[4] = "MAX";
     $COLS[5] = "L10";
     $COLS[6] = "L50";
     $COLS[7] = "L90";
     $COLS[8] = "SEL";
     $COLS[9] = "CRC";
     //$myFile = "../files/data.slm";
     $lineVals = explode(',', $theData);
     $count = count($lineVals) - 1;
     $totRows = $count / 11;
     $arrayCount = 0;
     $SLMArray = new ArrayObject();
     //loop over each row of information in the SLM
     $varIndex = 0;
     for ($a = 0; $a <= $totRows; $a++) {
         $dated = null;
         if ($lineVals[$varIndex] != null && $lineVals[$varIndex + 1] != null) {
             $datedStr = $lineVals[$varIndex];
             $timed = $lineVals[++$varIndex];
             $crc = "";
             if ($a != 0) {
                 $crc = substr($datedStr, 0, 1);
                 $datedStr = substr($datedStr, 1, 8);
             }
             $dateWithoutSlashes = str_replace('/', '-', $datedStr);
             // dd-mm-yyyy
             $date_parts = array_reverse(explode("-", $dateWithoutSlashes));
             $dateReFormated = implode('-', $date_parts);
             $timestamp = strtotime($dateReFormated . " " . $timed);
             $dated = date('Y-m-d H:i:s', $timestamp);
             $SLM = new SLM();
             $SLM->setDated($dated);
             $SLM->setLEQ($lineVals[++$varIndex]);
             $SLM->setMIN($lineVals[++$varIndex]);
             $SLM->setMAX($lineVals[++$varIndex]);
             $SLM->setL10($lineVals[++$varIndex]);
             $SLM->setL50($lineVals[++$varIndex]);
             $SLM->setL90($lineVals[++$varIndex]);
             $SLM->setSEL($lineVals[++$varIndex]);
             $SLM->setCRC($crc);
             $SLMDS = SLMDataStore::getInstance();
             $res = $SLMDS->SaveSML($SLM);
             $varIndex = $varIndex + 3;
             //padding variable and another increased
         }
     }
     //for loop
     $loggerDB->info("Parser came out of loop now");
 }
示例#2
0
 public function populateObject($rsItem)
 {
     $seq_ = $rsItem["seq"];
     $dated_ = $rsItem["dated"];
     $leq_ = $rsItem["leq"];
     $min_ = $rsItem["min"];
     $max_ = $rsItem["max"];
     $l10_ = $rsItem["l10"];
     $l50_ = $rsItem["l50"];
     $l90_ = $rsItem["l90"];
     $sel_ = $rsItem["sel"];
     $crc = $rsItem["crc"];
     $fileSeq = $rsItem["fileseq"];
     $slm = new SLM();
     $slm->setSeq($seq_);
     $slm->setDated($dated_);
     $slm->setLEQ($leq_);
     $slm->setMIN($min_);
     $slm->setMAX($max_);
     $slm->setL10($l10_);
     $slm->setL50($l50_);
     $slm->setL90($l90_);
     $slm->setSEL($sel_);
     $slm->setCRC($crc);
     $slm->setFileSeq($fileSeq);
     return $slm;
 }