// File: DoubleString[P]RtConverter/src/RtConverter/RtConverter.cpp
// Function: bamboo::RtConverter::routineObs()
void RtConverter::routineObs() {
	time_t now;
	int nbyte;
	char cmd[256];
	unsigned char buff[1024];
	list<RtConvItem> item_sd;
	sprintf(cmd, ":%d", port);
	strinit(&svr);
	stropen(&svr, STR_TCPSVR, STR_MODE_RW, cmd);
	while (true) {
		/* test for re-read configures*/
		item_sd.clear();
		def_lock(&_mutex);
		time(&now);
		list<RtConvItem>::reverse_iterator itrlist = obsqueue.rbegin();
		while (itrlist != obsqueue.rend()) {
			if (now - (*itrlist).gent >= obsdelay) {
				break;
			}
			++itrlist;
		}
		if (itrlist != obsqueue.rend()) {
			gtime_t sd_t = (*itrlist).curt;
			list<RtConvItem>::iterator itr = obsqueue.begin();
			while (itr != obsqueue.end()) {
				if ((*itr).curt.time > sd_t.time)  break;
				item_sd.push_back(*itr);
				itr = obsqueue.erase(itr);
			}
		}
		def_unlock(&_mutex);

		/// here to sending the observation 
		list<RtConvItem>::iterator itr = item_sd.begin();
		while (itr != item_sd.end()) {
			char strbuf[1024] = { 0 };
			time2str((*itr).curt, strbuf, 2);
			printf("Thread %010d,begin to sending observation %s\n", def_pthread_id_self(), strbuf);
			/// generate the buff here
			if(this->type == ConvType::obsbnc){
				memset(buff, 0, sizeof(buff));
				makeupTimeBuffer((*itr).curt, (char*)buff, nbyte);
				strwrite(&svr, buff, nbyte);
				std::map<std::string, std::map<std::string, RtSatObs> >::iterator obitr_tosend = (*itr).obslist.begin();
				while (obitr_tosend != (*itr).obslist.end()) {
					map<string, RtSatObs>::iterator satitr = (*obitr_tosend).second.begin();
					while (satitr != (*obitr_tosend).second.end()) {
						memset(buff, 0, sizeof(buff));
						makeupObsBuffer((*obitr_tosend).first.c_str(), (*satitr).first.c_str(), (*satitr).second, (char*)buff, nbyte);
						strwrite(&svr, buff, nbyte);
						++satitr;
					}
					obitr_tosend++;
				}
			}
			else{
				std::map<std::string, std::map<std::string, RtSatObs> >::iterator obitr_tosend = (*itr).obslist.begin();
				while (obitr_tosend != (*itr).obslist.end()) {
					if(rtcmexEncoder.m_encodeRtcmExMsg((*obitr_tosend).first.c_str(),(*itr).curt,(*obitr_tosend).second)){
						strwrite(&svr,(unsigned char*)rtcmexEncoder.buff,rtcmexEncoder.nbyte);
					}
					obitr_tosend++;
				}
			}
			++itr;
		}
		sleepms(NINT(1000 / Deploy::s_getSpeed()));
	}
	strclose(&svr);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xac0, %rsp            # imm = 0xAC0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa20(%rbp)
leaq -0x538(%rbp), %rdi
callq 0x54060
movq -0xa20(%rbp), %rax
movl 0x8(%rax), %edx
leaq 0x6bce1(%rip), %rsi     # 0xbdc58
xorl %eax, %eax
leaq -0x120(%rbp), %rdi
callq 0x9150
movq -0xa20(%rbp), %rdi
addq $0x10, %rdi
callq 0x9d310
jmp 0x51f97
movq -0xa20(%rbp), %rdi
addq $0x10, %rdi
movl $0x3, %edx
leaq -0x120(%rbp), %rcx
movl %edx, %esi
callq 0x9d3f0
jmp 0x51fb7
jmp 0x51fb9
jmp 0x51fbb
leaq -0x538(%rbp), %rdi
callq 0x54420
movq -0xa20(%rbp), %rdi
addq $0xa0f40, %rdi          # imm = 0xA0F40
callq 0x9ad0
leaq -0x10(%rbp), %rdi
callq 0x96e0
movq -0xa20(%rbp), %rsi
addq $0xa0ec8, %rsi          # imm = 0xA0EC8
leaq -0x550(%rbp), %rdi
callq 0x54450
movq -0xa20(%rbp), %rsi
addq $0xa0ec8, %rsi          # imm = 0xA0EC8
leaq -0x558(%rbp), %rdi
movq %rdi, -0xa30(%rbp)
callq 0x544d0
movq -0xa30(%rbp), %rsi
leaq -0x550(%rbp), %rdi
callq 0x544a0
movb %al, -0xa21(%rbp)
jmp 0x52039
movb -0xa21(%rbp), %al
testb $0x1, %al
jne 0x52045
jmp 0x520bd
movq -0x10(%rbp), %rax
movq %rax, -0xa40(%rbp)
leaq -0x550(%rbp), %rdi
callq 0x54520
movq %rax, -0xa38(%rbp)
jmp 0x52065
movq -0xa20(%rbp), %rcx
movq -0xa38(%rbp), %rdx
movq -0xa40(%rbp), %rax
subq (%rdx), %rax
movslq (%rcx), %rcx
cmpq %rcx, %rax
jl 0x520aa
jmp 0x520bd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x540(%rbp)
movl %eax, -0x544(%rbp)
leaq -0x538(%rbp), %rdi
callq 0x54100
jmp 0x52676
leaq -0x550(%rbp), %rdi
callq 0x54550
jmp 0x520b8
jmp 0x51ffd
movq -0xa20(%rbp), %rsi
addq $0xa0ec8, %rsi          # imm = 0xA0EC8
leaq -0x560(%rbp), %rdi
movq %rdi, -0xa50(%rbp)
callq 0x544d0
movq -0xa50(%rbp), %rsi
leaq -0x550(%rbp), %rdi
callq 0x544a0
movb %al, -0xa41(%rbp)
jmp 0x520f9
movb -0xa41(%rbp), %al
testb $0x1, %al
jne 0x52108
jmp 0x52218
leaq -0x550(%rbp), %rdi
callq 0x54520
movq %rax, -0xa58(%rbp)
jmp 0x5211d
movq -0xa20(%rbp), %rdi
movq -0xa58(%rbp), %rax
movq 0x8(%rax), %rcx
movq %rcx, -0x570(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x568(%rbp)
addq $0xa0ec8, %rdi          # imm = 0xA0EC8
callq 0x54210
movq %rax, -0x578(%rbp)
movq -0xa20(%rbp), %rdi
addq $0xa0ec8, %rdi          # imm = 0xA0EC8
callq 0x54270
movq %rax, -0x580(%rbp)
leaq -0x578(%rbp), %rdi
leaq -0x580(%rbp), %rsi
callq 0x54240
testb $0x1, %al
jne 0x5218a
jmp 0x52216
leaq -0x578(%rbp), %rdi
callq 0x542a0
movq 0x8(%rax), %rax
cmpq -0x570(%rbp), %rax
jle 0x521a5
jmp 0x52216
leaq -0x578(%rbp), %rdi
callq 0x542a0
movq %rax, %rsi
leaq -0x538(%rbp), %rdi
callq 0x54140
jmp 0x521c2
movq -0xa20(%rbp), %rax
addq $0xa0ec8, %rax          # imm = 0xA0EC8
movq %rax, -0xa60(%rbp)
leaq -0x590(%rbp), %rdi
leaq -0x578(%rbp), %rsi
callq 0x54350
movq -0xa60(%rbp), %rdi
movq -0x590(%rbp), %rsi
callq 0x54580
movq %rax, -0x588(%rbp)
movq -0x588(%rbp), %rax
movq %rax, -0x578(%rbp)
jmp 0x52154
jmp 0x52218
movq -0xa20(%rbp), %rdi
addq $0xa0f40, %rdi          # imm = 0xA0F40
callq 0x95a0
leaq -0x538(%rbp), %rdi
callq 0x54210
movq %rax, -0x598(%rbp)
leaq -0x538(%rbp), %rdi
callq 0x54270
movq %rax, -0x5a0(%rbp)
leaq -0x598(%rbp), %rdi
leaq -0x5a0(%rbp), %rsi
callq 0x54240
testb $0x1, %al
jne 0x5226d
jmp 0x52639
leaq -0x9a0(%rbp), %rdi
movq %rdi, -0xa68(%rbp)
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x93d0
leaq -0x598(%rbp), %rdi
callq 0x542a0
movq -0xa68(%rbp), %rsi
movups 0x8(%rax), %xmm0
movaps %xmm0, -0x9b0(%rbp)
movq -0x9b0(%rbp), %rdi
movsd -0x9a8(%rbp), %xmm0
movl $0x2, %edx
callq 0x8f550
jmp 0x522c0
callq 0x96a0
movq %rax, %rsi
leaq 0x6b98d(%rip), %rdi     # 0xbdc5c
xorl %eax, %eax
leaq -0x9a0(%rbp), %rdx
callq 0x9090
jmp 0x522df
movq -0xa20(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x524f6
leaq -0x520(%rbp), %rdi
movq %rdi, -0xa70(%rbp)
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x93d0
leaq -0x598(%rbp), %rdi
callq 0x542a0
movq -0xa20(%rbp), %rdi
movq -0xa70(%rbp), %rdx
movups 0x8(%rax), %xmm0
movaps %xmm0, -0x9c0(%rbp)
movq -0x9c0(%rbp), %rsi
movsd -0x9b8(%rbp), %xmm0
leaq -0x14(%rbp), %rcx
callq 0x529d0
jmp 0x52349
movq -0xa20(%rbp), %rdi
addq $0x10, %rdi
movl -0x14(%rbp), %edx
leaq -0x520(%rbp), %rsi
callq 0xa09c0
jmp 0x52365
leaq -0x598(%rbp), %rdi
callq 0x542a0
movq %rax, %rdi
addq $0x18, %rdi
callq 0x54390
movq %rax, -0x9c8(%rbp)
leaq -0x598(%rbp), %rdi
callq 0x542a0
movq %rax, %rdi
addq $0x18, %rdi
callq 0x4c010
movq %rax, -0x9d0(%rbp)
leaq -0x9c8(%rbp), %rdi
leaq -0x9d0(%rbp), %rsi
callq 0x543c0
testb $0x1, %al
jne 0x523bf
jmp 0x524f1
leaq -0x9c8(%rbp), %rdi
callq 0x4c060
movq %rax, %rdi
addq $0x20, %rdi
callq 0x32e20
movq %rax, -0x9d8(%rbp)
leaq -0x9c8(%rbp), %rdi
callq 0x4c060
movq %rax, %rdi
addq $0x20, %rdi
callq 0x32e80
movq %rax, -0x9e0(%rbp)
leaq -0x9d8(%rbp), %rdi
leaq -0x9e0(%rbp), %rsi
callq 0x32e50
testb $0x1, %al
jne 0x52419
jmp 0x524d7
leaq -0x520(%rbp), %rdi
movq %rdi, -0xa78(%rbp)
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x93d0
leaq -0x9c8(%rbp), %rdi
callq 0x4c060
movq %rax, %rdi
callq 0x92b0
movq %rax, -0xa88(%rbp)
leaq -0x9d8(%rbp), %rdi
movq %rdi, -0xa90(%rbp)
callq 0x32eb0
movq %rax, %rdi
callq 0x92b0
movq -0xa90(%rbp), %rdi
movq %rax, -0xa80(%rbp)
callq 0x32eb0
movq -0xa20(%rbp), %rdi
movq -0xa88(%rbp), %rsi
movq -0xa80(%rbp), %rdx
movq -0xa78(%rbp), %r8
movq %rax, %rcx
addq $0x20, %rcx
leaq -0x14(%rbp), %r9
callq 0x52a50
jmp 0x524aa
movq -0xa20(%rbp), %rdi
addq $0x10, %rdi
movl -0x14(%rbp), %edx
leaq -0x520(%rbp), %rsi
callq 0xa09c0
jmp 0x524c6
leaq -0x9d8(%rbp), %rdi
callq 0x32ee0
jmp 0x523de
leaq -0x9c8(%rbp), %rdi
xorl %esi, %esi
callq 0x545d0
movq %rax, -0x9e8(%rbp)
jmp 0x52384
jmp 0x52628
leaq -0x598(%rbp), %rdi
callq 0x542a0
movq %rax, %rdi
addq $0x18, %rdi
callq 0x54390
movq %rax, -0x9f0(%rbp)
leaq -0x598(%rbp), %rdi
callq 0x542a0
movq %rax, %rdi
addq $0x18, %rdi
callq 0x4c010
movq %rax, -0x9f8(%rbp)
leaq -0x9f0(%rbp), %rdi
leaq -0x9f8(%rbp), %rsi
callq 0x543c0
testb $0x1, %al
jne 0x52550
jmp 0x52626
movq -0xa20(%rbp), %rax
addq $0x870, %rax            # imm = 0x870
movq %rax, -0xaa8(%rbp)
leaq -0x9f0(%rbp), %rdi
movq %rdi, -0xab0(%rbp)
callq 0x4c060
movq %rax, %rdi
callq 0x92b0
movq %rax, -0xaa0(%rbp)
leaq -0x598(%rbp), %rdi
callq 0x542a0
movq -0xab0(%rbp), %rdi
movups 0x8(%rax), %xmm0
movaps %xmm0, -0xa10(%rbp)
callq 0x4c060
movq -0xaa8(%rbp), %rdi
movq -0xaa0(%rbp), %rsi
movq %rax, %rcx
addq $0x20, %rcx
movq -0xa10(%rbp), %rdx
movsd -0xa08(%rbp), %xmm0
callq 0x32430
movl %eax, -0xa94(%rbp)
jmp 0x525da
movl -0xa94(%rbp), %eax
cmpl $0x0, %eax
je 0x5260c
movq -0xa20(%rbp), %rax
movq %rax, %rdi
addq $0x10, %rdi
movq %rax, %rsi
addq $0x870, %rsi            # imm = 0x870
movl 0x1070(%rax), %edx
callq 0xa09c0
jmp 0x5260a
jmp 0x5260c
leaq -0x9f0(%rbp), %rdi
xorl %esi, %esi
callq 0x545d0
movq %rax, -0xa18(%rbp)
jmp 0x52515
jmp 0x52628
leaq -0x598(%rbp), %rdi
callq 0x542c0
jmp 0x5223e
callq 0x54660
movl %eax, -0xab4(%rbp)
jmp 0x52646
movl -0xab4(%rbp), %ecx
xorl %edx, %edx
movl $0x3e8, %eax            # imm = 0x3E8
idivl %ecx
movl %eax, %edi
callq 0x54610
movl %eax, -0xab8(%rbp)
jmp 0x52664
movl -0xab8(%rbp), %edi
callq 0x8f910
jmp 0x52671
jmp 0x51fb9
movq -0x540(%rbp), %rdi
callq 0x9d20
nopw %cs:(%rax,%rax)