Пример #1
0
void sensorAccumExit (WV_ACCUM_ID id)
{
    WV_ACCUM_SAMPLE*    nodePtr;

    for (nodePtr = (WV_ACCUM_SAMPLE*)radListRemoveFirst (&id->samples);
         nodePtr != NULL;
         nodePtr = (WV_ACCUM_SAMPLE*)radListRemoveFirst (&id->samples))
    {
        radBufferRls (nodePtr);
    }
    radBufferRls (id);
}
Пример #2
0
static int readHtmlTemplateFile (HTML_MGR *mgr, char *filename)
{
    HTML_TMPL       *html;
    FILE            *file;
    char            *token;
    char            temp[HTML_MAX_LINE_LENGTH];

    file = fopen (filename, "r");
    if (file == NULL)
    {
        radMsgLog (PRI_HIGH, "htmlmgrInit: %s does not exist!",
                   filename);
        return ERROR_ABORT;
    }

    while (fgets (temp, HTML_MAX_LINE_LENGTH, file) != NULL)
    {
        if (temp[0] == ' ' || temp[0] == '\n' || temp[0] == '#')
        {
            // comment or whitespace
            continue;
        }

        html = (HTML_TMPL *)malloc (sizeof (*html));
        if (html == NULL)
        {
            for (html = (HTML_TMPL *)radListRemoveFirst (&mgr->templateList);
                 html != NULL;
                 html = (HTML_TMPL *)radListRemoveFirst (&mgr->templateList))
            {
                free (html);
            }

            fclose (file);
            return ERROR;
        }

        // do the template file name
        token = strtok (temp, " \t\n");
        if (token == NULL)
        {
            free (html);
            continue;
        }
        wvstrncpy (html->fname, token, sizeof(html->fname));

        radListAddToEnd (&mgr->templateList, (NODE_PTR)html);
    }

    fclose (file);
    return OK;
}
Пример #3
0
static void emptyWorkLists
(
    HTML_MGR_ID     id
)
{
    NODE_PTR        nptr;

    for (nptr = radListRemoveFirst (&id->imgList);
         nptr != NULL;
         nptr = radListRemoveFirst (&id->imgList))
    {
        free (nptr);
    }

    for (nptr = radListRemoveFirst (&id->templateList);
         nptr != NULL;
         nptr = radListRemoveFirst (&id->templateList))
    {
        free (nptr);
    }

    return;
}
Пример #4
0
//  ... Allocate/modify a timer, returns NULL if none are available
TIMER_ID radTimerCreate
(
    TIMER_ID        timer,
    void            (*routine) (void *parm),
    void            *parm
)
{
    if (timer == NULL)
    {
        timer = (TIMER_ID) radListRemoveFirst (&timerList->freeList);
        if (timer == NULL)
        {
            return NULL;
        }

        timerList->noFreeTimers -= 1;
        timer->pending = FALSE;
    }

    timer->routine = routine;
    timer->parm = parm;
    return timer;
}
Пример #5
0
static int readImageConfFile (HTML_MGR *mgr, char *filename, int isUser)
{
    HTML_IMG        *img;
    FILE            *file;
    int             i, done;
    char            *token;
    char            temp[1536];

    file = fopen (filename, "r");
    if (file == NULL)
    {
        radMsgLog (PRI_HIGH, "htmlmgrInit: %s does not exist!",
                   filename);
        return ERROR_ABORT;
    }

    while (fgets (temp, 1536, file) != NULL)
    {
        if (temp[0] == ' ' || temp[0] == '\n' || temp[0] == '#')
        {
            // comment or whitespace
            continue;
        }

        token = strtok (temp, " \t");
        if (token == NULL)
        {
            continue;
        }

        img = (HTML_IMG *)malloc (sizeof (*img));
        if (img == NULL)
        {
            for (img = (HTML_IMG *)radListRemoveFirst (&mgr->imgList);
                    img != NULL;
                    img = (HTML_IMG *)radListRemoveFirst (&mgr->imgList))
            {
                free (img);
            }

            fclose (file);
            return ERROR;
        }
        memset (img, 0, sizeof (*img));

        img->mgrWork    = mgr;
        
        
        //  ... if legacy image type is found, skip it
        if (!strncmp (token, "IMG_TYPE_", 9))
        {
            // get the next token
            token = strtok (NULL, " \t");
            if (token == NULL)
            {
                free (img);
                goto line_loop_end;
            }
        }

        //  ... do the file name
        wvstrncpy (img->fname, token, sizeof(img->fname));

        //  ... now the label
        token = strtok (NULL, " \t");
        if (token == NULL)
        {
            free (img);
            goto line_loop_end;
        }
        if (token[strlen(token)-1] == '"')
        {
            // we're done!
            strncpy (img->title, &token[1], strlen(token)-2);   // lose quotes
        }
        else
        {
            done = FALSE;
            wvstrncpy (img->title, &token[1], sizeof(img->title));
            while (!done)
            {
                token = strtok (NULL, " ");
                if (token == NULL)
                {
                    free(img);
                    goto line_loop_end;
                }
                else
                {
                    if (token[strlen(token)-1] == '"')
                    {
                        done = TRUE;
                        token[strlen(token)-1] = 0;
                    }
                    strcat (img->title, " ");
                    strcat (img->title, token);
                }
            }
        }

        //  ... now the units label (no spaces allowed)
        token = strtok (NULL, " \t");
        if (token == NULL)
        {
            free (img);
            goto line_loop_end;
        }
        wvstrncpy (img->units, token, sizeof(img->units));

        //  ... now the decimal places
        token = strtok (NULL, " \t");
        if (token == NULL)
        {
            free (img);
            goto line_loop_end;
        }
        img->decimalPlaces = atoi (token);

        //  ... finally, the generator index
        token = strtok (NULL, " \t\n");
        if (token == NULL)
        {
            free (img);
            goto line_loop_end;
        }
        i = atoi (token);
        if (isUser)
        {
            img->generator = user_generators[i];
        }
        else
        {
            img->generator = images_generators[i];
        }

        radListAddToEnd (&mgr->imgList, (NODE_PTR)img);

// Loop end label:
line_loop_end:
        continue;
    }

    fclose (file);
    return OK;
}
Пример #6
0
static int readAlarmsConfig (void)
{
    WVIEW_ALARM     *alarm;
    int             i, numAlarms = 0;
    int             iValue;
    char            type[_MAX_PATH];
    int             boolMAX;
    double          thresh;
    int             abate;
    char            exec[_MAX_PATH];
    char            conftype[64];
    const char*     temp;

    if (wvconfigInit(FALSE) == ERROR)
    {
        radMsgLog (PRI_CATASTROPHIC, "wvconfigInit failed!");
        return ERROR;
    }

    // Is the alarms daemon enabled?
    iValue = wvconfigGetBooleanValue(configItem_ENABLE_ALARMS);
    if (iValue == ERROR || iValue == 0)
    {
        wvconfigExit ();
        return ERROR_ABORT;
    }

    // set the wview verbosity setting
    if (wvutilsSetVerbosity (WV_VERBOSE_WVALARMD) == ERROR)
    {
        radMsgLog (PRI_CATASTROPHIC, "wvutilsSetVerbosity failed!");
        wvconfigExit ();
        return ERROR_ABORT;
    }

    // get the metric units flag:
    iValue = wvconfigGetBooleanValue(configItem_ALARMS_STATION_METRIC);
    if (iValue == ERROR)
    {
        alarmsWork.isMetric = 0;
    }
    else
    {
        alarmsWork.isMetric = iValue;
    }

    // get the do test flag:
    iValue = wvconfigGetBooleanValue(configItem_ALARMS_DO_TEST);
    if (iValue <= 0)
    {
        alarmsWork.doTest = FALSE;
    }
    else
    {
        alarmsWork.doTest = TRUE;
        alarmsWork.doTestNumber = wvconfigGetINTValue(configItem_ALARMS_DO_TEST_NUMBER);
    }

    for (i = 1; i <= ALARMS_MAX; i ++)
    {
        sprintf (conftype, "ALARMS_%1.1d_TYPE", i);
        temp = wvconfigGetStringValue(conftype);
        if (temp == NULL)
        {
            // No type defined - continue:
            continue;
        }
        wvstrncpy(type, temp, _MAX_PATH);

        sprintf (conftype, "ALARMS_%1.1d_MAX", i);
        boolMAX = wvconfigGetBooleanValue(conftype);
        if (boolMAX == ERROR)
        {
            continue;
        }

        sprintf (conftype, "ALARMS_%1.1d_THRESHOLD", i);
        thresh = wvconfigGetDOUBLEValue(conftype);

        sprintf (conftype, "ALARMS_%1.1d_ABATEMENT", i);
        abate = wvconfigGetINTValue(conftype);

        sprintf (conftype, "ALARMS_%1.1d_EXECUTE", i);
        temp = wvconfigGetStringValue(conftype);
        if (temp == NULL)
        {
            // No type defined - continue:
            continue;
        }
        wvstrncpy(exec, temp, _MAX_PATH);

        alarm = (WVIEW_ALARM *) malloc (sizeof (*alarm));
        if (alarm == NULL)
        {
            for (alarm = (WVIEW_ALARM *)radListRemoveFirst (&alarmsWork.alarmList);
                 alarm != NULL;
                 alarm = (WVIEW_ALARM *)radListRemoveFirst (&alarmsWork.alarmList))
            {
                free (alarm);
            }

            return ERROR;
        }
        memset (alarm, 0, sizeof (*alarm));


        // get the type
        if (!strcmp (type, "Barometer"))
        {
            alarm->type = Barometer;
        }
        else if (!strcmp (type, "InsideTemp"))
        {
            alarm->type = InsideTemp;
        }
        else if (!strcmp (type, "InsideHumidity"))
        {
            alarm->type = InsideHumidity;
        }
        else if (!strcmp (type, "OutsideTemp"))
        {
            alarm->type = OutsideTemp;
        }
        else if (!strcmp (type, "WindSpeed"))
        {
            alarm->type = WindSpeed;
        }
        else if (!strcmp (type, "TenMinuteAvgWindSpeed"))
        {
            alarm->type = TenMinuteAvgWindSpeed;
        }
        else if (!strcmp (type, "WindDirection"))
        {
            alarm->type = WindDirection;
        }
        else if (!strcmp (type, "OutsideHumidity"))
        {
            alarm->type = OutsideHumidity;
        }
        else if (!strcmp (type, "RainRate"))
        {
            alarm->type = RainRate;
        }
        else if (!strcmp (type, "StormRain"))
        {
            alarm->type = StormRain;
        }
        else if (!strcmp (type, "DayRain"))
        {
            alarm->type = DayRain;
        }
        else if (!strcmp (type, "MonthRain"))
        {
            alarm->type = MonthRain;
        }
        else if (!strcmp (type, "YearRain"))
        {
            alarm->type = YearRain;
        }
        else if (!strcmp (type, "TxBatteryStatus"))
        {
            alarm->type = TxBatteryStatus;
        }
        else if (!strcmp (type, "ConsoleBatteryVoltage"))
        {
            alarm->type = ConsoleBatteryVoltage;
        }
        else if (!strcmp (type, "DewPoint"))
        {
            alarm->type = DewPoint;
        }
        else if (!strcmp (type, "WindChill"))
        {
            alarm->type = WindChill;
        }
        else if (!strcmp (type, "HeatIndex"))
        {
            alarm->type = HeatIndex;
        }
        else if (!strcmp (type, "Radiation"))
        {
            alarm->type = Radiation;
        }
        else if (!strcmp (type, "UV"))
        {
            alarm->type = UV;
        }
        else if (!strcmp (type, "ET"))
        {
            alarm->type = ET;
        }
        else if (!strcmp (type, "ExtraTemp1"))
        {
            alarm->type = ExtraTemp1;
        }
        else if (!strcmp (type, "ExtraTemp2"))
        {
            alarm->type = ExtraTemp2;
        }
        else if (!strcmp (type, "ExtraTemp3"))
        {
            alarm->type = ExtraTemp3;
        }
        else if (!strcmp (type, "SoilTemp1"))
        {
            alarm->type = SoilTemp1;
        }
        else if (!strcmp (type, "SoilTemp2"))
        {
            alarm->type = SoilTemp2;
        }
        else if (!strcmp (type, "SoilTemp3"))
        {
            alarm->type = SoilTemp3;
        }
        else if (!strcmp (type, "SoilTemp4"))
        {
            alarm->type = SoilTemp4;
        }
        else if (!strcmp (type, "LeafTemp1"))
        {
            alarm->type = LeafTemp1;
        }
        else if (!strcmp (type, "LeafTemp2"))
        {
            alarm->type = LeafTemp2;
        }
        else if (!strcmp (type, "ExtraHumid1"))
        {
            alarm->type = ExtraHumid1;
        }
        else if (!strcmp (type, "ExtraHumid2"))
        {
            alarm->type = ExtraHumid2;
        }
        else if (!strcmp (type, "Wxt510Hail"))
        {
            alarm->type = Wxt510Hail;
        }
        else if (!strcmp (type, "Wxt510Hailrate"))
        {
            alarm->type = Wxt510Hailrate;
        }
        else if (!strcmp (type, "Wxt510HeatingTemp"))
        {
            alarm->type = Wxt510HeatingTemp;
        }
        else if (!strcmp (type, "Wxt510HeatingVoltage"))
        {
            alarm->type = Wxt510HeatingVoltage;
        }
        else if (!strcmp (type, "Wxt510SupplyVoltage"))
        {
            alarm->type = Wxt510SupplyVoltage;
        }
        else if (!strcmp (type, "Wxt510ReferenceVoltage"))
        {
            alarm->type = Wxt510ReferenceVoltage;
        }
        else
        {
            free (alarm);
            radMsgLog (PRI_MEDIUM, "invalid alarm type %s - skipping...",
                       type);
            continue;
        }

        //  do the max/min flag
        alarm->isMax = boolMAX;

        //  now the bounding value
        alarm->bound = (float)thresh;

        //  now the abatement seconds
        alarm->abateSecs = abate;

        //  finally, the alarm script
        wvstrncpy (alarm->scriptToRun, exec, WVIEW_ALARM_SCRIPT_LENGTH);

        radListAddToEnd (&alarmsWork.alarmList, (NODE_PTR)alarm);
    }

    wvconfigExit ();
    return (radListGetNumberOfNodes (&alarmsWork.alarmList));
}