Exemplo n.º 1
0
bool Lighting_Output_Present_Value_Set(
    uint32_t object_instance,
    float value,
    unsigned priority)
{
    unsigned index = 0;
    bool status = false;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        if (priority && (priority <= BACNET_MAX_PRIORITY) &&
            (priority != 6 /* reserved */ ) &&
            (value >= 0.0) && (value <= 100.0)) {
            Lighting_Output_Level[index][priority - 1] = (uint8_t) value;
            /* Note: you could set the physical output here to the next
               highest priority, or to the relinquish default if no
               priorities are set.
               However, if Out of Service is TRUE, then don't set the
               physical output.  This comment may apply to the
               main loop (i.e. check out of service before changing output) */
            status = true;
        }
    }

    return status;
}
Exemplo n.º 2
0
/**
 * For a given object instance-number, sets the out-of-service property value
 *
 * @param object_instance - object-instance number of the object
 * @param value - boolean out-of-service value
 *
 * @return true if the out-of-service property value was set
 */
void Lighting_Output_Out_Of_Service_Set(
    uint32_t object_instance,
    bool value)
{
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        Lighting_Output[index].Out_Of_Service = value;
    }
}
Exemplo n.º 3
0
/**
 * Determines if a given Lighting Output instance is valid
 *
 * @param  object_instance - object-instance number of the object
 *
 * @return  true if the instance is valid, and false if not
 */
bool Lighting_Output_Valid_Instance(
    uint32_t object_instance)
{
    unsigned int index;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        return true;
    }

    return false;
}
Exemplo n.º 4
0
float Lighting_Output_Tracking_Value(
    uint32_t object_instance)
{
    float value = LIGHTING_RELINQUISH_DEFAULT;
    unsigned index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        value = Lighting_Output_Progress[index];
    }

    return value;
}
Exemplo n.º 5
0
/**
 * For a given object instance-number, gets the blink-warn-enable
 * property value
 *
 * @param object_instance - object-instance number of the object
 *
 * @return the blink-warn-enable property value of this object
 */
bool Lighting_Output_Blink_Warn_Enable(
    uint32_t object_instance)
{
    bool value = false;
    unsigned index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        value = Lighting_Output[index].Blink_Warn_Enable;
    }

    return value;
}
Exemplo n.º 6
0
/**
 * For a given object instance-number, gets the tracking-value property
 *
 * @param object_instance - object-instance number of the object
 *
 * @return the tracking-value of this object instance.
 */
float Lighting_Output_Tracking_Value(
    uint32_t object_instance)
{
    float value = 0.0;
    unsigned index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        value = Lighting_Output[index].Tracking_Value;
    }

    return value;
}
Exemplo n.º 7
0
/**
 * For a given object instance-number, gets the fade-time
 * property value
 *
 * @param object_instance - object-instance number of the object
 *
 * @return the fade-time property value of this object
 */
uint32_t Lighting_Output_Default_Fade_Time(
    uint32_t object_instance)
{
    uint32_t value = 0;
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        value = Lighting_Output[index].Default_Fade_Time;
    }

    return value;
}
Exemplo n.º 8
0
/**
 * For a given object instance-number, gets the in-progress property value
 *
 * @param object_instance - object-instance number of the object
 *
 * @return the in-progress value of this object instance.
 */
BACNET_LIGHTING_IN_PROGRESS Lighting_Output_In_Progress(
    uint32_t object_instance)
{
    BACNET_LIGHTING_IN_PROGRESS value = BACNET_LIGHTING_IDLE;
    unsigned index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        value = Lighting_Output[index].In_Progress;
    }

    return value;
}
Exemplo n.º 9
0
/**
 * For a given object instance-number, returns the out-of-service
 * property value
 *
 * @param  object_instance - object-instance number of the object
 *
 * @return  out-of-service property value
 */
bool Lighting_Output_Out_Of_Service(
    uint32_t object_instance)
{
    bool value = false;
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        value = Lighting_Output[index].Out_Of_Service;
    }

    return value;
}
Exemplo n.º 10
0
/**
 * For a given object instance-number, returns the relinquish-default
 * property value
 *
 * @param  object_instance - object-instance number of the object
 *
 * @return  relinquish-default property value
 */
