/*................................................................ */ QSTATE AlarmClock_timekeeping(AlarmClock *me, QEvent const *e) { switch (e->sig) { case Q_ENTRY_SIG: SetTimer(me->hWnd__, 1, 50, 0); return 0; case Q_EXIT_SIG: KillTimer(me->hWnd__, 1); return 0; case Q_INIT_SIG: Q_INIT(&AlarmClock_mode24hr); return 0; case IDC_12H: Q_TRAN(&AlarmClock_mode12hr); return 0; case IDC_24H: Q_TRAN(&AlarmClock_mode24hr); return 0; case ALARM_SIG: ShowWindow(GetDlgItem(me->hWnd__, IDC_BELL), SW_SHOW); return 0; case IDC_ON: case IDC_OFF: QFsmDispatch((QFsm *)&me->alarm__, e); /* dispatch e to alarm*/ return 0; case TERMINATE: Q_TRAN(&AlarmClock_final); return 0; } if (e->sig >= Q_USER_SIG) { me->isHandled__ = FALSE; } return (QSTATE)&QHsm_top; }
void Test5_initial(Test5* me, QEvent const *e) { QActive_subscribe_(& me->super_, Ev2); QActive_subscribe_(& me->super_, Ev1); Q_INIT(Test5_T5S1); }
int main(void) { const char *p1 = "param"; const char *v1 = "value"; Q_INIT(session); Q_INIT(query); Q_ADD(&session, p1, v1); Q_ADD(&session, "1", "value2"); Q_ADD(&query, "param", "value"); Q_ADD(&query, "showme", "themoney"); Q_PRINT(&session); Q_PRINT(&query); Q_PURGE(&session); Q_PURGE(&query); return (0); }
void AlarmClock_initial(AlarmClock *me, QEvent const *e) { AlarmInitEvt ie; SendMessage(me->hWnd__, WM_SETICON, (WPARAM)TRUE, (LPARAM)LoadIcon(inst, MAKEINTRESOURCE(IDI_QP))); me->currentTime__ = 0; ie.hWnd = me->hWnd__; QFsmInit((QFsm *)&me->alarm__, (QEvent *)&ie); /* initial tran. */ Q_INIT(&AlarmClock_timekeeping); }
QSTATE s2( QEVENT const *e) { switch (e->sig) { case Q_ENTRY_SIG: printf("s2-ENTRY;"); return 0; case Q_EXIT_SIG: printf("s2-EXIT;"); return 0; case Q_INIT_SIG: printf("s2-INIT;");Q_INIT(s21); return 0; case C_SIG: printf("s2-C;"); Q_TRAN(s1); return 0; case F_SIG: printf("s2-F;"); Q_TRAN(s11); return 0; } return (QSTATE)s0; }
QSTATE QHsmTst::s0(QEvent const *e) { switch (e->sig) { case Q_ENTRY_SIG: printf("s0-ENTRY;"); return 0; case Q_EXIT_SIG: printf("s0-EXIT;"); return 0; case Q_INIT_SIG: printf("s0-INIT;"); Q_INIT(&QHsmTst::s1); return 0; case E_SIG: printf("s0-E;"); Q_TRAN_DYN(&QHsmTst::s211); return 0; } return (QSTATE)&QHsmTst::top; }
QSTATE QHsmTst::s2(QEvent const *e) { switch (e->sig) { case Q_ENTRY_SIG: printf("s2-ENTRY;"); return 0; case Q_EXIT_SIG: printf("s2-EXIT;"); return 0; case Q_INIT_SIG: printf("s2-INIT;"); Q_INIT(&QHsmTst::s21); return 0; case C_SIG: printf("s2-C;"); Q_TRAN_DYN(&QHsmTst::s1); return 0; case F_SIG: printf("s2-F;"); Q_TRAN_DYN(&QHsmTst::s11); return 0; } return (QSTATE)&QHsmTst::s0; }
QSTATE QHsmTst::s1(QEvent const *e) { switch (e->sig) { case Q_ENTRY_SIG: printf("s1-ENTRY;"); return 0; case Q_EXIT_SIG: printf("s1-EXIT;"); return 0; case Q_INIT_SIG: printf("s1-INIT;"); Q_INIT(&QHsmTst::s11); return 0; case A_SIG: printf("s1-A;"); Q_TRAN_DYN(&QHsmTst::s1); return 0; case B_SIG: printf("s1-B;"); Q_TRAN_DYN(&QHsmTst::s11); return 0; case C_SIG: printf("s1-C;"); Q_TRAN_DYN(&QHsmTst::s2); return 0; case D_SIG: printf("s1-D;"); Q_TRAN_DYN(&QHsmTst::s0); return 0; case F_SIG: printf("s1-F;"); Q_TRAN_DYN(&QHsmTst::s211); return 0; } return (QSTATE)&QHsmTst::s0; }
QSTATE s21(QEVENT const *e) { switch (e->sig) { case Q_ENTRY_SIG: printf("s21-ENTRY;"); return 0; case Q_EXIT_SIG: printf("s21-EXIT;"); return 0; case Q_INIT_SIG:printf("s21-INIT;");Q_INIT(s211);return 0; case B_SIG: printf("s21-C;"); Q_TRAN(s211);return 0; case H_SIG: // self transition with a guard if (!bFoo) { // test the guard condition printf("s21-H;"); bFoo = true; Q_TRAN(s21); // self transition return 0; } break; //break to return the superstate } return (QSTATE)s2; }
QSTATE QHsmTst::s21(QEvent const *e) { switch (e->sig) { case Q_ENTRY_SIG: printf("s21-ENTRY;"); return 0; case Q_EXIT_SIG: printf("s21-EXIT;"); return 0; case Q_INIT_SIG: printf("s21-INIT;"); Q_INIT(&QHsmTst::s211); return 0; case B_SIG: printf("s21-B;"); Q_TRAN_DYN(&QHsmTst::s211); return 0; case H_SIG: // self transition with a guard if (!myFoo) { // test the guard condition printf("s21-H;"); myFoo = 1; Q_TRAN_DYN(&QHsmTst::s21); // self transition return 0; } break; // break to return the superstate } return (QSTATE)&QHsmTst::s2; // return the superstate }
/*===========================================================================*/ type_flagword_type get_literal_text(FILE *fp,char *buff,char quotech) /* This function reads a quoted character string which can end with any given ascii character "quotech". It is assumed that "current_ch" contains the first character following the opening "quotech". Upon exit, "current_ch" will contain the first character following the closing "quotech" which terminated the literal text. */ { type_flagword_type answer; char *ppp,*pppovf; Boolean truncated; short hold,start_lno; char tmpmsg[30]; /*-------------------------------------------------------*/ start_lno=charinfo.current_ch_lno; Q_INIT(buff,STRING_MAXNCH); /*--------------------------------- string of text chars */ answer=CHAR_TYPE; Q_STOR_LOOP(is_not_given_quotech); if (end_of_file_reached) goto eof_pt; /*--------------------------------- null terminated */ *ppp='\0'; /*--------------------------------- truncate when identifier too long */ hold=arrow_position; if (hold>max_input_line_length) hold=max_input_line_length; TRUNCATE_LOOP(is_not_given_quotech); if (end_of_file_reached) goto eof_pt; if (truncated){ arrow_position=hold; show_wrn_on_both(E_STRINGBIG,(void *) buff,CHAR_TYPE,SERIOUS_WARN_LEV);} /*--------------------------------- skip over closing quote character */ advance_1_char(); /*-------------------------------------------------------*/ return(answer); eof_pt: sprintf(tmpmsg," (%c on line#%d)",quotech,(int) start_lno); show_err_on_both(E_UNTERMQUOTE,tmpmsg,CHAR_TYPE); return(answer); }
/*.................................................................*/ QSTATE UltimateHook_generic(UltimateHook *me, QEvent const *e) { switch (e->sig) { case Q_INIT_SIG: printf("generic:init;"); Q_INIT(&UltimateHook_specific); return 0; case A_SIG: printf("generic:A;"); return 0; case B_SIG: printf("generic:B;"); return 0; case C_SIG: printf("generic:C(reset);"); Q_TRAN(&UltimateHook_generic); return 0; case D_SIG: Q_TRAN(&UltimateHook_final); return 0; } return (QSTATE)&QHsm_top; }
QSTATE s1(QEVENT const *e) { switch (e->sig) { case Q_ENTRY_SIG: printf("s1-ENTRY;"); return 0; case Q_EXIT_SIG: printf("s1-EXIT;"); return 0; case Q_INIT_SIG: printf("s1-INIT;"); Q_INIT(s11); return 0; case A_SIG: printf("s1-A;"); Q_TRAN(s1); return 0; case B_SIG: printf("s1-B;"); Q_TRAN(s11); return 0; case C_SIG: printf("s1-C;"); Q_TRAN(s2); return 0; case D_SIG: printf("s1-D;"); Q_TRAN(s0); return 0; case F_SIG: printf("s1-F;"); Q_TRAN(s211); return 0; } return (QSTATE) s0; }
/** * @ingroup app * @brief * s0״̬��Ϣ������ * @details * @param e ���͵���״̬����Ϣ * @retval 0 ���յ���Ϣ��״̬�Ѿ�������� * @retval ������0ֵ ��Ϣ��״̬�����������ɸ�״̬���д��� * @note * @code * @endcode */ QSTATE s0(QEVENT const *e) { if (e != NULL) { switch (e->sig) { case Q_ENTRY_SIG: printf("s0-ENTRY;"); return 0;//�ô�������Ϊ����״̬����ʼ���Ľ�� case Q_EXIT_SIG: printf("s0-EXIT;"); return 0; case Q_INIT_SIG: printf("s0-INIT;"); Q_INIT(s1); return 0; case E_SIG: printf("s0-E;"); Q_TRAN(s211); return 0; } } return (QSTATE) Q_Top; }
void CParser6initial(CParser6 *me, QEvent const *e) { me->commentCtr__ = 0; me->commBlkCtr__ = 0; Q_INIT(CParser6code); /* take the default transition */ }
/*.................................................................*/ void UltimateHook_initial(UltimateHook *me, QEvent const *e) { Q_INIT(&UltimateHook_generic); }
// HSM definition --------------------------------------------------- void Calc0::initial(QEvent const *) { Q_INIT(&Calc0::calc); }
void CParser6::initial(QEvent const *) { // initial pseudostate myCommentCtr = 0; myCommBlkCtr = 0; Q_INIT(&CParser6::code); // take the default transition }
void Test1_initial(Test1* me, QEvent const *e) { QActive_subscribe_(& me->super_, Ev1); Q_INIT(Test1_S1); }
int createtree(struct fh *rootfh, int depth, int d_max, dist_func_t d_cnts, dist_func_t d_weights, int f_max, dist_func_t f_cnts, dist_func_t f_weights, int l_max, dist_func_t l_cnts, dist_func_t l_weights, dist_func_t f_sizes, int scale) { int i, num_dirs_at_root = 1, create_reported = 0, ret=-1; nameset_entry_t rootnse; struct cr_rec *cr; int rexmit_max_preserve = 0; /* * remember the distributions. */ cr_d_cnts = d_cnts; cr_d_weights = d_weights; cr_d_max = d_max; cr_f_cnts = f_cnts; cr_f_weights = f_weights; cr_f_max = f_max; cr_l_cnts = l_cnts; cr_l_weights = l_weights; cr_l_max = l_max; cr_f_sizes = f_sizes; cr_scale = scale; Q_INIT(&cr_worklist); /* * create a root name entry. */ if ((rootnse = nameset_alloc(NULL, NFDIR, 0/*never pick*/)) == NULL) { report_error(FATAL, "nameset_alloc error"); goto out; } nameset_setfh(rootnse, rootfh->data, rootfh->len); /* * set up the file contents data block. */ if ((filedata = malloc(8192)) == NULL) { report_perror(FATAL, "malloc error"); goto out; } memset(filedata, 'x', 8192); rexmit_max_preserve = rexmit_max; rexmit_max = 2; /* rexmit a few times before cancel */ /* * go! */ for (i=0 ; i<num_dirs_at_root ; i++) { cr_newdir(rootnse, depth); } /* * create everything in parallel. */ while ((cr = Q_FIRST(&cr_worklist)) != NULL) { /* * some feedback that things are moving along... */ if (created - create_reported >= 100) { printf("%d ", created); fflush(stdout); create_reported = created; } Q_REMOVE(&cr_worklist, cr, link); switch(cr->nse->type) { case NFDIR: cr_dir(cr); break; case NFREG: cr_file(cr); break; case NFLNK: cr_symlink(cr); break; default: report_error(FATAL, "bad type %d", cr->nse->type); goto out; } /* * wait for replies b/c they register new worklist items. */ if (Q_FIRST(&cr_worklist) == NULL) { op_barrier(0); } } /* * wait for everything to finish. (redundant with above loop.) */ if (op_barrier(0) < 0) { report_error(FATAL, "op_barrier error"); goto out; } ret = 0; out: rexmit_max = rexmit_max_preserve; if (filedata) { free(filedata); filedata = NULL; } return ret; }
void QHsmTst::initial(QEvent const *) { printf("top-INIT;"); myFoo = 0; // initialize extended state variable Q_INIT(&QHsmTst::s0); // initial transition }