void ClientActionToneMelody::StartMelodyTone(QString cmelody)
{
    melody = cmelody;
    sub_level = 0;
    unsigned int pos = 0;
    unsigned int melody_ctemp = readIntFromString(melody, &pos);
    melody_timer_counter = 1;
    melody_timer_counter_max = 1;
    if (melody_ctemp) {
        melody_tempo = 7500 / melody_ctemp;
    } else {
        melody_tempo = 75;
    }
    if (melody[pos]=='-') {
        pos++;
        sub_level = readIntFromString(melody, &pos);
    }
    if (melody[pos] == ':') {
        pos++;
    }
    tone_frequency = 1;
    melody_pos = pos;
    tone_periodic = true;
    tone_state = true;
    tone_is_melody = true;
    prog_led_tone_control = false;
    toneMelodyAction();
    updateTimer->setInterval(melody_tempo / 2);
    periodicToneTimer->setInterval(melody_tempo);
    periodicToneTimer->start();
}
Beispiel #2
0
int getValuesFromConnectionString(char* connectionString,
                                    double* x, double* y, int* z) {
    int index = 0;
    int isXSet = FALSE;
    int isYSet = FALSE;
    int isZSet = FALSE;

    // Skip the GET command and the hostname
    while (connectionString[index] != '/' &&
              connectionString[index] != '\0') {
        index++;
    }

    // Skip to the character after the X
    while (connectionString[index] != 'X' &&
              connectionString[index] != '\0') {
        index++;
    }
    // If it didn't stop on null
    if (connectionString[index] == 'X') {
        isXSet = TRUE;
        index++;
        // Read the X value
        *x = readDoubleFromString(&connectionString[index]);
    }

    // Skip to the character after the Y
    while (connectionString[index] != 'Y' &&
              connectionString[index] != '\0') {
        index++;
    }
    // If it didn't stop on null
    if (connectionString[index] == 'Y') {
        isYSet = TRUE;
        index++;
        // Read the Y value
        *y = readDoubleFromString(&connectionString[index]);
    }


    // Skip to the character after the Z
    while (connectionString[index] != 'Z' &&
              connectionString[index] != '\0') {
        index++;
    }
    // If it didn't stop on null
    if (connectionString[index] == 'Z') {
        isZSet = TRUE;
        index++;
        // Read the Z value
        *z = readIntFromString(&connectionString[index]);
    }

    return isXSet && isYSet && isZSet;
}
bool ClientActionToneMelody::setParamsFromMessage(QString message)
{
    prog_led_tone_control = false;
    tone_state = false;
    tone_periodic = false;
    tone_frequency = 1;
    tone_period = 0;

    bool to_buf = false;
    bool by_index = false;
    if (message[0] == 'B') {
        to_buf = true;
        message.remove(0,1);
        if (message[0] == ',') message.remove(0,1);
    }
    if (message[0] == 'I') {
        by_index = true;
        message.remove(0,1);
        if (message[0] == ',') message.remove(0,1);
    }
    if (message[0] == 'B') {
        to_buf = true;
        message.remove(0,1);
        if (message[0] == ',') message.remove(0,1);
    }

    if (by_index) {
        unsigned index = readIntFromString(message, 0);
        StartMelodyToneByIndex(index);
    } else {
        settings->insert("MELODY",message);
        if (to_buf) {
            melody_0 = message;
        }
        StartMelodyTone(message);
    }

    return true;
}