float Lighting_Output_Relinquish_Default(
    uint32_t object_instance)
{
    float value = 0.0;
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        value = Lighting_Output[index].Relinquish_Default;
    }

    return value;
}
Exemplo n.º 11
0
/**
 * For a given object instance-number, gets the
 * lighting-command-default-priority
 * property value
 *
 * @param object_instance - object-instance number of the object
 *
 * @return the lighting-command-default-priority property value of
 * this object
 */
unsigned Lighting_Output_Default_Priority(
    uint32_t object_instance)
{
    unsigned value = 0;
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        value = Lighting_Output[index].Lighting_Command_Default_Priority;
    }

    return value;
}
Exemplo n.º 12
0
/**
 * For a given object instance-number, sets the relinquish-default
 * property value
 *
 * @param object_instance - object-instance number of the object
 * @param value - floating point relinquish-default value
 *
 * @return true if the relinquish-default property value was set
 */
bool Lighting_Output_Relinquish_Default_Set(
    uint32_t object_instance,
    float value)
{
    bool status = false;
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        Lighting_Output[index].Relinquish_Default = value;
    }

    return status;
}
Exemplo n.º 13
0
/**
 * For a given object instance-number, sets the blink-warn-enable
 * property value in the object.
 *
 * @param object_instance - object-instance number of the object
 * @param enable - holds the value to be set
 *
 * @return true if value was set
 */
bool Lighting_Output_Blink_Warn_Enable_Set(
    uint32_t object_instance,
    bool enable)
{
    bool status = false;
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        Lighting_Output[index].Blink_Warn_Enable = enable;
        status = true;
    }

    return status;
}
Exemplo n.º 14
0
/**
 * For a given object instance-number, sets the in-progress value of the
 * object.
 *
 * @param object_instance - object-instance number of the object
 * @param in_progress - holds the value to be set
 *
 * @return true if value was set
 */
bool Lighting_Output_In_Progress_Set(
    uint32_t object_instance,
    BACNET_LIGHTING_IN_PROGRESS in_progress)
{
    bool status = false;
    unsigned index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        Lighting_Output[index].In_Progress = in_progress;

    }

    return status;
}
Exemplo n.º 15
0
/**
 * For a given object instance-number, gets the lighting-command.
 *
 * @param object_instance - object-instance number of the object
 * @param value - holds the lighting command value
 *
 * @return true if lighting command was retrieved
 */
bool Lighting_Output_Lighting_Command(
    uint32_t object_instance,
    BACNET_LIGHTING_COMMAND *value)
{
    bool status = false;
    unsigned index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        status = lighting_command_copy(value,
            &Lighting_Output[index].Lighting_Command);
    }

    return status;
}
Exemplo n.º 16
0
/**
 * For a given object instance-number, sets the in-progress value of the
 * object.
 *
 * @param object_instance - object-instance number of the object
 * @param in_progress - holds the value to be set
 *
 * @return true if value was set
 */
bool Lighting_Output_Tracking_Value_Set(
    uint32_t object_instance,
    float value)
{
    bool status = false;
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        Lighting_Output[index].Tracking_Value = value;
        status = true;
    }

    return status;
}
Exemplo n.º 17
0
/**
 * For a given object instance-number, sets the egress-time
 * property value of the object.
 *
 * @param object_instance - object-instance number of the object
 * @param seconds - holds the value to be set
 *
 * @return true if value was set
 */
bool Lighting_Output_Egress_Time_Set(
    uint32_t object_instance,
    uint32_t seconds)
{
    bool status = false;
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        Lighting_Output[index].Egress_Time = seconds;
        status = true;
    }

    return status;
}
Exemplo n.º 18
0
/**
 * For a given object instance-number, sets the default-step-increment
 * property value of the object.
 *
 * @param object_instance - object-instance number of the object
 * @param step_increment - holds the value to be set
 *
 * @return true if value was set
 */
