/******************************************************************** * sendPacketToVfd: * * determines what packet string to send to the VFD and sends it * ********************************************************************/ int sendPacketToVfd() { static char messageToVfd[MSG_SIZE]; int strlength = 0; // save off flag and clear frequency and state flags LOCK(&flagMutex); int flag = update.updateFlag; CLRFLAG(update.updateFlag, UPDATE_FREQ_STATE); UNLOCK(&flagMutex); //send message based on current flags and remove UPDATE FLOW flag switch(flag & ~UPDATE_FLOW) { case UPDATE_FREQ: strlength = sprintf(messageToVfd, "<H=%.1f>\n", update.frequency); break; case UPDATE_STATE: strlength = sprintf(messageToVfd, "<S=%d>\n", update.VFDState); break; case UPDATE_FREQ_STATE: strlength = sprintf(messageToVfd, "<H=%.1f,S=%d>\n",update.frequency, update.VFDState); break; default: strlength = sprintf(messageToVfd, "%s\n", DATAREQUEST); break; } // Clear flags for updating the frequency and state printf("\nPi-->VFD: %s", messageToVfd); write(serialFd, messageToVfd, strlength); return 1; }
offs_t SE3208_Dasm(char *Buffer, offs_t PC, const UINT8 *oprom, const UINT8 *opram) { UINT16 Opcode; CLRFLAG(FLAG_E); Context.ER=0; Context.PC=PC; Opcode=oprom[0] | (oprom[1] << 8); return 2 | ((*DecodeOp(Opcode))(Opcode,Buffer)) | DASMFLAG_SUPPORTED; }
/******************************************************************** * updateFlowRate: * * determines whether to change the frequency on the VFD to * * match the desired flow rate * ********************************************************************/ void updateFlowRate() { float prevFreq = update.frequency; // Save the previous frequency // Save off desired flow in case server updates while in this function // If this happens, it will be updated on the next pass float currentDesiredFlow = update.desiredFlowRate; // If desired flow was updated via server // start with frequency based on lookup table if(CHKFLAG(update.updateFlag, UPDATE_FLOW)) { //TODO: Change/update LUT for how frequency is first determined update.frequency = currentDesiredFlow*(60/3.5); //TEMPORARY printf("Update Flow set, flow: %f, freq: %f\n", currentDesiredFlow, update.frequency); // clear update flow flag LOCK(&flagMutex); CLRFLAG(update.updateFlag, UPDATE_FLOW); UNLOCK(&flagMutex); } else //adjust flow rate based on how off it is from actual { // float difference = 0; // difference = data.flowRate - currentDesiredFlow; // if (difference > FLOW_THRESH || difference < -FLOW_THRESH) // { // //TODO: Change how frequency is calculated // update.frequency -= (difference*10); //TEMPORARY // if (update.frequency > MAX_FREQ) // { // update.frequency = MAX_FREQ; // printf("frequency calculated above %d\n", MAX_FREQ); // } // else if (update.frequency < MIN_FREQ) // { // update.frequency = MIN_FREQ; // printf("frequency calculated below %d\n", MIN_FREQ); // } // } } // update flag if frequency changed if (prevFreq != update.frequency) { LOCK(&flagMutex); SETFLAG(update.updateFlag, UPDATE_FREQ); UNLOCK(&flagMutex); } }
/* Try to solve in solve_nr_remaining half-moves. * @param si slice index * @note assigns solve_result the length of solution found and written, i.e.: * previous_move_is_illegal the move just played is illegal * this_move_is_illegal the move being played is illegal * immobility_on_next_move the moves just played led to an * unintended immobility on the next move * <=n+1 length of shortest solution found (n+1 only if in next * branch) * n+2 no solution found in this branch * n+3 no solution found in next branch * (with n denominating solve_nr_remaining) */ void doublemate_filter_solve(slice_index si) { TraceFunctionEntry(__func__); TraceFunctionParam("%u",si); TraceFunctionParamListEnd(); if (conditional_pipe_solve_delegate(si)==previous_move_has_not_solved) SETFLAG(goal_preprequisites_met[nbply],goal_doublemate); pipe_solve_delegate(si); CLRFLAG(goal_preprequisites_met[nbply],goal_doublemate); TraceFunctionExit(__func__); TraceFunctionResultEnd(); }
void applyclientparamcontrols3(NCDAPCOMMON* dapcomm) { /* clear the flags */ CLRFLAG(dapcomm->controls,NCF_CACHE); CLRFLAG(dapcomm->controls,NCF_SHOWFETCH); CLRFLAG(dapcomm->controls,NCF_NC3); CLRFLAG(dapcomm->controls,NCF_NCDAP); CLRFLAG(dapcomm->controls,NCF_PREFETCH); CLRFLAG(dapcomm->controls,NCF_PREFETCH_EAGER); /* Turn on any default on flags */ SETFLAG(dapcomm->controls,DFALT_ON_FLAGS); SETFLAG(dapcomm->controls,(NCF_NC3|NCF_NCDAP)); /* enable/disable caching */ if(paramcheck34(dapcomm,"cache",NULL)) SETFLAG(dapcomm->controls,NCF_CACHE); else if(paramcheck34(dapcomm,"nocache",NULL)) CLRFLAG(dapcomm->controls,NCF_CACHE); /* enable/disable cache prefetch and lazy vs eager*/ if(paramcheck34(dapcomm,"prefetch","eager")) { SETFLAG(dapcomm->controls,NCF_PREFETCH); SETFLAG(dapcomm->controls,NCF_PREFETCH_EAGER); } else if(paramcheck34(dapcomm,"prefetch","lazy") || paramcheck34(dapcomm,"prefetch",NULL)) { SETFLAG(dapcomm->controls,NCF_PREFETCH); CLRFLAG(dapcomm->controls,NCF_PREFETCH_EAGER); } else if(paramcheck34(dapcomm,"noprefetch",NULL)) CLRFLAG(dapcomm->controls,NCF_PREFETCH); if(FLAGSET(dapcomm->controls,NCF_UNCONSTRAINABLE)) SETFLAG(dapcomm->controls,NCF_CACHE); if(paramcheck34(dapcomm,"show","fetch")) SETFLAG(dapcomm->controls,NCF_SHOWFETCH); nclog(NCLOGNOTE,"Caching=%d",FLAGSET(dapcomm->controls,NCF_CACHE)); }
static char *ParsePieceWalkAndSquares(char *tok, Flags Spec, piece_addition_type type) { unsigned int nr_walks_parsed = 0; TraceFunctionEntry(__func__); TraceFunctionParam("%s",tok); TraceFunctionParamListEnd(); while (true) { piece_walk_type walk; char * const save_tok = tok; tok = ParsePieceWalk(tok,&walk); if (walk>=King) { piece_addition_settings settings = { walk, Spec, type}; ++nr_walks_parsed; if (tok[0]==0) { /* the next token must be a valid square list, e.g. B a1b2 */ char * const squares_tok = ReadNextTokStr(); tok = ParseSquareList(squares_tok,&HandleAddedPiece,&settings); if (tok==squares_tok) output_plaintext_input_error_message(MissngSquareList,0); else if (*tok!=0) output_plaintext_error_message(WrongSquareList); } else { /* the remainder of the token may be * * a valid square list, e.g. Ba1b2 * * the remainder of a different word e.g. Black */ if (*ParseSquareList(tok,&HandleAddedPiece,&settings)!=0) { tok = save_tok; break; } } tok = ReadNextTokStr(); /* undocumented feature: "royal" only applies to the immediately next * piece indication because there can be at most 1 royal piece per side */ CLRFLAG(Spec,Royal); } else { if (nr_walks_parsed==0) { output_plaintext_input_error_message(WrongPieceName,0); tok = ReadNextTokStr(); } else tok = save_tok; break; } } TraceFunctionExit(__func__); TraceFunctionResult("%s",tok); TraceFunctionResultEnd(); return tok; }