Profiles/Voltage/profile_voltage.c
void ProfileVoltage_Handler(service_t *service, msg_t *msg)
{
    profile_core_t *profile            = ProfileCore_GetFromService(service);
    profile_voltage_t *voltage_profile = (profile_voltage_t *)profile->profile_data;

    switch (msg->header.cmd)
    {
        case GET_CMD:
            if ((voltage_profile->access == READ_WRITE_ACCESS) || (voltage_profile->access == READ_ONLY_ACCESS))
            {
                // fill the message infos
                msg_t pub_msg;
                pub_msg.header.target_mode = msg->header.target_mode;
                pub_msg.header.target      = msg->header.source;
                if (voltage_profile->control.rec)
                {
                    LUOS_ASSERT(voltage_profile->signal.data_ptr != 0);
                    // send back a record stream
                    pub_msg.header.cmd = VOLTAGE;
                    Luos_SendStreaming(service, &pub_msg, &voltage_profile->signal);
                }
                else
                {
                    ElectricOD_VoltageToMsg(&voltage_profile->voltage, &pub_msg);
                    Luos_SendMsg(service, &pub_msg);
                }
            }
            break;
        case VOLTAGE:
            if ((voltage_profile->access == READ_WRITE_ACCESS) || (voltage_profile->access == WRITE_ONLY_ACCESS))
            {
                if (msg->header.size == sizeof(voltage_t))
                {
                    // Get the voltage
                    ElectricOD_VoltageFromMsg(&voltage_profile->voltage, msg);
                }
                else
                {
                    LUOS_ASSERT(voltage_profile->signal.data_ptr != 0);
                    // this is a signal, save it into ring buffer.
                    Luos_ReceiveStreaming(service, msg, &voltage_profile->signal);
                    // values will be converted one by one during trajectory management.
                }
            }
            break;
        case TIME:
        {
            // save time in ms
            TimeOD_TimeFromMsg((time_luos_t *)&voltage_profile->sampling_period, msg);
        }
        break;
        default:
        {
            return;
        }
        break;
    }

    if ((profile->profile_ops.Callback != 0))
    {
        profile->profile_ops.Callback(service, msg);
    }
}
/******************************************************************************
 * @brief function converting Luos messages into data and reverse.
 * @param service the target service
 * @param msg the received message
 * @return None
 ******************************************************************************/
@brief function converting Luos messages into data and reverse.
@param service the target service
@param msg the received message
@return None
@brief function converting Luos messages into data and reverse . @param service the target service @param msg the received message @return None
void ProfileVoltage_Handler(service_t *service, msg_t *msg)
{
    profile_core_t *profile            = ProfileCore_GetFromService(service);
    profile_voltage_t *voltage_profile = (profile_voltage_t *)profile->profile_data;
    switch (msg->header.cmd)
    {
        case GET_CMD:
            if ((voltage_profile->access == READ_WRITE_ACCESS) || (voltage_profile->access == READ_ONLY_ACCESS))
            {
                msg_t pub_msg;
                pub_msg.header.target_mode = msg->header.target_mode;
                pub_msg.header.target      = msg->header.source;
                if (voltage_profile->control.rec)
                {
                    LUOS_ASSERT(voltage_profile->signal.data_ptr != 0);
                    pub_msg.header.cmd = VOLTAGE;
                    Luos_SendStreaming(service, &pub_msg, &voltage_profile->signal);
                }
                else
                {
                    ElectricOD_VoltageToMsg(&voltage_profile->voltage, &pub_msg);
                    Luos_SendMsg(service, &pub_msg);
                }
            }
            break;
        case VOLTAGE:
            if ((voltage_profile->access == READ_WRITE_ACCESS) || (voltage_profile->access == WRITE_ONLY_ACCESS))
            {
                if (msg->header.size == sizeof(voltage_t))
                {
                    ElectricOD_VoltageFromMsg(&voltage_profile->voltage, msg);
                }
                else
                {
                    LUOS_ASSERT(voltage_profile->signal.data_ptr != 0);
                    Luos_ReceiveStreaming(service, msg, &voltage_profile->signal);
                }
            }
            break;
        case TIME:
        {
            TimeOD_TimeFromMsg((time_luos_t *)&voltage_profile->sampling_period, msg);
        }
        break;
        default:
        {
            return;
        }
        break;
    }
    if ((profile->profile_ops.Callback != 0))
    {
        profile->profile_ops.Callback(service, msg);
    }
}
void ProfileVoltage_Handler ( service_t * service , msg_t * msg ) { profile_core_t * profile = ProfileCore_GetFromService ( service ) ; profile_voltage_t * voltage_profile = ( profile_voltage_t * ) profile -> profile_data ; switch ( msg -> header . cmd ) { case GET_CMD : if ( ( voltage_profile -> access == READ_WRITE_ACCESS ) || ( voltage_profile -> access == READ_ONLY_ACCESS ) ) { msg_t pub_msg ; pub_msg . header . target_mode = msg -> header . target_mode ; pub_msg . header . target = msg -> header . source ; if ( voltage_profile -> control . rec ) { LUOS_ASSERT ( voltage_profile -> signal . data_ptr != 0 ) ; pub_msg . header . cmd = VOLTAGE ; Luos_SendStreaming ( service , & pub_msg , & voltage_profile -> signal ) ; } else { ElectricOD_VoltageToMsg ( & voltage_profile -> voltage , & pub_msg ) ; Luos_SendMsg ( service , & pub_msg ) ; } } break ; case VOLTAGE : if ( ( voltage_profile -> access == READ_WRITE_ACCESS ) || ( voltage_profile -> access == WRITE_ONLY_ACCESS ) ) { if ( msg -> header . size == sizeof ( voltage_t ) ) { ElectricOD_VoltageFromMsg ( & voltage_profile -> voltage , msg ) ; } else { LUOS_ASSERT ( voltage_profile -> signal . data_ptr != 0 ) ; Luos_ReceiveStreaming ( service , msg , & voltage_profile -> signal ) ; } } break ; case TIME : { TimeOD_TimeFromMsg ( ( time_luos_t * ) & voltage_profile -> sampling_period , msg ) ; } break ; default : { return ; } break ; } if ( ( profile -> profile_ops . Callback != 0 ) ) { profile -> profile_ops . Callback ( service , msg ) ; } }
@brief function converting Luos messages into data and reverse.
@brief function converting Luos messages into data and reverse .
// fill the message infos // send back a record stream // Get the voltage // this is a signal, save it into ring buffer. // values will be converted one by one during trajectory management. // save time in ms