bool Lighting_Output_Default_Step_Increment_Set(
    uint32_t object_instance,
    float step_increment)
{
    bool status = false;
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if ((index < MAX_LIGHTING_OUTPUTS) &&
        (step_increment >= 0.1) &&
        (step_increment <= 100.0)) {
        Lighting_Output[index].Default_Step_Increment = step_increment;
        status = true;
    }

    return status;
}
Exemplo n.º 19
0
/**
 * For a given object instance-number, loads the object-name into
 * a characterstring. Note that the object name must be unique
 * within this device.
 *
 * @param  object_instance - object-instance number of the object
 * @param  object_name - holds the object-name retrieved
 *
 * @return  true if object-name was retrieved
 */
bool Lighting_Output_Object_Name(
    uint32_t object_instance,
    BACNET_CHARACTER_STRING * object_name)
{
    char text_string[32] = "";
    bool status = false;
    unsigned index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        sprintf(text_string, "LIGHTING OUTPUT %lu",
            (unsigned long) object_instance);
        status = characterstring_init_ansi(object_name, text_string);
    }

    return status;
}
Exemplo n.º 20
0
/**
 * For a given object instance-number, sets the ramp-rate value of the
 * object.
 *
 * @param object_instance - object-instance number of the object
 * @param percent_per_second - holds the value to be set
 *
 * @return true if value was set
 */
bool Lighting_Output_Default_Ramp_Rate_Set(
    uint32_t object_instance,
    float percent_per_second)
{
    bool status = false;
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if ((index < MAX_LIGHTING_OUTPUTS) &&
        (percent_per_second >= 0.1) &&
        (percent_per_second <= 100.0)) {
        Lighting_Output[index].Default_Ramp_Rate = percent_per_second;
        status = true;
    }

    return status;
}
Exemplo n.º 21
0
/**
 * For a given object instance-number, sets the
 * lighting-command-default-priority property value of the object.
 *
 * @param object_instance - object-instance number of the object
 * @param priority - holds the value to be set
 *
 * @return true if value was set
 */
bool Lighting_Output_Default_Priority_Set(
    uint32_t object_instance,
    unsigned priority)
{
    bool status = false;
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if ((index < MAX_LIGHTING_OUTPUTS) &&
        (priority >= BACNET_MIN_PRIORITY) &&
        (priority <= BACNET_MAX_PRIORITY)) {
        Lighting_Output[index].Lighting_Command_Default_Priority = priority;
        status = true;
    }

    return status;
}
Exemplo n.º 22
0
/**
 * For a given object instance-number, sets the fade-time
 * property value of the object.
 *
 * @param object_instance - object-instance number of the object
 * @param milliseconds - holds the value to be set
 *
 * @return true if value was set
 */
bool Lighting_Output_Default_Fade_Time_Set(
    uint32_t object_instance,
    uint32_t milliseconds)
{
    bool status = false;
    unsigned int index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if ((index < MAX_LIGHTING_OUTPUTS) &&
        (milliseconds >= 100) &&
        (milliseconds <= 86400000)) {
        Lighting_Output[index].Default_Fade_Time = milliseconds;
        status = true;
    }

    return status;
}
Exemplo n.º 23
0
/**
 * For a given object instance-number, determines the value at a
 * given priority.
 *
 * @param  object_instance - object-instance number of the object
 * @param  priority - priority 1..16
 *
 * @return  priority-value of the object
 */
static float Lighting_Output_Priority_Value(
    uint32_t object_instance,
    unsigned priority)
{
    float value = 0.0;
    unsigned index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        if (priority && (priority <= BACNET_MAX_PRIORITY)) {
            priority--;
            value = Lighting_Output[index].Priority_Array[priority];
        }
    }

    return value;
}
Exemplo n.º 24
0
/**
 * For a given object instance-number, sets the lighting-command.
 *
 * @param object_instance - object-instance number of the object
 * @param value - holds the lighting command value
 *
 * @return  true if lighting command was set
 */
