int deviceTestGetInterface(char commandHeader, DeviceInterfaceMode mode, bool fillDeviceArgumentList) {
    if (commandHeader == COMMAND_TEST) {
        if (fillDeviceArgumentList) {
            setFunction("test", 2, 1);
            setArgumentUnsignedHex2(0, "a");
            setArgumentUnsignedHex2(1, "b");
            setResultUnsignedHex2(0, "result");
        }
        return commandLengthValueForMode(mode, 4, 2);
    }
    else if (commandHeader == COMMAND_SIMPLE_TEST) {
        if (fillDeviceArgumentList) {
            setFunctionNoArgumentAndNoResult("simpleTest");
        }
        return commandLengthValueForMode(mode, 0, 0);
    }
    else if (commandHeader == COMMAND_HEAVY_TEST) {
        if (fillDeviceArgumentList) {
            setFunction("heavyTest", 10, 1);
            setArgumentUnsignedHex2(0, "a");
            setArgumentUnsignedHex2(1, "b");
            setArgumentUnsignedHex4(2, "c");
            setArgumentUnsignedHex4(3, "d");
            setArgumentUnsignedHex2(4, "e");
            setArgumentSeparator(5);
            setArgumentUnsignedHex2(6, "f");
            setArgumentUnsignedHex4(7, "g");
            setArgument(8, DEVICE_ARG_UNSIGNED_HEX_6, "h");
            setArgumentUnsignedHex2(9, "i");
            setResult(0, DEVICE_ARG_UNSIGNED_HEX_6, "result");
        }
        return commandLengthValueForMode(mode, 29, 6);
    }
    // Debug Test
    else if (commandHeader == COMMAND_DEBUG_TEST) {
        if (fillDeviceArgumentList) {
            setFunctionNoArgumentAndNoResult("debugTest");
        }
        return commandLengthValueForMode(mode, 0, 0);
    }
    else if (commandHeader == COMMAND_GENERATE_NOTIFY_TEST) {
        if (fillDeviceArgumentList) {
            setFunction("generateNotifyTest", 1, 0);
            setArgumentUnsignedHex2(0, "notifyTestValue");
        }
        return commandLengthValueForMode(mode, 2, 0);
    }
    // Handle a notification test
    else if (mode == DEVICE_MODE_NOTIFY) {
        if (commandHeader == NOTIFY_TEST) {
            if (fillDeviceArgumentList) {
                setNotification("notifyTest", 1);
                setArgumentUnsignedHex2(0, "notifyArg0");
            }
            return 2;
        }
    }
    
    return DEVICE_HEADER_NOT_HANDLED;
}
void fillNotifyResults(char* notificationName) {
    setNotification(notificationName, 5);
    setArgumentUnsignedHex4(0, "x(mm)");
    setArgumentSeparator(1);
    setArgumentUnsignedHex4(2, "y(mm)");
    setArgumentSeparator(3);
    setArgumentUnsignedHex4(4, "ang(1/10)deg");
}
int trajectoryGetInterface(unsigned char commandHeader, DeviceInterfaceMode mode, bool fillDeviceArgumentList) {
    if (commandHeader == COMMAND_TRAJECTORY_GET_ABSOLUTE_POSITION) {
        if (fillDeviceArgumentList) {
            setFunction(GET_ABS_POS_STRING, 0, 5);
            setResultFloatHex4(0, X_MM);
            setResultSeparator(1);
            setResultFloatHex4(2, Y_MM);
            setResultSeparator(3);
            setResultUnsignedHex4(4, ANGLE_1_10_DEG);
        }
        return commandLengthValueForMode(mode, 0, 14);
    } else if (commandHeader == COMMAND_TRAJECTORY_DEBUG_GET_ABSOLUTE_POSITION) {
        // Same return in case of input / output
        if (fillDeviceArgumentList) {
            setFunctionNoArgumentAndNoResult(GET_DEBUG_ABS_POS_STRING);
        }
        return commandLengthValueForMode(mode, 0, 0);
	}
	else if (commandHeader == COMMAND_TRAJECTORY_DEBUG_CODERS) {
		// Same return in case of input / output
		if (fillDeviceArgumentList) {
			setFunctionNoArgumentAndNoResult("Debug Coders History");
		}
		return commandLengthValueForMode(mode, 0, 0);
	} else if (commandHeader == COMMAND_TRAJECTORY_SET_ABSOLUTE_POSITION) {
        if (fillDeviceArgumentList) {
            setFunction(SET_ABS_POS_STRING, 5, 0);
            setArgumentFloatHex6(0, X_MM);
            setArgumentSeparator(1);
            setArgumentFloatHex6(2, Y_MM);
            setArgumentSeparator(3);
            setArgumentUnsignedHex4(4, ANGLE_1_10_DEG);
        }
        return commandLengthValueForMode(mode, 18, 0);
	} else if (commandHeader == COMMAND_TRAJECTORY_ADJUST_X) {
        if (fillDeviceArgumentList) {
            setFunction("Adjust X", 1, 1);
            setArgumentFloatHex6(0, X_MM);
            setResultUnsignedChar1(0, "Done or not");
        }
        return commandLengthValueForMode(mode, 6, 1);
	} else if (commandHeader == COMMAND_TRAJECTORY_ADJUST_Y) {
        if (fillDeviceArgumentList) {
            setFunction("Adjust Y", 1, 1);
            setArgumentFloatHex6(0, X_MM);
            setResultUnsignedChar1(0, "Done or not");
        }
        return commandLengthValueForMode(mode, 6, 1);
    }
    // NOTIFY PARAMETERS
    else if (commandHeader == COMMAND_TRAJECTORY_NOTIFY_OFF) {
        if (fillDeviceArgumentList) {
            setFunctionNoArgumentAndNoResult("Notify Off");
        }
        return commandLengthValueForMode(mode, 0, 0);
    }
    else if (commandHeader == COMMAND_TRAJECTORY_NOTIFY_ON) {
        if (fillDeviceArgumentList) {
            setFunctionNoArgumentAndNoResult("Notify On");
        }
        return commandLengthValueForMode(mode, 0, 0);
    }
    else if (commandHeader == COMMAND_TRAJECTORY_NOTIFY_SET_PARAMETERS) {
        if (fillDeviceArgumentList) {
            setFunction("Notify Set Param", 3, 0);  
            setArgumentFloatHex4(0, "Dist (mm)");
            setArgumentSeparator(1);
            setArgumentFloatHex4(2, "Angle (deciDegree)");
        }
        return commandLengthValueForMode(mode, 9, 0);
    }
    // NOTIFICATION
    if (DEVICE_MODE_NOTIFY == mode) {
        if (commandHeader == NOTIFY_TRAJECTORY_CHANGED) {
            if (fillDeviceArgumentList) {
                setNotification("Trajectory Changed", 7);
                setArgumentUnsignedHex4(0, "x(mm)");
                setArgumentSeparator(1);
                setArgumentUnsignedHex4(2, "y(mm)");
                setArgumentSeparator(3);
                setArgumentUnsignedHex4(4, "ang(1/10)deg");
                setArgumentSeparator(5);
                setArgumentUnsignedChar1(6, "Trajectory Type");
            }
            return 16;
        }
    }
    return DEVICE_HEADER_NOT_HANDLED;
}
Esempio n. 4
0
MqlHash::MqlHash(QObject *pParent, QSqlDatabase pDb)
  : XCachedHash<QString, QString>(pParent, QString(), pDb)
{
  setNotification(QStringList() << "metasql" << "pkgmetasql");
}