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 MissionEngineThink(struct MissionEngine* _Engine, lua_State* _State, const struct RBTree* _BigGuys) { MissionCompare(_BigGuys->Table, &_Engine->MissionsTrigger); if(MONTH(g_GameWorld.Date) == MARCH) RBMissionOnEvent(_Engine, MEVENT_SPRING, _BigGuys->Table); else if(MONTH(g_GameWorld.Date) == SEPTEMBER) RBMissionOnEvent(_Engine,MEVENT_SPRING, _BigGuys->Table); }
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( ); }
/** * \brief Process a time-stamp. * \return None. * \param uint8_t * pbTimestamp, pointer to time-stamp as an array of bytes. * \author gjones * * \details * The conversion is mildly interesting, printing it is trivial. *--------------------------------------------------------------------------*/ void process_timestamp(uint8_t * pbTimestamp) { #define UNIX_EPOCH_OFFSET (946684800000ULL) // EasyParse time-stamps share the Unix time origin, 1970/01/01 00:00:00. // RBR's date/time conversion routines start from 2000/01/01 00:00:00, so // an offset is needed to use them. If you are using another date/time // convention, different adjustments may be needed. static const char * aszMonthNames[12] = { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" }; #define MONTH(x) (aszMonthNames[10*(((char *)(x))[0]-'0')+(((char *)(x))[1]-'0')-1]) // Convert month from a 2-digit substring to a name, eg. "04" to "Apr". uint64_t uuTimestamp; uint16_t uMilliseconds; uint32_t ulSeconds; char acDateTimeString[32]; // Adjust offset, separate seconds and milliseconds. uuTimestamp = byte_array_to_longlong(pbTimestamp) - UNIX_EPOCH_OFFSET; uMilliseconds = (uint16_t)(uuTimestamp%1000LL); ulSeconds = (uint32_t)(uuTimestamp/1000LL); // Basic seconds to date/time conversion, the tricky part. dtm_date_from_days(&acDateTimeString[0], (uint16_t)(ulSeconds/86400L)); dtm_time_from_secs(&acDateTimeString[6], ulSeconds%86400L); // Prettify the output format while writing: // YYMMDDhhmmss -> 20YY-Mon-DD hh:mm:ss.ttt printf("20%.2s-%s-%.2s %.2s:%.2s:%.2s.%03d", &acDateTimeString[0], MONTH(&acDateTimeString[2]), &acDateTimeString[4], &acDateTimeString[6], &acDateTimeString[8], &acDateTimeString[10], uMilliseconds); } // process_timestamp()
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( ); }
/*! \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; }
double VTIM_parse(const char *p) { double t; int month = 0, year = 0, weekday = -1, mday = 0; int hour = 0, min = 0, sec = 0; int d, leap; while (*p == ' ') p++; if (*p >= '0' && *p <= '9') { /* ISO8601 -- "1994-11-06T08:49:37" */ DIGIT(1000, year); DIGIT(100, year); DIGIT(10, year); DIGIT(1, year); MUSTBE('-'); DIGIT(10, month); DIGIT(1, month); MUSTBE('-'); DIGIT(10, mday); DIGIT(1, mday); MUSTBE('T'); TIMESTAMP(); } else { WEEKDAY(); assert(weekday >= 0 && weekday <= 6); if (*p == ',') { /* RFC822 & RFC1123 - "Sun, 06 Nov 1994 08:49:37 GMT" */ p++; MUSTBE(' '); DIGIT(10, mday); DIGIT(1, mday); MUSTBE(' '); MONTH(); MUSTBE(' '); DIGIT(1000, year); DIGIT(100, year); DIGIT(10, year); DIGIT(1, year); MUSTBE(' '); TIMESTAMP(); MUSTBE(' '); MUSTBE('G'); MUSTBE('M'); MUSTBE('T'); } else if (*p == ' ') { /* ANSI-C asctime() -- "Sun Nov 6 08:49:37 1994" */ p++; MONTH(); MUSTBE(' '); if (*p != ' ') DIGIT(10, mday); else p++; DIGIT(1, mday); MUSTBE(' '); TIMESTAMP(); MUSTBE(' '); DIGIT(1000, year); DIGIT(100, year); DIGIT(10, year); DIGIT(1, year); } else if (!memcmp(p, more_weekday[weekday], strlen(more_weekday[weekday]))) { /* RFC850 -- "Sunday, 06-Nov-94 08:49:37 GMT" */ p += strlen(more_weekday[weekday]); MUSTBE(','); MUSTBE(' '); DIGIT(10, mday); DIGIT(1, mday); MUSTBE('-'); MONTH(); MUSTBE('-'); DIGIT(10, year); DIGIT(1, year); year += 1900; if (year < 1969) year += 100; MUSTBE(' '); TIMESTAMP(); MUSTBE(' '); MUSTBE('G'); MUSTBE('M'); MUSTBE('T'); } else FAIL(); } while (*p == ' ') p++; if (*p != '\0') FAIL(); if (sec < 0 || sec > 60) /* Leapseconds! */ FAIL(); if (min < 0 || min > 59) FAIL(); if (hour < 0 || hour > 23) FAIL(); if (month < 1 || month > 12) FAIL(); if (mday < 1 || mday > days_in_month[month - 1]) FAIL(); if (year < 1899) FAIL(); leap = ((year) % 4) == 0 && (((year) % 100) != 0 || ((year) % 400) == 0); if (month == 2 && mday > 28 && !leap) FAIL(); if (sec == 60) /* Ignore Leapseconds */ sec--; t = ((hour * 60.) + min) * 60. + sec; d = (mday - 1) + days_before_month[month - 1]; if (month > 2 && leap) d++; d += (year % 100) * 365; /* There are 365 days in a year */ if ((year % 100) > 0) /* And a leap day every four years */ d += (((year % 100) - 1) / 4); d += ((year / 100) - 20) * /* Days relative to y2000 */ (100 * 365 + 24); /* 24 leapdays per year in a century */ d += ((year - 1) / 400) - 4; /* And one more every 400 years */ /* * Now check weekday, if we have one. * 6 is because 2000-01-01 was a saturday. * 10000 is to make sure the modulus argument is always positive */ if (weekday != -1 && (d + 6 + 7 * 10000) % 7 != weekday) FAIL(); t += d * 86400.; t += 10957. * 86400.; /* 10957 days frm UNIX epoch to y2000 */ return (t); }
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 }