void main( void ) { int handle; unsigned date, time; if( _dos_open( "file", O_RDWR, &handle ) != 0 ) { printf( "Unable to open file\n" ); } else { printf( "Open succeeded\n" ); _dos_getftime( handle, &date, &time ); printf( "The file was last modified on %d/%d/%d", MONTH(date), DAY(date), YEAR(date) ); printf( " at %.2d:%.2d:%.2d\n", HOUR(time), MINUTE(time), SECOND(time) ); /* set the time to 12 noon */ time = (12 << 11) + (0 << 5) + 0; _dos_setftime( handle, date, time ); _dos_getftime( handle, &date, &time ); printf( "The file was last modified on %d/%d/%d", MONTH(date), DAY(date), YEAR(date) ); printf( " at %.2d:%.2d:%.2d\n", HOUR(time), MINUTE(time), SECOND(time) ); _dos_close( handle ); } }
void smartschoolTest::testSaveUser() { y::ldap::server Server; y::ldap::account & a = Server.getAccount(UID("unitTest")); if(!a.isNew()) { CPPUNIT_ASSERT(false); } a.role(ROLE(ROLE::NONE)); a.uid(UID("unitTest")); a.gender(GENDER(GENDER::MALE)); a.street(STREET("my street")); a.houseNumber(HOUSENUMBER(42)); a.houseNumberAdd(HOUSENUMBER_ADD("a")); a.birthDay(DATE(DAY(9), MONTH(8), YEAR(1972))); a.wisaID(WISA_ID(111111111)); a.password(PASSWORD("ABcd!eGf")); a.ssPassword("ABcd!eGf"); a.cn(CN("unit")); a.sn(SN("test")); a.birthPlace(BIRTHPLACE("brussels")); a.postalCode(POSTAL_CODE("1000")); a.city(CITY("brussels")); a.country(COUNTRY("belgie")); a.mail(MAIL("*****@*****.**")); // role is not set! if(y::Smartschool().saveUser(a)) { CPPUNIT_ASSERT(false); } a.role(ROLE(ROLE::STUDENT)); if(!y::Smartschool().saveUser(a)) { CPPUNIT_ASSERT(false); } }
y::ldap::account::account(y::ldap::server * server) : server(server), // var name in ldap type and init is int? _uidNumber (TYPE_UIDNUMBER , UID_NUMBER (0 )), _uid (TYPE_UID , UID ("")), _dn ("DN" , DN ("")), _cn (TYPE_CN , CN ("")), _sn ("sn" , SN ("")), _fullName ("displayName" , FULL_NAME ("")), _homeDir ("homeDirectory" , HOMEDIR ("")), _wisaID ("wisaID" , WISA_ID (0 )), _wisaName (TYPE_WISANAME , WISA_NAME ("")), _mail ("mail" , MAIL ("")), _mailAlias ("mailAlias" , MAIL_ALIAS ("")), _birthDay ("birthday" , DATE(DAY(1), MONTH(1), YEAR(1))), _password ("gMailPassword" , PASSWORD ("")), _role ("schoolRole" , ROLE(ROLE::NONE)), _groupID ("gidNumber" , GID_NUMBER (0 )), _schoolClass ("class" , SCHOOLCLASS("")), _classChange ("classChangeDate" , DATE(DAY(1), MONTH(1), YEAR(1))), _birthPlace ("placeOfBirth" , BIRTHPLACE ("")), _gender ("gender" , GENDER(GENDER::MALE) ), _adminGroup ("adminGroupID" , ADMINGROUP (0 )), _registerID ("nationalRegisterID", REGISTER_ID("")), _nationality ("nationality" , NATION ("")), _stemID ("stemID" , STEM_ID (0 )), _schoolID ("schoolID" , SCHOOL_ID (0 )), _houseNumber ("houseNumber" , HOUSENUMBER(0 )), _houseNumberAdd("houseNumberAdd" , HOUSENUMBER_ADD("") ), _city ("location" , CITY ("")), _postalCode ("postalCode" , POSTAL_CODE("")), _street ("street" , STREET ("")), _country ("co" , COUNTRY ("")), _new(true), _hasKrbName(false), _hasSchoolPersonClass(false), _importStatus(WI_NOT_ACCOUNTED), _flaggedForRemoval(false) {}
/* 显示item 9个字节的头 uint32_t id; 单增序号 MYTIME datetime; 收到的时间 uint8_t len; 长度 第11字节是flag, 数据从第12字节开始,汉字 12x12 每行10个 ASC 0612 每行 20个 */ static void display_item( ) { char buf1[32], buf2[32]; uint8_t len; if( item_pos >= textmsg_count ) { rt_kprintf("\n%d>item_pos >= textmsg_count"); return; /*item_pos=0可以环回*/ } /*item_pos 范围[0..textmsg_count-1]*/ if( item_pos_read != item_pos ) /*有变化,要读*/ { jt808_textmsg_get( item_pos, &textmsg ); item_pos_read = item_pos; } lcd_fill( 0 ); sprintf( buf1, "[%02d] %02d/%02d/%02d %02d:%02d", item_pos + 1, YEAR( textmsg.datetime ), MONTH( textmsg.datetime ), DAY( textmsg.datetime ), HOUR( textmsg.datetime ), MINUTE( textmsg.datetime ) ); split_lines_count = 0; analy_textmsg( ); //len = my_strncpy( buf2, (char*)( textmsg.body ), 20 ); /*获取第一行*/ len = my_strncpy( buf2, (char*)( textmsg.body + split_lines[0] ), 20 ); /*获取第一行*/ if( len ) { lcd_text12( 0, 4, buf1, strlen( buf1 ), LCD_MODE_SET ); lcd_text12( 0, 16, buf2, len, LCD_MODE_SET ); } lcd_update_all( ); }
static time_t gtime ( struct tm *tm ) { register int i, sec, mins, hour, mday, mon, year; register time_t result; if ((sec = tm -> tm_sec) < 0 || sec > 59 || (mins = tm -> tm_min) < 0 || mins > 59 || (hour = tm -> tm_hour) < 0 || hour > 24 || (mday = tm -> tm_mday) < 1 || mday > 31 || (mon = tm -> tm_mon + 1) < 1 || mon > 12) return ((time_t) -1); if (hour == 24) { hour = 0; mday++; } year = YEAR (tm -> tm_year); result = 0L; for (i = 1970; i < year; i++) result += dysize (i); if (dysize (year) == 366 && mon >= 3) result++; while (--mon) result += dmsize[mon - 1]; result += mday - 1; result = 24 * result + hour; result = 60 * result + mins; result = 60 * result + sec; return result; }
void y::ldap::account::clear() { _new = true; _hasKrbName = false; _hasSchoolPersonClass = false; _uidNumber .reset(UID_NUMBER (0 )); _uid .reset(UID ("")); _dn .reset(DN ("")); _cn .reset(CN ("")); _sn .reset(SN ("")); _fullName .reset(FULL_NAME ("")); _homeDir .reset(HOMEDIR ("")); _wisaID .reset(WISA_ID (0 )); _wisaName .reset(WISA_NAME ("")); _mail .reset(MAIL ("")); _mailAlias .reset(MAIL_ALIAS ("")); _birthDay .reset(DATE(DAY(1), MONTH(1), YEAR(1))); _password .reset(PASSWORD ("")); _role .reset(ROLE(ROLE::NONE)); _groupID .reset(GID_NUMBER (0 )); _schoolClass .reset(SCHOOLCLASS("")); _birthPlace .reset(BIRTHPLACE ("")); _gender .reset(GENDER(GENDER::MALE)); _adminGroup .reset(ADMINGROUP (0 )); _registerID .reset(REGISTER_ID("")); _nationality .reset(NATION ("")); _stemID .reset(STEM_ID (0 )); _schoolID .reset(SCHOOL_ID (0 )); _street .reset(STREET ("")); _houseNumber .reset(HOUSENUMBER(0 )); _houseNumberAdd.reset(HOUSENUMBER_ADD("")); _city .reset(CITY ("")); _postalCode .reset(POSTAL_CODE("")); _country .reset(COUNTRY ("")); _ssPassword.clear(); _flaggedForRemoval = false; }
void yearbookDownload::generatePDF() { std::fstream content; content.open("yearbook_latex/content.tex", std::ios::out | std::ios::trunc); db->loadAllUsers("classgroup", true); string currentGroup; container<yearbookDB::entry> & entries = db->getEntries(); for(int i = 0; i < entries.elms(); i++) { yearbookDB::entry & currentEntry = entries[i]; if (currentGroup != currentEntry.group) { // new group currentGroup = currentEntry.group; string groupName = currentEntry.group; for (int i = 0; i < db->getReplacements().elms(); i++) { if(db->getReplacements()[i]["original"].asString() == currentEntry.group) { groupName = db->getReplacements()[i]["replacement"].asString(); } } std::string groupImage = "Pictures/chapter_head_2"; for(int i = 0; i < db->getGroupImages().elms(); i++) { if(db->getGroupImages()[i]["groupName"].asString() == currentGroup) { groupImage = "../" + db->getGroupImages()[i]["imageName"].asString().utf8(); boost::algorithm::erase_last(groupImage, ".png"); break; } } content << std::endl << "\\chapterimage{" << groupImage << "}" << std::endl; content << std::endl << "\\chapter*{" << groupName << "}" << std::endl; content << std::endl << "\\chaptermark{" << groupName << "}" << std::endl; content << std::endl << "\\addcontentsline{toc}{chapter}{" << groupName << "}" << std::endl; content << std::endl << "\\centering" << std::endl; content << "\\begin{varwidth}{\\textwidth}" << std::endl; content << "\\begin{itemize}" << std::endl; content << "\\Large" << std::endl; for (int j = i; j < db->getEntries().elms(); j++) { yearbookDB::entry & tempEntry = db->getEntries()[j]; if(currentGroup != tempEntry.group) { break; } content << "\\item " << tempEntry.name << " " << tempEntry.surname << std::endl; } content << "\\end{itemize}" << std::endl; content << "\\end{varwidth}" << std::endl; content << std::endl << "\\newpage" << std::endl; } content << std::endl << "\\section*{\\sectionformat " << currentEntry.name << " " << currentEntry.surname << "}" << std::endl; content << "\\hrule\\bigskip" << std::endl; content << std::endl << "\\centering" << std::endl; content << "\\begin{varwidth}{\\textwidth}" << std::endl; content << "\\begin{itemize}" << std::endl; DATE date = DATE(DAY(currentEntry.birthday.day()), MONTH(currentEntry.birthday.month()), YEAR(currentEntry.birthday.year())); content << std::endl << "\\bday \\Large " << date.get() << std::endl; content << "\\end{itemize}" << std::endl; content << "\\end{varwidth}" << std::endl; content << std::endl << "\\bigskip" << std::endl; std::string mail = currentEntry.mail.utf8(); std::replace(mail.begin(), mail.end(), '%', ' '); content << "\\begin{varwidth}{\\textwidth}" << std::endl; content << "\\begin{itemize}" << std::endl; content << std::endl << "\\mail \\Large \\detokenize{" << mail << "}" << std::endl; content << "\\end{itemize}" << std::endl; content << "\\end{varwidth}" << std::endl; content << std::endl << "\\bigskip" << std::endl; std::string picture; if (currentEntry.photo.size() > 0) { picture = "../" + currentEntry.photo.utf8(); boost::algorithm::replace_first(picture, "userImages", "yearbookImages"); boost::algorithm::erase_last(picture, ".png"); } else { picture = "Pictures/placeholder"; } content << std::endl << "\\includegraphics[height=7cm]{" << picture << "}" << std::endl; content << std::endl << "\\bigskip" << std::endl; content << std::endl << "\\justifying" << std::endl; content << std::endl << db->getQuestion(0) << std::endl; content << std::endl << "\\begin{exercise}" << std::endl; content << std::endl << "\\detokenize{" << currentEntry.answer1 << "}" << std::endl; content << std::endl << "\\end{exercise}" << std::endl; content << std::endl << db->getQuestion(1) << std::endl; content << std::endl << "\\begin{exercise}" << std::endl; content << std::endl << "\\detokenize{" << currentEntry.answer2 << "}" << std::endl; content << std::endl << "\\end{exercise}" << std::endl; content << std::endl << db->getQuestion(2) << std::endl; content << std::endl << "\\begin{exercise}" << std::endl; content << std::endl << "\\detokenize{" << currentEntry.answer3 << "}" << std::endl; content << std::endl << "\\end{exercise}" << std::endl; content << std::endl << db->getQuestion(3) << std::endl; content << std::endl << "\\begin{exercise}" << std::endl; content << std::endl << "\\detokenize{" << currentEntry.answer4 << "}" << std::endl; content << std::endl << "\\end{exercise}" << std::endl; content << std::endl << "\\newpage" << std::endl; } content.close(); string cmd; cmd = "export PATH=\"$PATH:/usr/sbin:/usr/bin:/sbin:/bin\"; "; cmd += "cd yearbook_latex; "; cmd += "xelatex main; cd ..;"; cmd.execute(); cmd.execute(); downloadFile->setFileName("yearbook_latex/main.pdf"); downloadFile->setMimeType("application/pdf"); downloadAnchor->setLink(Wt::WLink(downloadFile)); downloadTitle->show(); downloadContainer->show(); }
static void display( void ) { uint16_t pic_page_start; /*每四个图片记录为一个page*/ uint8_t buf[32], buf_time[16]; uint16_t i; MYTIME t; TypeDF_PackageHead * pcurrhead; lcd_fill( 0 ); switch( scr_mode ) { case SCR_PHOTO_MENU: pos &= 0x01; lcd_text12( 5, 4, "1.图片记录", 10, 3 - pos * 2 ); lcd_text12( 5, 18, "2.拍照上传", 10, pos * 2 + 1 ); break; case SCR_PHOTO_SELECT_ITEM: if( pic_count ) /*有图片*/ { if( pos >= pic_count ) { pos = 0; } if( pos < 0 ) { pos = pic_count - 1; } pic_page_start = pos & 0xFFFC; /*每4个1组*/ for( i = pic_page_start; i < pic_page_start + 4; i++ ) { if( i >= pic_count ) { break; } pcurrhead = (TypeDF_PackageHead*)( pHead + i * sizeof( TypeDF_PackageHead ) ); t = pcurrhead->Time; sprintf( buf, "%02d>%02d-%02d-%02d %02d:%02d:%02d", i+1, YEAR( t ), MONTH( t ), DAY( t ), HOUR( t ), MINUTE( t ), SEC( t )); if( i == pos ) { lcd_asc0608( 0, 8 * ( i & 0x03 ), buf, LCD_MODE_INVERT ); } else { lcd_asc0608( 0, 8 * ( i & 0x03 ), buf, LCD_MODE_SET ); } } }else /*没有图片*/ { lcd_text12( 25, 12, "没有图片记录", 12, LCD_MODE_SET ); } break; case SCR_PHOTO_SELECT_DETAILED:/*显示图片详细信息*/ pcurrhead = (TypeDF_PackageHead*)( pHead + pos * sizeof( TypeDF_PackageHead ) ); t = pcurrhead->Time; sprintf( buf, "%02d-%02d-%02d %02d:%02d:%02d", YEAR( t ), MONTH( t ), DAY( t ), HOUR( t ), MINUTE( t ), SEC( t )); lcd_asc0608( 0, 0, buf, LCD_MODE_SET ); sprintf(buf,"chn=%d trig=%d del=%d",pcurrhead->Channel_ID,pcurrhead->TiggerStyle,pcurrhead->State); lcd_asc0608( 0, 8, buf, LCD_MODE_SET ); sprintf(buf,"size=%d",pcurrhead->Len-64); lcd_asc0608( 0, 16, buf, LCD_MODE_SET ); lcd_asc0608(70,24,"usb",LCD_MODE_SET); lcd_asc0608(104,24,"rep",LCD_MODE_SET); break; case SCR_PHOTO_TAKE: lcd_text12( 20, 12, "拍照上传中...", 12, LCD_MODE_SET ); break; } lcd_update_all( ); }
void wmessage(void) { int x, y; int done = FALSE; char ch; char name[NAMELTH + 1]; int temp = (-1); int linedone, dotitles = TRUE; char line[BIGLTH]; /* what nation to send to */ clear_bottom(0); mvaddstr( LINES - 4, 0, "The Conquer Administrator is 'god'; To send to the News use 'news';"); mvaddstr(LINES - 3, 0, "Send mail to what nation? "); refresh(); temp = get_country(); if (temp == NEWSMAIL) { strcpy(name, "news"); } else { /* quick return on bad input */ if (temp == (-1) || temp >= NTOTAL || (!isntn(ntn[temp].active) && temp != 0)) { makebottom(); return; } strcpy(name, ntn[temp].name); /* find nation name */ } if (mailopen(temp) == (-1)) { makebottom(); return; } redraw = FULL; if (temp != -2) { if (country == 0) fprintf(fm, "Message to %s from GOD (%s of year %d)\n\n", name, PMONTH(TURN), YEAR(TURN)); else fprintf(fm, "Message to %s from %s (%s of year %d)\n\n", name, curntn->name, PMONTH(TURN), YEAR(TURN)); } else { char ugh[NAMELTH + 2]; /* * I'm pretty sure this memchr() is really supposed to be memset(). * Either the function has changed over the years, or it was a typo * that went undetected, and somehow didn't crash very often. * * memchr(ugh, '-', NAMELTH + 1); */ memset(ugh, '-', NAMELTH + 1); fprintf(fm, "5.%s\n", ugh); } strcpy(line, ""); while (done == FALSE) { if (dotitles == TRUE) { move(0, 0); clrtobot(); standout(); if (temp != -2) mvprintw(3, (COLS - 25) / 2, "Message to Nation %s", name); else mvaddstr(3, (COLS - 25) / 2, "Message to All Players"); mvaddstr(LINES - 2, (COLS - 37) / 2, "End with a <Control-D> on a New Line"); mvaddstr(LINES - 1, (COLS - 28) / 2, "Hit ESC to Abort the Message"); standend(); mvaddstr(5, 0, line); y = 6; x = 0; refresh(); dotitles = FALSE; } linedone = FALSE; ch = ' '; /* read line */ while (linedone == FALSE) { /* check for delete or backspace */ switch (ch) { case '\b': case '\177': /* backspace or delete */ if (x > 1) x--; mvaddch(y, x, ' '); move(y, x); line[x] = ' '; refresh(); ch = getch(); break; case '\n': case '\r': /* newline or carriage return */ linedone = TRUE; break; case '\004': /* a control-d was hit */ if (x == 1) { linedone = TRUE; done = TRUE; } else { standout(); mvaddstr(LINES - 3, (COLS - 37) / 2, "Hit [RETURN] Control-D to End Message"); standend(); move(y, x); refresh(); ch = getch(); move(LINES - 3, 0); clrtoeol(); refresh(); } break; case '\033': /* escape key was hit */ mvaddstr(LINES - 3, 0, "Abort Message? "); refresh(); if (getch() == 'y') { linedone = TRUE; done = TRUE; temp = ABORTMAIL; } else { move(LINES - 3, 0); clrtoeol(); move(y, x); refresh(); ch = getch(); } break; case '': /* new page -- end of form */ wrefresh(stdscr); ch = getch(); break; default: /* any remaining possibilities */ if (isprint(ch) && (x < (74 - NAMELTH))) { /* concatonate to end */ line[x] = ch; mvaddch(y, x, ch); x++; refresh(); } ch = getch(); break; } } if ((ch != '\n') && (ch != '\r') && (ch != '\033')) { mvaddch(y, x, ch); line[x] = ch; x++; } line[x] = '\0'; /* check for single period */ if (strcmp(line, " .") == 0) done = TRUE; /* write to file */ if (done == FALSE) { if (temp != -2) fprintf(fm, "%s\n", line); else { if (country != 0) fprintf(fm, "5.%-9s:%s\n", curntn->name, line); else fprintf(fm, "5.God :%s\n", line); } x = 0; y++; if (y == LINES - 3) { standout(); mvaddstr(LINES - 3, 0, "Continuing..."); standend(); refresh(); sleep(2); dotitles = TRUE; } } } mailclose(temp); }
/*! \param Func */ xbShort xbExpn::ProcessFunction( char * Func ) { /* 1 - pop function from stack 2 - verify function name and get no of parms needed 3 - verify no of parms >= remainder of stack 4 - pop parms off stack 5 - execute function 6 - push result back on stack */ char *buf = 0; xbExpNode *p1, *p2, *p3, *WorkNode, *FuncNode; xbShort ParmsNeeded,len; char ptype = 0; /* process type s=string, l=logical, d=double */ xbDouble DoubResult = 0; xbLong IntResult = 0; FuncNode = (xbExpNode *) Pop(); ParmsNeeded = GetFuncInfo( Func, 1 ); if( ParmsNeeded == -1 ) { return XB_INVALID_FUNCTION; } else { ParmsNeeded = 0; if( FuncNode->Sibling1 ) ParmsNeeded++; if( FuncNode->Sibling2 ) ParmsNeeded++; if( FuncNode->Sibling3 ) ParmsNeeded++; } if( ParmsNeeded > GetStackDepth()) return XB_INSUFFICIENT_PARMS; p1 = p2 = p3 = NULL; if( ParmsNeeded > 2 ) p3 = (xbExpNode *) Pop(); if( ParmsNeeded > 1 ) p2 = (xbExpNode *) Pop(); if( ParmsNeeded > 0 ) p1 = (xbExpNode *) Pop(); memset( WorkBuf, 0x00, WorkBufMaxLen+1); if( strncmp( Func, "ABS", 3 ) == 0 ) { ptype = 'd'; DoubResult = ABS( GetDoub( p1 )); } else if( strncmp( Func, "ASC", 3 ) == 0 ) { ptype = 'd'; DoubResult = ASC( p1->StringResult ); } else if( strncmp( Func, "AT", 2 ) == 0 ) { ptype = 'd'; DoubResult = AT( p1->StringResult, p2->StringResult ); } else if( strncmp( Func, "CDOW", 4 ) == 0 ) { ptype = 's'; buf = CDOW( p1->StringResult ); } else if( strncmp( Func, "CHR", 3 ) == 0 ) { ptype = 's'; buf = CHR( GetInt( p1 )); } else if( strncmp( Func, "CMONTH", 6 ) == 0 ) { ptype = 's'; buf = CMONTH( p1->StringResult ); } else if( strncmp( Func, "CTOD", 4 ) == 0 ) { ptype = 's'; buf = CTOD( p1->StringResult ); } else if( strncmp( Func, "DATE", 4 ) == 0 ) { ptype = 's'; buf = DATE(); } else if( strncmp( Func, "DAY", 3 ) == 0 ) { ptype = 'd'; DoubResult = DAY( p1->StringResult ); } else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'C' ) { ptype = 's'; buf = DESCEND( p1->StringResult.c_str() ); } else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'N' ) { ptype = 'd'; DoubResult = DESCEND( GetDoub( p1 )); } else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'D' ) { xbDate d( p1->StringResult ); ptype = 'd'; DoubResult = DESCEND( d ); } else if( strncmp( Func, "DOW", 3 ) == 0 ) { ptype = 'd'; DoubResult = DOW( p1->StringResult ); } else if( strncmp( Func, "DTOC", 4 ) == 0 ) { ptype = 's'; buf = DTOC( p1->StringResult ); } else if( strncmp( Func, "DTOS", 4 ) == 0 ) { ptype = 's'; buf = DTOS( p1->StringResult ); } else if( strncmp( Func, "EXP", 3 ) == 0 ) { ptype = 'd'; DoubResult = EXP( GetDoub( p1 )); } else if( strncmp( Func, "IIF", 3 ) == 0 ){ ptype = 's'; buf = IIF( p1->IntResult, p2->StringResult, p3->StringResult ); } else if( strncmp( Func, "INT", 3 ) == 0 ) { ptype = 'd'; DoubResult = INT( GetDoub( p1 )); } else if( strncmp( Func, "ISALPHA", 7 ) == 0 ) { ptype = 'l'; IntResult = ISALPHA( p1->StringResult ); } else if( strncmp( Func, "ISLOWER", 7 ) == 0 ) { ptype = 'l'; IntResult = ISLOWER( p1->StringResult ); } else if( strncmp( Func, "ISUPPER", 7 ) == 0 ) { ptype = 'l'; IntResult = ISUPPER( p1->StringResult ); } else if( strncmp( Func, "LEN", 3 ) == 0 ) { ptype = 'd'; DoubResult = LEN( p1->StringResult ); } else if( strncmp( Func, "LEFT", 4 ) == 0 ) { ptype = 's'; buf = LEFT( p1->StringResult, INT( p2->DoubResult )); } else if( strncmp( Func, "LTRIM", 5 ) == 0 ) { ptype = 's'; buf = LTRIM( p1->StringResult ); } else if( strncmp( Func, "LOG", 3 ) == 0 ) { ptype = 'd'; DoubResult = LOG( GetDoub( p1 )); } else if( strncmp( Func, "LOWER", 5 ) == 0 ) { ptype = 's'; buf = LOWER( p1->StringResult ); } else if( strncmp( Func, "MAX", 3 ) == 0 ) { ptype = 'd'; DoubResult = MAX( GetDoub( p1 ), GetDoub( p2 )); } else if( strncmp( Func, "MIN", 3 ) == 0 ) { ptype = 'd'; DoubResult = MIN( GetDoub( p1 ), GetDoub( p2 )); } else if( strncmp( Func, "MONTH", 5 ) == 0 ) { ptype = 'd'; DoubResult = MONTH( p1->StringResult ); } else if( strncmp( Func, "RECNO", 5 ) == 0 ) { ptype = 'd'; DoubResult = RECNO( FuncNode->dbf ); } else if( strncmp( Func, "REPLICATE", 9 ) == 0 ) { ptype = 's'; buf = REPLICATE( p1->StringResult, GetInt( p2 )); } else if( strncmp( Func, "RIGHT", 5 ) == 0 ) { ptype = 's'; buf = RIGHT( p1->StringResult, GetInt( p2 )); } else if( strncmp( Func, "RTRIM", 5 ) == 0 ) { ptype = 's'; buf = RTRIM( p1->StringResult ); } else if( strncmp( Func, "SPACE", 5 ) == 0 ) { ptype = 's'; buf = SPACE( INT( GetDoub( p1 ))); } else if( strncmp( Func, "SQRT", 4 ) == 0 ) { ptype = 'd'; DoubResult = SQRT( GetDoub( p1 )); } else if( strncmp( Func, "STRZERO", 7 ) == 0 && ParmsNeeded == 1 ) { ptype = 's'; buf = STRZERO( p1->StringResult ); } else if( strncmp( Func, "STRZERO", 7 ) == 0 && ParmsNeeded == 2 ) { ptype = 's'; buf = STRZERO( p1->StringResult, GetInt( p2 )); } else if( strncmp( Func, "STRZERO", 7 ) == 0 && ParmsNeeded == 3 ) { ptype = 's'; buf = STRZERO( p1->StringResult, GetInt( p2 ), GetInt( p3 )); } else if( strncmp( Func, "STR", 3 ) == 0 && p3 ) { ptype = 's'; if(p1->ExpressionType == 'N') buf = STR( p1->DoubResult, GetInt( p2 ), GetInt( p3 )); else buf = STR( p1->StringResult, GetInt( p2 ), GetInt( p3 )); } else if( strncmp( Func, "STR", 3 ) == 0 && p2 ) { ptype = 's'; buf = STR( p1->StringResult, GetInt( p2 )); } else if( strncmp( Func, "STR", 3 ) == 0 && p1 ) { ptype = 's'; buf = STR( p1->StringResult ); } else if( strncmp( Func, "SUBSTR", 6 ) == 0 ) { ptype = 's'; buf = SUBSTR( p1->StringResult, GetInt( p2 ), GetInt( p3 )); } else if( strncmp( Func, "TRIM", 4 ) == 0 ) { ptype = 's'; buf = TRIM( p1->StringResult ); } else if( strncmp( Func, "UPPER", 5 ) == 0 ) { ptype = 's'; buf = UPPER( p1->StringResult ); } else if( strncmp( Func, "VAL", 3 ) == 0 ) { ptype = 'd'; DoubResult = VAL( p1->StringResult ); } else if( strncmp( Func, "YEAR", 4 ) == 0 ) { ptype = 'd'; DoubResult = YEAR( p1->StringResult ); } if( p1 && !p1->InTree ) delete p1; if( p2 && !p2->InTree ) delete p2; if( p3 && !p3->InTree ) delete p3; if( !FuncNode->InTree ) delete FuncNode; if( buf ){ len = strlen( buf ); WorkNode = new xbExpNode; if( !WorkNode ) return XB_NO_MEMORY; WorkNode->ResultLen = len + 1; } else { len = 0; WorkNode = new xbExpNode; if( !WorkNode ) return XB_NO_MEMORY; WorkNode->ResultLen = 0; } switch( ptype ){ case 's': /* string or char result */ WorkNode->DataLen = len; WorkNode->ExpressionType = 'C'; WorkNode->Type = 's'; WorkNode->StringResult = buf; break; case 'd': /* numeric result */ WorkNode->DataLen = 0; WorkNode->ExpressionType = 'N'; WorkNode->Type = 'd'; WorkNode->DoubResult = DoubResult; break; case 'l': /* logical result */ WorkNode->DataLen = 0; WorkNode->ExpressionType = 'L'; WorkNode->Type = 'l'; WorkNode->IntResult = IntResult; break; default: std::cout << "\nInternal error. " << ptype; break; } Push(WorkNode); return XB_NO_ERROR; }
void power_switch(UINT32 mode) { unsigned long keycode; SYSTEM_DATA* sys_data; UINT32 vkey; UINT32 times = 0,display_type=0; date_time dt; UINT32 hh,mm,ss; char time_str[10]; struct pan_key key_struct; UINT32 timer; struct sf_panel_attr panel_attr; /*alfred.wu 1.0版本的MCU程序因为待机时间不能超过256小时*/ #ifdef MCUSTANDBY struct sf_panel_time time; date_time sRecentTime; UINT32 nDurationTime = 0; UINT32 nYear = 0; UINT32 nMonth = 0; UINT32 nDay = 0; UINT32 nHour = 0; UINT32 nMin = 0; UINT32 nSec = 0; struct sf_standby_param standby_param; /*Note: For the limited memory size of MCU, if using led panel, the maximum IR key num is 5 and for vfd panel the size is 2. */ struct sf_power_ir_key ir_key[] = \ { #ifdef RC04_A {0x007f, 0x1c}, /*RC04_A*/ #endif #ifdef RC09_A {0x00FD, 0x1A}, /*RC09_A*/ #endif #ifdef RC11_A {0x00ff, 0x54}, /*RC11_A*/ #endif #ifdef RC19_D {0x01fe, 0x00}, /*RC11_A*/ #endif #ifdef RC01_A_02 {0x807f, 0x0a}, /*RC01_A_02*/ #endif #ifdef ORDER_GZ1010001 {0x007f, 0x1c}, /*RC04_A*/ #else {0x007f, 0x0a}, /*RC01_A*/ #endif {0x01FE, 0x01}, /*REMOTE02420100*/ {0x06FB, 0x0E}, /*ALI_RCU_60_KEY*/ }; #endif sys_data = sys_data_get(); sys_data->bstandmode = 1; sys_data_save(1); system_state = SYS_STATE_POWER_OFF; /*Archer:The following process is unnessary when using mcu standby resolution.*/ #if 0 power_off_process(); power_off_process2(); #endif #ifndef MCUSTANDBY if(mode != 1) key_pan_display("off ", 4); key_pan_display_standby(1); key_pan_display_lock(0); api_standby_led_onoff(TRUE); #else #if 0 get_local_time(&dt); nDurationTime = api_get_recently_timer(); POWER_PRINTF("nDurationTime = 0x%x\n",nDurationTime); if(0 != nDurationTime) { sRecentTime.year = YEAR(nDurationTime); sRecentTime.month= MONTH(nDurationTime); sRecentTime.day= DAY(nDurationTime); sRecentTime.hour= HOUR(nDurationTime); sRecentTime.min= MIN(nDurationTime); sRecentTime.sec= SEC(nDurationTime); POWER_PRINTF("RecentTime:%d-%d-%d %d:%d:%d\n",sRecentTime.year,sRecentTime.month,\ sRecentTime.day, sRecentTime.hour,sRecentTime.min,sRecentTime.sec); get_time_offset(&dt,&sRecentTime,&nDay,&nHour,&nMin,&nSec); //standby_param.standby_time_sec = nHour*60*60+nMin*60; standby_param.standby_time_sec = 60; POWER_PRINTF("standby:hour:%d, minute:%d, total secs:%d\n",nHour,nMin, standby_param.standby_time_sec); //pan_set_standby_time((struct pan_device*)dev_get_by_id(HLD_DEV_TYPE_PAN,0),&sPanelTime); } else { POWER_PRINTF("no timer\n"); } #endif //pan_display(g_pan_dev, " ", 8);//albert.li del 2011.1.25 /*albert.li add 2011.1.25*/ get_local_time(&dt); time.hour = dt.hour; time.min= dt.min; time.sec = dt.sec; #ifndef FAKE_STANDBY sf_panel_clear(); reset_sf_panel_all_led(); /*albert.li add end*/ sf_panel_display_time(&time); sf_panel_term(); #else pan_io_control(g_pan_dev, PAN_DRIVER_GET_ATTRIBUTE, &panel_attr); if (panel_attr.type == SF_PANEL_TYPE_LED) { pan_display(g_pan_dev,"OFF ", 4); } else { pan_display(g_pan_dev,"STANDBY", 7); } #endif power_off_process(); //S5PanelStandby(g_pan_dev,(const)&sPanIRSpecialKey,2);//guop edit standby_param.ir_key_num = sizeof(ir_key)/sizeof(struct sf_power_ir_key); standby_param.ir_key_list = ir_key; standby_param.standby_time_sec = 0; #ifndef FAKE_STANDBY sf_power_down(&standby_param); #else //zhouxp fake standby { while (1) { ControlMsg_t msg; times++; times = times % 100; osal_delay(5000); vkey = V_KEY_NULL; if(key_get_key(&key_struct,0)) { keycode = scan_code_to_msg_code(&key_struct); ap_hk_to_vk(0, keycode, &vkey); } else keycode = PAN_KEY_INVALID; if(vkey == V_KEY_POWER) { power_on_process(); } ap_receive_msg( &msg, 10); libc_printf("got msg type=%d\n",msg.msgType); if(msg.msgType== CTRL_MSG_SUBTYPE_CMD_TIMER_WAKEUP) power_on_process(); } } #endif #endif #ifndef MCUSTANDBY if(1) /* Real Standby*//*alfred.wu ali的IC真待机处理流程在MCUSTANDBY后不会执行*/ { UINT32 cur_time, target_time; get_local_time(&dt); pan_close(g_pan_dev); timer = api_get_recently_timer(); // disable interrupt osal_interrupt_disable(); cur_time = (dt.sec & 0x3F ) | ((dt.min & 0x3F )<<6) | ((dt.hour & 0x1F )<<12) | ((dt.day & 0x1F)<<17) | ((dt.month & 0xF) << 22) | (((dt.year % 100) & 0x3F)<<26); sys_ic_enter_standby(timer, cur_time); // enable interrupt osal_interrupt_enable(); } while (1) { times++; times = times % 100; osal_delay(5000); if(times==0) { //get_cur_time(&hh,&mm,&ss); get_local_time(&dt); hh = dt.hour; mm = dt.min; if(display_type==0) sprintf(time_str,"%02d%02d ",hh,mm); else sprintf(time_str,"%02d.%02d",hh,mm); key_pan_display(time_str, 5); display_type++; display_type %= 2; } vkey = V_KEY_NULL; if(key_get_key(&key_struct,0)) { keycode = scan_code_to_msg_code(&key_struct); ap_hk_to_vk(0, keycode, &vkey); } else keycode = PAN_KEY_INVALID; if(vkey == V_KEY_POWER) { power_on_process(); } } #endif }