Exemplo n.º 1
0
static void AddBedroomData(swi_av_Asset_t *asset, swi_av_Table_t *table, int temperature)
{
    rc_ReturnCode_t res;

    LE_INFO("Add bedroom data\n");

    swi_av_table_PushInteger(table, temperature);
    swi_av_table_PushInteger(table, 19);
    swi_av_table_PushInteger(table, time(NULL));

    res = swi_av_table_PushRow(table);
    if (res != RC_OK)
    {
        fprintf(stderr, "Failed to push row to agent\n");
        exit(1);
    }

    if (temperature < 13)
    {
        swi_av_asset_PushInteger(asset, "bedroom.event.temptoolow.temperature", POLICY, SWI_AV_TSTAMP_AUTO, temperature);
        swi_av_asset_PushInteger(asset, "bedroom.event.temptoolow.alarmtemperature", POLICY, SWI_AV_TSTAMP_AUTO, 13);
    }
}
Exemplo n.º 2
0
static int test_5_asset_pushData()
{

    swi_status_t res = swi_av_Init();
    if (res != SWI_STATUS_OK)
        return 1;

    swi_av_Asset_t* asset;

    res = swi_av_asset_Create(&asset, ASSET_ID);
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_asset_Start(asset);
    if (res != SWI_STATUS_OK)
        return res;

//"long" path
    res = swi_av_asset_PushInteger(asset, "titi.test.toto1", "now", SWI_AV_TSTAMP_AUTO, 42);
    if (res != SWI_STATUS_OK)
        return res;
//"short" path
    res = swi_av_asset_PushInteger(asset, "titi.toto2", "now", SWI_AV_TSTAMP_AUTO, 43);
    if (res != SWI_STATUS_OK)
        return res;
//"shortest" path
    res = swi_av_asset_PushInteger(asset, "toto3", "now", SWI_AV_TSTAMP_AUTO, 44);
    if (res != SWI_STATUS_OK)
        return res;
//"shortest" path, no timestamp
    res = swi_av_asset_PushInteger(asset, "toto4", "now", SWI_AV_TSTAMP_NO, 45);
    if (res != SWI_STATUS_OK)
        return res;
//"shortest" path, no timestamp, no policy
    res = swi_av_asset_PushInteger(asset, "toto5", NULL, SWI_AV_TSTAMP_AUTO, 46);
    if (res != SWI_STATUS_OK)
        return res;
//"shortest" path, manual timestamp, no policy
    res = swi_av_asset_PushInteger(asset, "toto6", NULL, 23, 47);
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_asset_PushFloat(asset, "toto7", "now", SWI_AV_TSTAMP_AUTO, 47.455555);
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_asset_PushString(asset, "toto8", "now", SWI_AV_TSTAMP_AUTO, "foo");
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_asset_PushString(asset, "toto8", "now", SWI_AV_TSTAMP_AUTO, NULL );
    if (res != SWI_STATUS_WRONG_PARAMS)
        return res;

    res = swi_av_TriggerPolicy("*");
    if (res != SWI_STATUS_OK)
        return res;

    res = swi_av_asset_Destroy(asset);
    if (res != SWI_STATUS_OK)
        return res;

    return 0;
}