本文整理汇总了C++中STATE函数的典型用法代码示例。如果您正苦于以下问题:C++ STATE函数的具体用法?C++ STATE怎么用?C++ STATE使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STATE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HdlrFunc1
/* handler for function 1 */
static Obj HdlrFunc1 (
Obj self )
{
Obj t_1 = 0;
Obj t_2 = 0;
Bag oldFrame;
/* allocate new stack frame */
SWITCH_TO_NEW_FRAME(self,0,0,oldFrame);
/* range2 := function ( a, b )
return [ a .. b ];
end; */
t_1 = NewFunction( NameFunc[2], 2, ArgStringToList("a,b"), HdlrFunc2 );
SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
t_2 = NewFunctionBody();
SET_STARTLINE_BODY(t_2, 1);
SET_ENDLINE_BODY(t_2, 1);
SET_FILENAME_BODY(t_2, FileName);
SET_BODY_FUNC(t_1, t_2);
AssGVar( G_range2, t_1 );
/* range3 := function ( a, b, c )
return [ a, b .. c ];
end; */
t_1 = NewFunction( NameFunc[3], 3, ArgStringToList("a,b,c"), HdlrFunc3 );
SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
t_2 = NewFunctionBody();
SET_STARTLINE_BODY(t_2, 2);
SET_ENDLINE_BODY(t_2, 2);
SET_FILENAME_BODY(t_2, FileName);
SET_BODY_FUNC(t_1, t_2);
AssGVar( G_range3, t_1 );
/* runtest := function ( )
BreakOnError := false;
CALL_WITH_CATCH( range2, [ 1, 2 ^ 80 ] );
CALL_WITH_CATCH( range2, [ - 2 ^ 80, 0 ] );
CALL_WITH_CATCH( range3, [ 1, 2, 2 ^ 80 ] );
CALL_WITH_CATCH( range3, [ - 2 ^ 80, 0, 1 ] );
CALL_WITH_CATCH( range3, [ 0, 2 ^ 80, 2 ^ 81 ] );
Display( [ 1, 2 .. 2 ] );
CALL_WITH_CATCH( range3, [ 2, 2, 2 ] );
Display( [ 2, 4 .. 6 ] );
CALL_WITH_CATCH( range3, [ 2, 4, 7 ] );
Display( [ 2, 4 .. 2 ] );
Display( [ 2, 4 .. 0 ] );
CALL_WITH_CATCH( range3, [ 4, 2, 1 ] );
Display( [ 4, 2 .. 0 ] );
Display( [ 4, 2 .. 8 ] );
return;
end; */
t_1 = NewFunction( NameFunc[4], 0, 0, HdlrFunc4 );
SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
t_2 = NewFunctionBody();
SET_STARTLINE_BODY(t_2, 4);
SET_ENDLINE_BODY(t_2, 26);
SET_FILENAME_BODY(t_2, FileName);
SET_BODY_FUNC(t_1, t_2);
AssGVar( G_runtest, t_1 );
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}
示例2: nl_dump_conntrack_table
int nl_dump_conntrack_table(void)
{
return nfct_query(STATE(dump), NFCT_Q_DUMP, &CONFIG(family));
}
示例3: taskMainPidLoop
void taskMainPidLoop(void)
{
cycleTime = getTaskDeltaTime(TASK_SELF);
dT = (float)cycleTime * 0.000001f;
// Calculate average cycle time and average jitter
filteredCycleTime = pt1FilterApply4(&filteredCycleTimeState, cycleTime, 1, dT);
#ifdef DEBUG_CYCLE_TIME
debug[0] = cycleTime;
debug[1] = cycleTime - filteredCycleTime;
#endif
imuUpdateGyroAndAttitude();
updateRcCommands(); // this must be called here since applyAltHold directly manipulates rcCommands[]
if (rxConfig()->rcSmoothing) {
filterRc();
}
#if defined(BARO) || defined(SONAR)
haveUpdatedRcCommandsOnce = true;
#endif
// Read out gyro temperature. can use it for something somewhere. maybe get MCU temperature instead? lots of fun possibilities.
if (gyro.temperature) {
gyro.temperature(&telemTemperature1);
}
#ifdef MAG
if (sensors(SENSOR_MAG)) {
updateMagHold();
}
#endif
#ifdef GTUNE
updateGtuneState();
#endif
#if defined(BARO) || defined(SONAR)
if (sensors(SENSOR_BARO) || sensors(SENSOR_SONAR)) {
if (FLIGHT_MODE(BARO_MODE) || FLIGHT_MODE(SONAR_MODE)) {
applyAltHold();
}
}
#endif
// If we're armed, at minimum throttle, and we do arming via the
// sticks, do not process yaw input from the rx. We do this so the
// motors do not spin up while we are trying to arm or disarm.
// Allow yaw control for tricopters if the user wants the servo to move even when unarmed.
if (isUsingSticksForArming() && rcData[THROTTLE] <= rxConfig()->mincheck
#ifndef USE_QUAD_MIXER_ONLY
#ifdef USE_SERVOS
&& !((mixerConfig()->mixerMode == MIXER_TRI || mixerConfig()->mixerMode == MIXER_CUSTOM_TRI) && mixerConfig()->tri_unarmed_servo)
#endif
&& mixerConfig()->mixerMode != MIXER_AIRPLANE
&& mixerConfig()->mixerMode != MIXER_FLYING_WING
#endif
) {
rcCommand[YAW] = 0;
}
if (throttleCorrectionConfig()->throttle_correction_value && (FLIGHT_MODE(ANGLE_MODE) || FLIGHT_MODE(HORIZON_MODE))) {
rcCommand[THROTTLE] += calculateThrottleAngleCorrection(throttleCorrectionConfig()->throttle_correction_value);
}
#ifdef GPS
if (sensors(SENSOR_GPS)) {
if ((FLIGHT_MODE(GPS_HOME_MODE) || FLIGHT_MODE(GPS_HOLD_MODE)) && STATE(GPS_FIX_HOME)) {
updateGpsStateForHomeAndHoldMode();
}
}
#endif
// PID - note this is function pointer set by setPIDController()
pid_controller(
pidProfile(),
currentControlRateProfile,
imuConfig()->max_angle_inclination,
&accelerometerConfig()->accelerometerTrims,
rxConfig()
);
mixTable();
#ifdef USE_SERVOS
filterServos();
writeServos();
#endif
if (motorControlEnable) {
writeMotors();
}
#ifdef USE_SDCARD
afatfs_poll();
#endif
//.........这里部分代码省略.........
示例4: board_remove_msg
int board_remove_msg(int board_type, struct char_data *ch, char *arg, struct obj_data *board)
{
int ind, msg, slot_num;
char number[MAX_INPUT_LENGTH], buf[MAX_INPUT_LENGTH];
struct descriptor_data *d;
one_argument(arg, number);
if (!*number || !is_number(number))
return (0);
if (!(msg = atoi(number)))
return (0);
if (!num_of_msgs[board_type]) {
send_to_char(ch, "The board is empty!\r\n");
return (1);
}
if (msg < 1 || msg > num_of_msgs[board_type]) {
send_to_char(ch, "That message exists only in your imagination.\r\n");
return (1);
}
#if NEWEST_AT_TOP
ind = num_of_msgs[board_type] - msg;
#else
ind = msg - 1;
#endif
if (!MSG_HEADING(board_type, ind)) {
send_to_char(ch, "That message appears to be screwed up.\r\n");
return (1);
}
snprintf(buf, sizeof(buf), "(%s)", GET_NAME(ch));
if (GET_LEVEL(ch) < REMOVE_LVL(board_type) &&
!(strstr(MSG_HEADING(board_type, ind), buf))) {
send_to_char(ch, "You are not holy enough to remove other people's messages.\r\n");
return (1);
}
if (GET_LEVEL(ch) < MSG_LEVEL(board_type, ind)) {
send_to_char(ch, "You can't remove a message holier than yourself.\r\n");
return (1);
}
slot_num = MSG_SLOTNUM(board_type, ind);
if (slot_num < 0 || slot_num >= INDEX_SIZE) {
send_to_char(ch, "That message is majorly screwed up.\r\n");
log("SYSERR: The board is seriously screwed up. (Room #%d)", GET_ROOM_VNUM(IN_ROOM(ch)));
return (1);
}
for (d = descriptor_list; d; d = d->next)
if (STATE(d) == CON_PLAYING && d->str == &(msg_storage[slot_num])) {
send_to_char(ch, "At least wait until the author is finished before removing it!\r\n");
return (1);
}
if (msg_storage[slot_num])
free(msg_storage[slot_num]);
msg_storage[slot_num] = 0;
msg_storage_taken[slot_num] = 0;
if (MSG_HEADING(board_type, ind))
free(MSG_HEADING(board_type, ind));
for (; ind < num_of_msgs[board_type] - 1; ind++) {
MSG_HEADING(board_type, ind) = MSG_HEADING(board_type, ind + 1);
MSG_SLOTNUM(board_type, ind) = MSG_SLOTNUM(board_type, ind + 1);
MSG_LEVEL(board_type, ind) = MSG_LEVEL(board_type, ind + 1);
}
num_of_msgs[board_type]--;
send_to_char(ch, "Message removed.\r\n");
snprintf(buf, sizeof(buf), "$n just removed message %d.", msg);
act(buf, FALSE, ch, 0, 0, TO_ROOM);
board_save_board(board_type);
return (1);
}
示例5: processRx
void processRx(void)
{
static bool armedBeeperOn = false;
calculateRxChannelsAndUpdateFailsafe(currentTime);
// in 3D mode, we need to be able to disarm by switch at any time
if (feature(FEATURE_3D)) {
if (!IS_RC_MODE_ACTIVE(BOXARM))
mwDisarm();
}
updateRSSI(currentTime);
if (feature(FEATURE_FAILSAFE)) {
if (currentTime > FAILSAFE_POWER_ON_DELAY_US && !failsafeIsMonitoring()) {
failsafeStartMonitoring();
}
failsafeUpdateState();
}
throttleStatus_e throttleStatus = calculateThrottleStatus(&masterConfig.rxConfig, masterConfig.flight3DConfig.deadband3d_throttle);
if (throttleStatus == THROTTLE_LOW) {
pidResetErrorAngle();
pidResetErrorGyro();
}
// When armed and motors aren't spinning, do beeps and then disarm
// board after delay so users without buzzer won't lose fingers.
// mixTable constrains motor commands, so checking throttleStatus is enough
if (ARMING_FLAG(ARMED)
&& feature(FEATURE_MOTOR_STOP)
&& !STATE(FIXED_WING)
) {
if (isUsingSticksForArming()) {
if (throttleStatus == THROTTLE_LOW) {
if (masterConfig.auto_disarm_delay != 0
&& (int32_t)(disarmAt - millis()) < 0
) {
// auto-disarm configured and delay is over
mwDisarm();
armedBeeperOn = false;
} else {
// still armed; do warning beeps while armed
beeper(BEEPER_ARMED);
armedBeeperOn = true;
}
} else {
// throttle is not low
if (masterConfig.auto_disarm_delay != 0) {
// extend disarm time
disarmAt = millis() + masterConfig.auto_disarm_delay * 1000;
}
if (armedBeeperOn) {
beeperSilence();
armedBeeperOn = false;
}
}
} else {
// arming is via AUX switch; beep while throttle low
if (throttleStatus == THROTTLE_LOW) {
beeper(BEEPER_ARMED);
armedBeeperOn = true;
} else if (armedBeeperOn) {
beeperSilence();
armedBeeperOn = false;
}
}
}
processRcStickPositions(&masterConfig.rxConfig, throttleStatus, masterConfig.retarded_arm, masterConfig.disarm_kill_switch);
if (feature(FEATURE_INFLIGHT_ACC_CAL)) {
updateInflightCalibrationState();
}
updateActivatedModes(currentProfile->modeActivationConditions);
if (!cliMode) {
updateAdjustmentStates(currentProfile->adjustmentRanges);
processRcAdjustments(currentControlRateProfile, &masterConfig.rxConfig);
}
bool canUseHorizonMode = true;
if ((IS_RC_MODE_ACTIVE(BOXANGLE) || (feature(FEATURE_FAILSAFE) && failsafeIsActive())) && (sensors(SENSOR_ACC))) {
// bumpless transfer to Level mode
canUseHorizonMode = false;
if (!FLIGHT_MODE(ANGLE_MODE)) {
pidResetErrorAngle();
ENABLE_FLIGHT_MODE(ANGLE_MODE);
}
} else {
DISABLE_FLIGHT_MODE(ANGLE_MODE); // failsafe support
}
//.........这里部分代码省略.........
示例6: ntfs_write_r
ssize_t ntfs_write_r (struct _reent *r, int fd, const char *ptr, size_t len)
{
ntfs_log_trace("fd %p, ptr %p, len %u\n", (void *) fd, ptr, len);
ntfs_file_state* file = STATE(((s64) fd));
ssize_t written = 0;
off_t old_pos = 0;
// Sanity check
if (!file || !file->vd || !file->ni || !file->data_na) {
r->_errno = EINVAL;
return -1;
}
// Short circuit cases where we don't actually have to do anything
if (!ptr || len <= 0) {
return 0;
}
// Lock
ntfsLock(file->vd);
// Check that we are allowed to write to this file
if (!file->write) {
ntfsUnlock(file->vd);
r->_errno = EACCES;
return -1;
}
// If we are in append mode, backup the current position and move to the end of the file
if (file->append) {
old_pos = file->pos;
file->pos = file->len;
}
// Write to the files data atrribute
while (len) {
ssize_t ret = ntfs_attr_pwrite(file->data_na, file->pos, len, ptr);
if (ret <= 0) {
ntfsUnlock(file->vd);
r->_errno = errno;
return -1;
}
len -= ret;
file->pos += ret;
written += ret;
}
// If we are in append mode, restore the current position to were it was prior to this write
if (file->append) {
file->pos = old_pos;
}
// Mark the file for archiving (if we actually wrote something)
if (written)
file->ni->flags |= FILE_ATTR_ARCHIVE;
// Update the files data length
file->len = file->data_na->data_size;
// Unlock
ntfsUnlock(file->vd);
return written;
}
示例7: ntfs_open_r
int ntfs_open_r (struct _reent *r, void *fileStruct, const char *path, int flags, int mode)
{
ntfs_log_trace("fileStruct %p, path %s, flags %i, mode %i\n", (void *) fileStruct, path, flags, mode);
ntfs_file_state* file = STATE(fileStruct);
// Get the volume descriptor for this path
file->vd = ntfsGetVolume(path);
if (!file->vd) {
r->_errno = ENODEV;
return -1;
}
// Lock
ntfsLock(file->vd);
// Determine which mode the file is opened for
file->flags = flags;
if ((flags & 0x03) == O_RDONLY) {
file->read = true;
file->write = false;
file->append = false;
} else if ((flags & 0x03) == O_WRONLY) {
file->read = false;
file->write = true;
file->append = (flags & O_APPEND);
} else if ((flags & 0x03) == O_RDWR) {
file->read = true;
file->write = true;
file->append = (flags & O_APPEND);
} else {
r->_errno = EACCES;
ntfsUnlock(file->vd);
return -1;
}
// Try and find the file and (if found) ensure that it is not a directory
file->ni = ntfsOpenEntry(file->vd, path);
if (file->ni && (file->ni->mrec->flags & MFT_RECORD_IS_DIRECTORY)) {
ntfsCloseEntry(file->vd, file->ni);
ntfsUnlock(file->vd);
r->_errno = EISDIR;
return -1;
}
// Are we creating this file?
if ((flags & O_CREAT) && !file->ni) {
// Create the file
file->ni = ntfsCreate(file->vd, path, S_IFREG, NULL);
if (!file->ni) {
ntfsUnlock(file->vd);
return -1;
}
}
// Sanity check, the file should be open by now
if (!file->ni) {
ntfsUnlock(file->vd);
r->_errno = ENOENT;
return -1;
}
// Open the files data attribute
file->data_na = ntfs_attr_open(file->ni, AT_DATA, AT_UNNAMED, 0);
if(!file->data_na) {
ntfsCloseEntry(file->vd, file->ni);
ntfsUnlock(file->vd);
return -1;
}
// Determine if this files data is compressed and/or encrypted
file->compressed = NAttrCompressed(file->data_na) || (file->ni->flags & FILE_ATTR_COMPRESSED);
file->encrypted = NAttrEncrypted(file->data_na) || (file->ni->flags & FILE_ATTR_ENCRYPTED);
// We cannot read/write encrypted files
if (file->encrypted) {
ntfs_attr_close(file->data_na);
ntfsCloseEntry(file->vd, file->ni);
ntfsUnlock(file->vd);
r->_errno = EACCES;
return -1;
}
// Make sure we aren't trying to write to a read-only file
if ((file->ni->flags & FILE_ATTR_READONLY) && file->write) {
ntfs_attr_close(file->data_na);
ntfsCloseEntry(file->vd, file->ni);
ntfsUnlock(file->vd);
r->_errno = EROFS;
return -1;
}
// Truncate the file if requested
if ((flags & O_TRUNC) && file->write) {
if (ntfs_attr_truncate(file->data_na, 0)) {
ntfs_attr_close(file->data_na);
ntfsCloseEntry(file->vd, file->ni);
//.........这里部分代码省略.........
示例8: processRx
void processRx(void)
{
static bool armedBeeperOn = false;
calculateRxChannelsAndUpdateFailsafe(currentTime);
// in 3D mode, we need to be able to disarm by switch at any time
if (feature(FEATURE_3D)) {
if (!IS_RC_MODE_ACTIVE(BOXARM))
mwDisarm();
}
updateRSSI(currentTime);
if (feature(FEATURE_FAILSAFE)) {
if (currentTime > FAILSAFE_POWER_ON_DELAY_US && !failsafeIsMonitoring()) {
failsafeStartMonitoring();
}
failsafeUpdateState();
}
throttleStatus_e throttleStatus = calculateThrottleStatus(&masterConfig.rxConfig, masterConfig.flight3DConfig.deadband3d_throttle);
// When armed and motors aren't spinning, do beeps and then disarm
// board after delay so users without buzzer won't lose fingers.
// mixTable constrains motor commands, so checking throttleStatus is enough
if (ARMING_FLAG(ARMED)
&& feature(FEATURE_MOTOR_STOP)
&& !STATE(FIXED_WING)
) {
if (isUsingSticksForArming()) {
if (throttleStatus == THROTTLE_LOW) {
if (masterConfig.auto_disarm_delay != 0
&& (int32_t)(disarmAt - millis()) < 0
) {
// auto-disarm configured and delay is over
mwDisarm();
armedBeeperOn = false;
} else {
// still armed; do warning beeps while armed
beeper(BEEPER_ARMED);
armedBeeperOn = true;
}
} else {
// throttle is not low
if (masterConfig.auto_disarm_delay != 0) {
// extend disarm time
disarmAt = millis() + masterConfig.auto_disarm_delay * 1000;
}
if (armedBeeperOn) {
beeperSilence();
armedBeeperOn = false;
}
}
} else {
// arming is via AUX switch; beep while throttle low
if (throttleStatus == THROTTLE_LOW) {
beeper(BEEPER_ARMED);
armedBeeperOn = true;
} else if (armedBeeperOn) {
beeperSilence();
armedBeeperOn = false;
}
}
}
processRcStickPositions(&masterConfig.rxConfig, throttleStatus, masterConfig.disarm_kill_switch);
updateActivatedModes(currentProfile->modeActivationConditions);
if (!cliMode) {
updateAdjustmentStates(currentProfile->adjustmentRanges);
processRcAdjustments(currentControlRateProfile, &masterConfig.rxConfig);
}
bool canUseHorizonMode = true;
if ((IS_RC_MODE_ACTIVE(BOXANGLE) || (feature(FEATURE_FAILSAFE) && failsafeIsActive()) || naivationRequiresAngleMode()) && sensors(SENSOR_ACC)) {
// bumpless transfer to Level mode
canUseHorizonMode = false;
if (!FLIGHT_MODE(ANGLE_MODE)) {
ENABLE_FLIGHT_MODE(ANGLE_MODE);
}
} else {
DISABLE_FLIGHT_MODE(ANGLE_MODE); // failsafe support
}
if (IS_RC_MODE_ACTIVE(BOXHORIZON) && canUseHorizonMode) {
DISABLE_FLIGHT_MODE(ANGLE_MODE);
if (!FLIGHT_MODE(HORIZON_MODE)) {
ENABLE_FLIGHT_MODE(HORIZON_MODE);
}
} else {
DISABLE_FLIGHT_MODE(HORIZON_MODE);
//.........这里部分代码省略.........
示例9: taskMainPidLoop
void taskMainPidLoop(void)
{
cycleTime = getTaskDeltaTime(TASK_SELF);
dT = (float)cycleTime * 0.000001f;
imuUpdateAccelerometer();
imuUpdateGyroAndAttitude();
annexCode();
if (masterConfig.rxConfig.rcSmoothing) {
filterRc(isRXDataNew);
}
#if defined(NAV)
if (isRXDataNew) {
updateWaypointsAndNavigationMode();
}
#endif
isRXDataNew = false;
#if defined(NAV)
updatePositionEstimator();
applyWaypointNavigationAndAltitudeHold();
#endif
// If we're armed, at minimum throttle, and we do arming via the
// sticks, do not process yaw input from the rx. We do this so the
// motors do not spin up while we are trying to arm or disarm.
// Allow yaw control for tricopters if the user wants the servo to move even when unarmed.
if (isUsingSticksForArming() && rcData[THROTTLE] <= masterConfig.rxConfig.mincheck
#ifndef USE_QUAD_MIXER_ONLY
#ifdef USE_SERVOS
&& !((masterConfig.mixerMode == MIXER_TRI || masterConfig.mixerMode == MIXER_CUSTOM_TRI) && masterConfig.mixerConfig.tri_unarmed_servo)
#endif
&& masterConfig.mixerMode != MIXER_AIRPLANE
&& masterConfig.mixerMode != MIXER_FLYING_WING
&& masterConfig.mixerMode != MIXER_CUSTOM_AIRPLANE
#endif
) {
rcCommand[YAW] = 0;
}
// Apply throttle tilt compensation
if (!STATE(FIXED_WING)) {
int16_t thrTiltCompStrength = 0;
if (navigationRequiresThrottleTiltCompensation()) {
thrTiltCompStrength = 100;
}
else if (currentProfile->throttle_tilt_compensation_strength && (FLIGHT_MODE(ANGLE_MODE) || FLIGHT_MODE(HORIZON_MODE))) {
thrTiltCompStrength = currentProfile->throttle_tilt_compensation_strength;
}
if (thrTiltCompStrength) {
rcCommand[THROTTLE] = constrain(masterConfig.escAndServoConfig.minthrottle
+ (rcCommand[THROTTLE] - masterConfig.escAndServoConfig.minthrottle) * calculateThrottleTiltCompensationFactor(thrTiltCompStrength),
masterConfig.escAndServoConfig.minthrottle,
masterConfig.escAndServoConfig.maxthrottle);
}
}
pidController(¤tProfile->pidProfile, currentControlRateProfile, &masterConfig.rxConfig);
#ifdef HIL
if (hilActive) {
hilUpdateControlState();
motorControlEnable = false;
}
#endif
mixTable();
#ifdef USE_SERVOS
if (isMixerUsingServos()) {
servoMixer();
}
if (feature(FEATURE_SERVO_TILT)) {
processServoTilt();
}
//Servos should be filtered or written only when mixer is using servos or special feaures are enabled
if (isServoOutputEnabled()) {
filterServos();
writeServos();
}
#endif
if (motorControlEnable) {
writeMotors();
}
#ifdef BLACKBOX
if (!cliMode && feature(FEATURE_BLACKBOX)) {
handleBlackbox();
}
#endif
//.........这里部分代码省略.........
示例10: on_headers_complete
static int
on_headers_complete (http_parser *self) {
set_state(self, STATE(HEADERS_COMPLETE));
return 0;
}
示例11: HdlrFunc1
/* handler for function 1 */
static Obj HdlrFunc1 (
Obj self )
{
Obj t_1 = 0;
Obj t_2 = 0;
Bag oldFrame;
/* allocate new stack frame */
SWITCH_TO_NEW_FRAME(self,0,0,oldFrame);
/* f1 := function ( a )
Print( "f1:", a, "\n" );
return;
end; */
t_1 = NewFunction( NameFunc[2], 1, 0, HdlrFunc2 );
SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
t_2 = NewBag( T_BODY, sizeof(BodyHeader) );
SET_STARTLINE_BODY(t_2, 1);
SET_ENDLINE_BODY(t_2, 3);
SET_FILENAME_BODY(t_2, FileName);
SET_BODY_FUNC(t_1, t_2);
CHANGED_BAG( STATE(CurrLVars) );
AssGVar( G_f1, t_1 );
/* f2 := function ( a, b )
Print( "f2:", a, ":", b, "\n" );
return;
end; */
t_1 = NewFunction( NameFunc[3], 2, 0, HdlrFunc3 );
SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
t_2 = NewBag( T_BODY, sizeof(BodyHeader) );
SET_STARTLINE_BODY(t_2, 5);
SET_ENDLINE_BODY(t_2, 7);
SET_FILENAME_BODY(t_2, FileName);
SET_BODY_FUNC(t_1, t_2);
CHANGED_BAG( STATE(CurrLVars) );
AssGVar( G_f2, t_1 );
/* f3 := function ( a... )
Print( "f3:", a, "\n" );
return;
end; */
t_1 = NewFunction( NameFunc[4], -1, 0, HdlrFunc4 );
SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
t_2 = NewBag( T_BODY, sizeof(BodyHeader) );
SET_STARTLINE_BODY(t_2, 9);
SET_ENDLINE_BODY(t_2, 11);
SET_FILENAME_BODY(t_2, FileName);
SET_BODY_FUNC(t_1, t_2);
CHANGED_BAG( STATE(CurrLVars) );
AssGVar( G_f3, t_1 );
/* f4 := function ( a, b... )
Print( "f4:", a, ":", b, "\n" );
return;
end; */
t_1 = NewFunction( NameFunc[5], -2, 0, HdlrFunc5 );
SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
t_2 = NewBag( T_BODY, sizeof(BodyHeader) );
SET_STARTLINE_BODY(t_2, 13);
SET_ENDLINE_BODY(t_2, 15);
SET_FILENAME_BODY(t_2, FileName);
SET_BODY_FUNC(t_1, t_2);
CHANGED_BAG( STATE(CurrLVars) );
AssGVar( G_f4, t_1 );
/* runtest := function ( )
f1( 2 );
f2( 2, 3 );
f3( );
f3( 2 );
f3( 2, 3, 4 );
f4( 1 );
f4( 1, 2 );
f4( 1, 2, 3 );
return;
end; */
t_1 = NewFunction( NameFunc[6], 0, 0, HdlrFunc6 );
SET_ENVI_FUNC( t_1, STATE(CurrLVars) );
t_2 = NewBag( T_BODY, sizeof(BodyHeader) );
SET_STARTLINE_BODY(t_2, 17);
SET_ENDLINE_BODY(t_2, 26);
SET_FILENAME_BODY(t_2, FileName);
SET_BODY_FUNC(t_1, t_2);
CHANGED_BAG( STATE(CurrLVars) );
AssGVar( G_runtest, t_1 );
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
/* return; */
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
}
示例12: on_message_begin
static int
on_message_begin (http_parser *self) {
set_state(self, STATE(MESSAGE_BEGIN));
return 0;
}
示例13: subTaskMainSubprocesses
void subTaskMainSubprocesses(void)
{
const uint32_t startTime = micros();
// Read out gyro temperature. can use it for something somewhere. maybe get MCU temperature instead? lots of fun possibilities.
if (gyro.temperature) {
gyro.temperature(&telemTemperature1);
}
#ifdef GTUNE
updateGtuneState();
#endif
#if defined(BARO) || defined(SONAR)
// FIXME outdated comments?
// updateRcCommands sets rcCommand, which is needed by updateAltHoldState and updateSonarAltHoldState
// this must be called here since applyAltHold directly manipulates rcCommands[]
updateRcCommands();
if (sensors(SENSOR_BARO) || sensors(SENSOR_SONAR)) {
if (FLIGHT_MODE(BARO_MODE) || FLIGHT_MODE(SONAR_MODE)) {
applyAltHold();
}
}
#endif
#ifdef MAG
if (sensors(SENSOR_MAG)) {
updateMagHold();
}
#endif
// If we're armed, at minimum throttle, and we do arming via the
// sticks, do not process yaw input from the rx. We do this so the
// motors do not spin up while we are trying to arm or disarm.
// Allow yaw control for tricopters if the user wants the servo to move even when unarmed.
if (isUsingSticksForArming() && rcData[THROTTLE] <= rxConfig()->mincheck
#ifndef USE_QUAD_MIXER_ONLY
#ifdef USE_SERVOS
&& !((mixerConfig()->mixerMode == MIXER_TRI || mixerConfig()->mixerMode == MIXER_CUSTOM_TRI) && mixerConfig()->tri_unarmed_servo)
#endif
&& mixerConfig()->mixerMode != MIXER_AIRPLANE
&& mixerConfig()->mixerMode != MIXER_FLYING_WING
#endif
) {
rcCommand[YAW] = 0;
}
if (throttleCorrectionConfig()->throttle_correction_value && (FLIGHT_MODE(ANGLE_MODE) || FLIGHT_MODE(HORIZON_MODE))) {
rcCommand[THROTTLE] += calculateThrottleAngleCorrection(throttleCorrectionConfig()->throttle_correction_value);
}
processRcCommand();
#ifdef GPS
if (sensors(SENSOR_GPS)) {
if ((FLIGHT_MODE(GPS_HOME_MODE) || FLIGHT_MODE(GPS_HOLD_MODE)) && STATE(GPS_FIX_HOME)) {
updateGpsStateForHomeAndHoldMode();
}
}
#endif
#ifdef USE_SDCARD
afatfs_poll();
#endif
#ifdef BLACKBOX
if (!cliMode && feature(FEATURE_BLACKBOX)) {
handleBlackbox();
}
#endif
if (debugMode == DEBUG_PIDLOOP) {debug[1] = micros() - startTime;}
}
示例14: check_stats
/**
* Проверка стартовых и итоговых статов.
* Если невалидные стартовые статы - чар отправляется на реролл.
* Если невалидные только итоговые статы - идет перезапись со стартовых с учетом мортов и славы.
*/
bool check_stats(CHAR_DATA *ch)
{
// иммов травмировать не стоит
if (IS_IMMORTAL(ch))
{
return 1;
}
int have_stats = ch->get_inborn_str() + ch->get_inborn_dex() + ch->get_inborn_int() + ch->get_inborn_wis()
+ ch->get_inborn_con() + ch->get_inborn_cha();
// чар со старым роллом статов или после попыток поправить статы в файле
if (bad_start_stats(ch))
{
snprintf(buf, MAX_STRING_LENGTH, "\r\n%sВаши параметры за вычетом перевоплощений:\r\n"
"Сила: %d, Ловкость: %d, Ум: %d, Мудрость: %d, Телосложение: %d, Обаяние: %d\r\n"
"Если вы долго отсутствовали в игре, то изменения, касающиеся стартовых параметров были следующие:%s\r\n"
"\r\n"
"\tДобавлено ограничение на максимальный класс защиты:\r\n"
"\tВоры, наемники и дружинники - -250\r\n"
"\tКупцы, богатыри, витязи, охотники, кузнецы - -200\r\n"
"\tЛекари, волхвы - -150\r\n"
"\tКудесники, чернокнижники, колдуны, волшебники - -100\r\n"
"\r\n"
"\tТелосложение: изменились коэффициенты профессий и максимальное родное тело (50) в расчетах при\r\n"
"\tполучении уровня, поэтому изменены границы стартового телосложения у некоторых профессий,\r\n"
"\tв целом это увеличивает кол-во жизней персонажа тем сильнее, чем больше у него было ремортов.\r\n"
"\r\n",
CCIGRN(ch, C_SPR),
ch->get_inborn_str() - GET_REMORT(ch),
ch->get_inborn_dex() - GET_REMORT(ch),
ch->get_inborn_int() - GET_REMORT(ch),
ch->get_inborn_wis() - GET_REMORT(ch),
ch->get_inborn_con() - GET_REMORT(ch),
ch->get_inborn_cha() - GET_REMORT(ch),
CCNRM(ch, C_SPR));
SEND_TO_Q(buf, ch->desc);
// данную фигню мы делаем для того, чтобы из ролла нельзя было случайно так просто выйти
// сразу, не раскидав статы, а то много любителей тригов и просто нажатий не глядя
ch->set_str(MIN_STR(ch));
ch->set_dex(MIN_DEX(ch));
ch->set_int(MIN_INT(ch));
ch->set_wis(MIN_WIS(ch));
ch->set_con(MIN_CON(ch));
ch->set_cha(MIN_CHA(ch));
snprintf(buf, MAX_STRING_LENGTH, "%sПросим вас заново распределить основные параметры персонажа.%s\r\n",
CCIGRN(ch, C_SPR), CCNRM(ch, C_SPR));
SEND_TO_Q(buf, ch->desc);
SEND_TO_Q("\r\n* В связи с проблемами перевода фразы ANYKEY нажмите ENTER *", ch->desc);
STATE(ch->desc) = CON_RESET_STATS;
return 0;
}
// стартовые статы в поряде, но слава не сходится (снялась по времени или иммом)
if (bad_real_stats(ch, have_stats))
{
recalculate_stats(ch);
}
return 1;
}
示例15: mavlinkSendPosition
void mavlinkSendPosition(void)
{
uint16_t msgLength;
uint8_t gpsFixType = 0;
if (!sensors(SENSOR_GPS))
return;
if (!STATE(GPS_FIX)) {
gpsFixType = 1;
}
else {
if (GPS_numSat < 5) {
gpsFixType = 2;
}
else {
gpsFixType = 3;
}
}
mavlink_msg_gps_raw_int_pack(0, 200, &mavMsg,
// time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
micros(),
// fix_type 0-1: no fix, 2: 2D fix, 3: 3D fix. Some applications will not use the value of this field unless it is at least two, so always correctly fill in the fix.
gpsFixType,
// lat Latitude in 1E7 degrees
GPS_coord[LAT],
// lon Longitude in 1E7 degrees
GPS_coord[LON],
// alt Altitude in 1E3 meters (millimeters) above MSL
GPS_altitude * 1000,
// eph GPS HDOP horizontal dilution of position in cm (m*100). If unknown, set to: 65535
65535,
// epv GPS VDOP horizontal dilution of position in cm (m*100). If unknown, set to: 65535
65535,
// vel GPS ground speed (m/s * 100). If unknown, set to: 65535
GPS_speed,
// cog Course over ground (NOT heading, but direction of movement) in degrees * 100, 0.0..359.99 degrees. If unknown, set to: 65535
GPS_ground_course * 10,
// satellites_visible Number of satellites visible. If unknown, set to 255
GPS_numSat);
msgLength = mavlink_msg_to_send_buffer(mavBuffer, &mavMsg);
mavlinkSerialWrite(mavBuffer, msgLength);
// Global position
mavlink_msg_global_position_int_pack(0, 200, &mavMsg,
// time_usec Timestamp (microseconds since UNIX epoch or microseconds since system boot)
micros(),
// lat Latitude in 1E7 degrees
GPS_coord[LAT],
// lon Longitude in 1E7 degrees
GPS_coord[LON],
// alt Altitude in 1E3 meters (millimeters) above MSL
GPS_altitude * 1000,
// relative_alt Altitude above ground in meters, expressed as * 1000 (millimeters)
#if defined(BARO) || defined(SONAR)
(sensors(SENSOR_SONAR) || sensors(SENSOR_BARO)) ? altitudeHoldGetEstimatedAltitude() * 10 : GPS_altitude * 1000,
#else
GPS_altitude * 1000,
#endif
// Ground X Speed (Latitude), expressed as m/s * 100
0,
// Ground Y Speed (Longitude), expressed as m/s * 100
0,
// Ground Z Speed (Altitude), expressed as m/s * 100
0,
// heading Current heading in degrees, in compass units (0..360, 0=north)
DECIDEGREES_TO_DEGREES(attitude.values.yaw)
);
msgLength = mavlink_msg_to_send_buffer(mavBuffer, &mavMsg);
mavlinkSerialWrite(mavBuffer, msgLength);
mavlink_msg_gps_global_origin_pack(0, 200, &mavMsg,
// latitude Latitude (WGS84), expressed as * 1E7
GPS_home[LAT],
// longitude Longitude (WGS84), expressed as * 1E7
GPS_home[LON],
// altitude Altitude(WGS84), expressed as * 1000
0); // FIXME
msgLength = mavlink_msg_to_send_buffer(mavBuffer, &mavMsg);
mavlinkSerialWrite(mavBuffer, msgLength);
}