Are you seeing the "evenement envoye" printf? Have you tried taking the 
code that sets the resource to failed and creates the event outside of the 
switch and any if conditions?

Saludos,

        --Renier

[EMAIL PROTECTED] wrote on 06/06/2007 06:31:08 
AM:

> Hi,
> 
> As i got no helping responses on how generate an event from a plugin and
> how to change the .ResourceFailed flag, i retry again on this
> mailing-list. Sorry if that disturb you.
> 
> I just tried to modify a get_sensor_reading() function to try to emit an
> event when the sensor value raise above a specific threshold. In that
> case, i try additionaly to change the value of the ResourceFailed flag
> to FALSE. For the moment, without any success.
> 
> Thanks in advance if you have any clue about this specific problem.
> The plugin i have modified is the simulator plugin.
> 
> Lionel Tricon
> 
> 
/************************************************************************/
> /* Sensor functions */
> 
/************************************************************************/
> SaErrorT sim_get_sensor_reading(void *hnd,
>                                 SaHpiResourceIdT id,
>                                 SaHpiSensorNumT num,
>                                 SaHpiSensorReadingT *data,
>                                 SaHpiEventStateT    *state) {
>         struct SensorInfo *sinfo;
>         struct oh_handler_state *handle = (struct oh_handler_state 
*)hnd;
> // MODIFICATION
> struct oh_event *e;
> // END OF MODIFICATION
> 
>         if (!hnd) {
>                 dbg("Invalid parameter.");
>                 return(SA_ERR_HPI_INVALID_PARAMS);
>         }
> 
>         /* Check if resource exists and has sensor capabilities */
>         SaHpiRptEntryT *rpt = oh_get_resource_by_id(handle->rptcache, 
id);
>         if (!rpt)
>                 return(SA_ERR_HPI_INVALID_RESOURCE);
>         if (!(rpt->ResourceCapabilities & SAHPI_CAPABILITY_SENSOR))
>                 return(SA_ERR_HPI_CAPABILITY);
> 
>         /* Check if sensor exist and is enabled */
>         SaHpiRdrT *rdr = oh_get_rdr_by_type(handle->rptcache, id,
>                                             SAHPI_SENSOR_RDR, num);
>         if (rdr == NULL)
>                 return(SA_ERR_HPI_NOT_PRESENT);
>         sinfo = (struct SensorInfo *)oh_get_rdr_data(handle->rptcache, 
id,
>                                                      rdr->RecordId);
>         if (sinfo == NULL) {
>                 dbg("No sensor data. Sensor=%s", rdr->IdString.Data);
>                 return(SA_ERR_HPI_NOT_PRESENT);
>         }
> 
>         /*If sensor is enabled, get sensor reading*/
>         if (sinfo->sensor_enabled == SAHPI_FALSE) {
>                 return(SA_ERR_HPI_INVALID_REQUEST);
>         } else {
>                 if (data) {
>                         *data = sinfo->reading;
> // MODIFICATION
> printf("** id=%d\n", id);
> switch( data->Type ) {
>     case SAHPI_SENSOR_READING_TYPE_FLOAT64:
>         printf("** value=%lf\n", data->Value.SensorFloat64 );
>         sinfo->reading.Value.SensorFloat64 += 10;
> 
>         if (rpt && sinfo->reading.Value.SensorFloat64>200) {
>           /* Only notify if change in status */
>           if (rpt->ResourceFailed == SAHPI_FALSE) {
>             printf("** ResourceFailed **\n");
>             rpt->ResourceFailed = SAHPI_TRUE;
>             /* Add changed resource to event queue */
>             e = (struct oh_event *)malloc(sizeof(*e));
>             if (!e) {
>               dbg("unable to allocate event");
>               return SA_ERR_HPI_OUT_OF_SPACE;
>             }
>             memset(e, '\0', sizeof(struct oh_event));
>             e->resource = *rpt;
>             e->event.Severity = e->resource.ResourceSeverity;
>             e->event.Source =   e->resource.ResourceId;
>             e->event.EventType = SAHPI_ET_RESOURCE;
>             e->event.EventDataUnion.ResourceEvent.ResourceEventType =
> SAHPI_RESE_RESOURCE_FAILURE;
>             oh_gettimeofday(&e->event.Timestamp);
>             /* add event to our event queue */
>             oh_evt_queue_push(handle->eventq, e);
>             printf("** evenement envoye ....\n");
>           }
>         }
>         break;
>     default:
>         printf("** Format unsupported\n");
>         break;
> }
> // END OF MODIFICATION
>                 }
> 
>                 if (state) {
>                         *state = sinfo->cur_state;
>                 }
>         }
> 
>         return(SA_OK);
> }
> 
> Renier Morales a écrit :
> > Could you attach the diff file of your changes to the simulator? It
> > would help me understand what you are doing.
> >
> > You are probably not seeing any change because the code you wrote is
> > not being executed. If I understood correctly, your code is in
> > sim_get_sensor_reading() which gets called if the
> > saHpiSensorReadingGet() api is called. Which hpievents doesn't call.
> > It only calls saHpiEventGet() to get new events.
> >
> > You should put your code in sim_get_event().
> >
> > Saludos,
> 
> 
> 
-------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Openhpi-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/openhpi-devel
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Openhpi-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openhpi-devel

Reply via email to