bool Lighting_Output_Lighting_Command_Set(
    uint32_t object_instance,
    BACNET_LIGHTING_COMMAND *value)
{
    bool status = false;
    unsigned index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        // FIXME: check lighting command member values
        status = lighting_command_copy(
            &Lighting_Output[index].Lighting_Command,
            value);
        // FIXME: set all the other values, and get the light levels moving
    }

    return status;
}
Exemplo n.º 25
0
/**
 * For a given object instance-number, determines the active priority
 *
 * @param  object_instance - object-instance number of the object
 *
 * @return  active priority 1..16, or 0 if no priority is active
 */
unsigned Lighting_Output_Present_Value_Priority(
    uint32_t object_instance)
{
    unsigned index = 0; /* instance to index conversion */
    unsigned p = 0;     /* loop counter */
    unsigned priority = 0;      /* return value */

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        for (p = 0; p < BACNET_MAX_PRIORITY; p++) {
            if (BIT_CHECK(Lighting_Output[index].Priority_Active_Bits, p)) {
                priority = p + 1;
                break;
            }
        }
    }

    return priority;
}
Exemplo n.º 26
0
unsigned Lighting_Output_Present_Value_Priority(
    uint32_t object_instance)
{
    unsigned index = 0; /* instance to index conversion */
    unsigned i = 0;     /* loop counter */
    unsigned priority = 0;      /* return value */

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
            if (Lighting_Output_Level[index][i] != LIGHTING_LEVEL_NULL) {
                priority = i + 1;
                break;
            }
        }
    }

    return priority;
}
Exemplo n.º 27
0
float Lighting_Output_Present_Value(
    uint32_t object_instance)
{
    float value = LIGHTING_RELINQUISH_DEFAULT;
    unsigned index = 0;
    unsigned i = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
            if (Lighting_Output_Level[index][i] != LIGHTING_LEVEL_NULL) {
                value = Lighting_Output_Level[index][i];
                break;
            }
        }
    }

    return value;
}
Exemplo n.º 28
0
/**
 * For a given object instance-number, determines if the given priority
 * is active or NULL.
 *
 * @param  object_instance - object-instance number of the object
 * @param  priority - priority 1..16
 *
 * @return  true if the priority slot is active
 */
static bool Lighting_Output_Priority_Active(
    uint32_t object_instance,
    unsigned priority)
{
    bool status = false;
    unsigned index = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        if (priority && (priority <= BACNET_MAX_PRIORITY)) {
            priority--;
            if (BIT_CHECK(Lighting_Output[index].Priority_Active_Bits, priority)) {
                status = true;
            }
        }
    }

    return status;
}
Exemplo n.º 29
0
/**
 * For a given object instance-number, determines the present-value
 *
 * @param  object_instance - object-instance number of the object
 *
 * @return  present-value of the object
 */
float Lighting_Output_Present_Value(
    uint32_t object_instance)
{
    float value = 0.0;
    unsigned index = 0;
    unsigned p = 0;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        value = Lighting_Output[index].Relinquish_Default;
        for (p = 0; p < BACNET_MAX_PRIORITY; p++) {
            if (BIT_CHECK(Lighting_Output[index].Priority_Active_Bits, p)) {
                value = Lighting_Output[index].Priority_Array[p];
                break;
            }
        }
    }

    return value;
}
Exemplo n.º 30
0
/**
 * For a given object instance-number, relinquishes the present-value
 * at a given priority 1..16.
 *
 * @param  object_instance - object-instance number of the object
 * @param  priority - priority 1..16
 *
 * @return  true if values are within range and present-value is set.
 */
bool Lighting_Output_Present_Value_Relinquish(
    uint32_t object_instance,
    unsigned priority)
{
    unsigned index = 0;
    bool status = false;

    index = Lighting_Output_Instance_To_Index(object_instance);
    if (index < MAX_LIGHTING_OUTPUTS) {
        if (priority && (priority <= BACNET_MAX_PRIORITY) &&
            (priority != 6 /* reserved */ )) {
            priority--;
            BIT_CLEAR(Lighting_Output[index].Priority_Active_Bits, priority);
            Lighting_Output[index].Priority_Array[priority] = 0.0;
            status = true;
        }
    }

    return status;
}