No lel bo ji mal gol ke le so da len se sang e so sal go sel
그저 모르는 사람으로 산다면
Ke jo mo le nen sa la me lo san sa myon
이런 아픔따위는 몰랐을 테니
I lon a pem d’a ui nen mol la sel tei ni
매일매일 너를 지우고 매일매일 너를 버려도
Mei il mei il no lel ji u go mei il mei il no lel bo lyo do
내맘은 이미 너를 꼭 숨긴채 놓아주질않아
Nei ma men I mi no lel g’ok sum gin che no a zhu jil a na
사랑이라 부르며
Sa lang I la bu le myo
사랑은 행복이라 믿고 있었는데
Sa lang en heing bo gi la mi go I so nen dei
말못하는 사랑은 하늘이 준 벌일뿐이야
Mal mo ta nen sa lang en ha nel I zhun bo lil b’u ni ya
너만 사랑하면 맘이 저려서
No man sa lang ha myon ma mi jo lyo so
눈물만 훔치며 살아가니까
nun mul man hum chi myo sa la ga ni g’a
머리로는 너를 잊었어 입으로도 너를 잊었어
Mo li lo nen no lel I jyo so I be lo do no lel I jyo so
가끔씩 술에 취해 내 사랑을 말해 버릴 것 같아
Ga g’em x’ik se lei chui hei nei sa lang el ma lei bo lil go ga ta
그게 겁이 날 뿐야
Ke gei go bi nal bu nya
사랑은 행복이라 믿고 있었는데
Sa lang en heing bo gi la mi go I son nen nei
말못하는 사랑은 하늘이 준 벌일뿐이야
Mal mo ta nen sa lang en ha ne li zhun bo lil bu ni ya
너만 사랑하면 맘이 저려서
No man sa lang ha myon ma mi jyo lyo so
눈물만 훔치며 살아가니까
Nun mul man hum chi myo sa la ga ni g’a
꿈에선 사랑을 할까
G’u mei son sa lang el hal g’a
울고 또 울다가 지쳐서 잠이 들어보지만
ul go d’o ul da ga ji chyo so ja mi de lo bo ji man
깨고 나면 하루가 늘 똑같은데
g’e go na myon ha lu ga nel d’o ka ten dei
널 사랑해 이렇게 사랑하고 있어
nol sa lang hei I lo kei sa lang ha go I so
니가 없는 곳에서 남 몰래 사랑을 말해와
ni ga ob nen go sei so nam mol lei sa lang el ma lei wa
혹시 니가 듣고 달아날까봐 아무도 모르게 사랑하잖아
hok xi ni ga den go da la nal g’a bwa a mu do mo le gei sa lang ha ja na
亲,罗马歌词占时无人制作哦~找不到的!!!
void* OracleProcess(GPS_DATA GpsRec) // 数据库数据处理{
interval = 0
struct HashItem* pHash
pHash = inithashtable(MAX_REC<<2)
char sql[384] = {0}
char temp[256] = {0}
char tName[10] = {0} // 表名字
int i,k
int j = TotalRec >>RATE
double distance
for(i=0i <ji++)
{
sprintf(temp,"%s%f%f%f%d",gps_last[i].tid,gps_last[i].lon,gps_last[i].lat,gps_last[i].speed,gps_last[i].udate)
InsertHash(temp, pHash, MAX_REC<<2) // 插入最后GPS信息到hash
memset(temp,0x00,256)
}
for(i = 0i <TotalReci++)
{
for(k=0k<jk++) // 查询车机是否在册
if(strcmp(GpsRec[i].tid,tid[k]) == 0)
break
if(k <j)
{
if(GpsRec[i].udate != 0.00)
{
distance = InfoUpdate(GpsRec,i)// 最新GPS数据更新
sprintf(temp,"%s%f%f%f%d",GpsRec[i].tid,GpsRec[i].lon,GpsRec[i].lat,GpsRec[i].speed,GpsRec[i].udate)
if(GetHashTablePos(temp, pHash, MAX_REC<<2) == -1) // 查找hash是否存在
{
if (distance >0.0001)
{
sprintf(tName,"GPS_%d_Y",tf[k])
InsertHash(temp, pHash, MAX_REC<<2)// 插入
sprintf(sql,"insert into %s (id,tm_id,lon,lat, speed, utc_time, udate,mileage,DIRECTION,DISTANCE) values (seq_gps.nextVal,'%s','%f','%f','%f','%d','%d','%f','%d','%f','%d')",
tName,GpsRec[i].tid,GpsRec[i].lon,GpsRec[i].lat,GpsRec[i].speed,GpsRec[i].utime,GpsRec[i].udate,GpsRec[i].mileage,GpsRec[i].dir,distance,interval)
printf("%s\n",sql)
oci_excu(oracle_env,(text *)sql,0) // 插入数据
memset(tName,0x00,10)
}
}
memset(sql,0x00,384)
memset(temp,0x00,256)
}
}
}
memset(GpsRec,0x00,sizeof(GpsRec))
free(pHash)
pthread_exit(NULL)
}
void TcpProcess(int tfd) // 处理TCP连接上的事务
{
struct timeval ntime
int index = 0,times,ret
int rlen = 0,rflag = 0
char recvbuf[513] = {0}
bzero(recvbuf,513)
while(1)
{
ret = rlen = read(tfd,recvbuf,512)
if(rlen <= 0)
break
if((rlen%32) == 0) // 32长度为标准TCP信息
{
times = 0
ret >>= 5
while(ret--)
{
if(tflag[tfd] == tfd) // 已经存在的socket
{
LOVENIX *info = (LOVENIX *)malloc(sizeof(LOVENIX))
memset(info,0x00,sizeof(LOVENIX))
if(recvbuf[times] == 0x58 || recvbuf[times] == 0x59)
ProtocolAnalysisLovenixTcp(&recvbuf[times],info)
else if(recvbuf[times] == 0x24)
ProtocolAnalysisLovenixUdp(&recvbuf[times],info)
sprintf(info->tid,"%s",seq[tfd]) // 合成车辆ID
DataProcess(info) // 处理GPS数据
free(info)
gettimeofday(&ntime, NULL)
cntime[tfd] = ntime.tv_sec // 更新时间
times += 32
}
}
}
else if(rlen >32)
{
if(!rflag)
{
if((index = RegLovenix(tfd,recvbuf)) >-1)
{
sprintf(seq[tfd],"%s",tid[index]) // 将对应的socket设备ID保存
gettimeofday(&ntime, NULL)
sfd[tfd] = tfd
cntime[tfd] = ntime.tv_sec
tflag[tfd] = tfd
rflag = 1
}
}
}
if(rlen <512) // 已经读完
break
memset(recvbuf,0x00,rlen)
}
}
void *TcpServer(void *arg)
{
int port = (unsigned int) arg
int efd,i
struct timeval ntime
int listener, nfds, n, listen_opt = 1, lisnum
struct sockaddr_in my_addr, their_addr
socklen_t len = sizeof(their_addr)
lisnum = MAXLISTEN
for(i=0i<MAX_RECi++)
{
sfd[i] = 0
tflag[i] = 0
}
if ((listener = socket(PF_INET, SOCK_STREAM, 0)) == -1) // 开启 socket 监听
{
lprintf(lfd, FATAL, "TCP Socket error!\n")
exit(1)
}
else
lprintf(lfd, INFO, "TCP socket creat susscess!\n")
setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, (void *) &listen_opt,(int) sizeof(listen_opt)) // 设置端口多重邦定
setnonblocking(listener)
bzero(&my_addr, sizeof(my_addr))
my_addr.sin_family = PF_INET
my_addr.sin_port = htons(port)
my_addr.sin_addr.s_addr = INADDR_ANY
if (bind(listener, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) == -1)
{
lprintf(lfd, FATAL, "TCP bind error!\n")
exit(1)
}
else
lprintf(lfd, INFO, "TCP bind susscess!\n")
if (listen(listener, lisnum) == -1)
{
lprintf(lfd, FATAL, "TCP listen error!\n")
exit(1)
}
else
lprintf(lfd, INFO, "TCP listen susscess!\n")
kdpfd = epoll_create(MAXEPOLLSIZE) // 创建 epoll句柄,把监听socket加入到epoll集合里
ev.events = EPOLLIN | EPOLLET // 注册epoll 事件
ev.data.fd = listener
if (epoll_ctl(kdpfd, EPOLL_CTL_ADD, listener, &ev) <0)
lprintf(lfd, FATAL, "EPOLL_CTL_ADD error!\n")
while (1)
{
sem_wait(&sem_tcp)// 等待 sem_TCP
sem_wait(&sem_tp) // 将tp值减一
nfds = epoll_wait(kdpfd, events, MAXEPOLLSIZE, 1)// 等待有事件发生
if (nfds == -1)
lprintf(lfd, FATAL,"EPOLL_WAIT error!\n")
for (n = 0n <nfds++n) // 处理epoll所有事件
{
if (events[n].data.fd == listener) // 如果是连接事件
{
if ((efd = accept(listener, (struct sockaddr *) &their_addr,&len)) <0)
{
lprintf(lfd, FATAL, "accept error!\n")
continue
}
else
lprintf(lfd, INFO, "Client from :%s\tSocket ID:%d\n", inet_ntoa(their_addr.sin_addr) ,efd)
setnonblocking(efd) // 设置新连接为非阻塞模式
ev.events = EPOLLIN | EPOLLET// 注册新连接
ev.data.fd = efd
if (epoll_ctl(kdpfd, EPOLL_CTL_ADD, efd, &ev) <0) // 将新连接加入EPOLL的监听队列
lprintf(lfd, FATAL, "EPOLL_CTL_ADD error!\n")
else
{
gettimeofday(&ntime, NULL)
cntime[efd] = ntime.tv_sec
sfd[efd] = efd
}
}
else if (events[n].events &EPOLLIN)
tpool_add_work(pool, TcpProcess, (void*)events[n].data.fd) // 读取分析TCP信息
else
{
close(events[n].data.fd)
epoll_ctl(kdpfd, EPOLL_CTL_DEL, events[n].data.fd, &ev)
}
}
sem_post(&sem_cm)
sem_post(&sem_udp)
}
close(listener)
}
int DataProcess(LOVENIX *info) // 处理GPS数据
{
if(sflag == 0 &&(CacheRec != TotalRec)) // 缓存1可用且没有满
{
gps_cache[CacheRec].lat = info->lat
gps_cache[CacheRec].mileage = info->mileage
gps_cache[CacheRec].lon = info->lon
gps_cache[CacheRec].speed = atod(info->speed, strlen(info->speed))*0.514444444*3.6
gps_cache[CacheRec].udate = atoi(info->udate)
gps_cache[CacheRec].utime = atoi(info->utime)
gps_cache[CacheRec].dir = atoi(info->dir)
sprintf(gps_cache[CacheRec].tid ,"%s",info->tid)
CacheRec++
// printf("CacheRec %d\tTotalRec %d \t sflag:%d\n",CacheRec,TotalRec,sflag)
if(CacheRec == TotalRec)
{
sflag = 1
pthread_attr_init(&attr) // 初始化属性值,均设为默认值
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)// 设置线程为分离属性
if (pthread_create(&thread, &attr,(void*) OracleProcess,(void*)gps_cache)) // 创建数据处理线程
lprintf(lfd, FATAL, "oracle pthread_creat error!\n")
CacheRec = 0
}
}
else if(sflag == 1 &&(Cache1Rec != TotalRec)) // 缓存2可用且没有满
{
gps_cache1[Cache1Rec].mileage = info->mileage
gps_cache1[Cache1Rec].lat = info->lat
gps_cache1[Cache1Rec].lon = info->lon
gps_cache1[Cache1Rec].speed = atod(info->speed, strlen(info->speed))*0.514444444*3.6
gps_cache1[Cache1Rec].udate = atoi(info->udate)
gps_cache1[Cache1Rec].utime = atoi(info->utime)
gps_cache1[Cache1Rec].dir = atoi(info->dir)
sprintf(gps_cache1[Cache1Rec].tid ,"%s",info->tid)
Cache1Rec++
if(Cache1Rec == TotalRec)
{
sflag = 0
pthread_attr_init(&attr) // 初始化属性值,均设为默认值
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)// 设置线程为分离属性
if (pthread_create(&thread, &attr,(void*) OracleProcess,(void*)gps_cache1)) // 创建数据处理线程
lprintf(lfd, FATAL, "oracle pthread_creat error!\n")
Cache1Rec = 0
}
}
else
{
lprintf(lfd, FATAL, "No cache to use!\n")
return (0)
}
return (1)
}
。。你子线程控制同步了么? 断错误一般是内存操作出错 和oci 或者pthread的关系不大!
void* OracleProcess(GPS_DATA GpsRec) // 数据库数据处理
{
interval = 0
struct HashItem* pHash
pHash = inithashtable(MAX_REC<<2)
char sql[384] = {0}
char temp[256] = {0}
char tName[10] = {0} // 表名字
int i,k
int j = TotalRec >>RATE
double distance
for(i=0i <ji++)
{
sprintf(temp,"%s%f%f%f%d",gps_last[i].tid,gps_last[i].lon,gps_last[i].lat,gps_last[i].speed,gps_last[i].udate)
InsertHash(temp, pHash, MAX_REC<<2) // 插入最后GPS信息到hash
memset(temp,0x00,256)
}
for(i = 0i <TotalReci++)
{
for(k=0k<jk++) // 查询车机是否在册
if(strcmp(GpsRec[i].tid,tid[k]) == 0)
break
if(k <j)
{
if(GpsRec[i].udate != 0.00)
{
distance = InfoUpdate(GpsRec,i)// 最新GPS数据更新
sprintf(temp,"%s%f%f%f%d",GpsRec[i].tid,GpsRec[i].lon,GpsRec[i].lat,GpsRec[i].speed,GpsRec[i].udate)
if(GetHashTablePos(temp, pHash, MAX_REC<<2) == -1) // 查找hash是否存在
{
if (distance >0.0001)
{
sprintf(tName,"GPS_%d_Y",tf[k])
InsertHash(temp, pHash, MAX_REC<<2)// 插入
sprintf(sql,"insert into %s (id,tm_id,lon,lat, speed, utc_time, udate,mileage,DIRECTION,DISTANCE) values (seq_gps.nextVal,'%s','%f','%f','%f','%d','%d','%f','%d','%f','%d')",
tName,GpsRec[i].tid,GpsRec[i].lon,GpsRec[i].lat,GpsRec[i].speed,GpsRec[i].utime,GpsRec[i].udate,GpsRec[i].mileage,GpsRec[i].dir,distance,interval)
printf("%s\n",sql)
oci_excu(oracle_env,(text *)sql,0) // 插入数据
memset(tName,0x00,10)
}
}
memset(sql,0x00,384)
memset(temp,0x00,256)
}
}
}
memset(GpsRec,0x00,sizeof(GpsRec))
free(pHash)
pthread_exit(NULL)
}
void TcpProcess(int tfd) // 处理TCP连接上的事务
{
struct timeval ntime
int index = 0,times,ret
int rlen = 0,rflag = 0
char recvbuf[513] = {0}
bzero(recvbuf,513)
while(1)
{
ret = rlen = read(tfd,recvbuf,512)
if(rlen <= 0)
break
if((rlen%32) == 0) // 32长度为标准TCP信息
{
times = 0
ret >>= 5
while(ret--)
{
if(tflag[tfd] == tfd) // 已经存在的socket
{
LOVENIX *info = (LOVENIX *)malloc(sizeof(LOVENIX))
memset(info,0x00,sizeof(LOVENIX))
if(recvbuf[times] == 0x58 || recvbuf[times] == 0x59)
ProtocolAnalysisLovenixTcp(&recvbuf[times],info)
else if(recvbuf[times] == 0x24)
ProtocolAnalysisLovenixUdp(&recvbuf[times],info)
sprintf(info->tid,"%s",seq[tfd]) // 合成车辆ID
DataProcess(info) // 处理GPS数据
free(info)
gettimeofday(&ntime, NULL)
cntime[tfd] = ntime.tv_sec // 更新时间
times += 32
}
}
}
else if(rlen >32)
{
if(!rflag)
{
if((index = RegLovenix(tfd,recvbuf)) >-1)
{
sprintf(seq[tfd],"%s",tid[index]) // 将对应的socket设备ID保存
gettimeofday(&ntime, NULL)
sfd[tfd] = tfd
cntime[tfd] = ntime.tv_sec
tflag[tfd] = tfd
rflag = 1
}
}
}
if(rlen <512) // 已经读完
break
memset(recvbuf,0x00,rlen)
}
}
void *TcpServer(void *arg)
{
int port = (unsigned int) arg
int efd,i
struct timeval ntime
int listener, nfds, n, listen_opt = 1, lisnum
struct sockaddr_in my_addr, their_addr
socklen_t len = sizeof(their_addr)
lisnum = MAXLISTEN
for(i=0i<MAX_RECi++)
{
sfd[i] = 0
tflag[i] = 0
}
if ((listener = socket(PF_INET, SOCK_STREAM, 0)) == -1) // 开启 socket 监听
{
lprintf(lfd, FATAL, "TCP Socket error!\n")
exit(1)
}
else
lprintf(lfd, INFO, "TCP socket creat susscess!\n")
setsockopt(listener, SOL_SOCKET, SO_REUSEADDR, (void *) &listen_opt,(int) sizeof(listen_opt)) // 设置端口多重邦定
setnonblocking(listener)
bzero(&my_addr, sizeof(my_addr))
my_addr.sin_family = PF_INET
my_addr.sin_port = htons(port)
my_addr.sin_addr.s_addr = INADDR_ANY
if (bind(listener, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) == -1)
{
lprintf(lfd, FATAL, "TCP bind error!\n")
exit(1)
}
else
lprintf(lfd, INFO, "TCP bind susscess!\n")
if (listen(listener, lisnum) == -1)
{
lprintf(lfd, FATAL, "TCP listen error!\n")
exit(1)
}
else
lprintf(lfd, INFO, "TCP listen susscess!\n")
kdpfd = epoll_create(MAXEPOLLSIZE) // 创建 epoll句柄,把监听socket加入到epoll集合里
ev.events = EPOLLIN | EPOLLET // 注册epoll 事件
ev.data.fd = listener
if (epoll_ctl(kdpfd, EPOLL_CTL_ADD, listener, &ev) <0)
lprintf(lfd, FATAL, "EPOLL_CTL_ADD error!\n")
while (1)
{
sem_wait(&sem_tcp)// 等待 sem_TCP
sem_wait(&sem_tp) // 将tp值减一
nfds = epoll_wait(kdpfd, events, MAXEPOLLSIZE, 1)// 等待有事件发生
if (nfds == -1)
lprintf(lfd, FATAL,"EPOLL_WAIT error!\n")
for (n = 0n <nfds++n) // 处理epoll所有事件
{
if (events[n].data.fd == listener) // 如果是连接事件
{
if ((efd = accept(listener, (struct sockaddr *) &their_addr,&len)) <0)
{
lprintf(lfd, FATAL, "accept error!\n")
continue
}
else
lprintf(lfd, INFO, "Client from :%s\tSocket ID:%d\n", inet_ntoa(their_addr.sin_addr) ,efd)
setnonblocking(efd) // 设置新连接为非阻塞模式
ev.events = EPOLLIN | EPOLLET// 注册新连接
ev.data.fd = efd
if (epoll_ctl(kdpfd, EPOLL_CTL_ADD, efd, &ev) <0) // 将新连接加入EPOLL的监听队列
lprintf(lfd, FATAL, "EPOLL_CTL_ADD error!\n")
else
{
gettimeofday(&ntime, NULL)
cntime[efd] = ntime.tv_sec
sfd[efd] = efd
}
}
else if (events[n].events &EPOLLIN)
tpool_add_work(pool, TcpProcess, (void*)events[n].data.fd) // 读取分析TCP信息
else
{
close(events[n].data.fd)
epoll_ctl(kdpfd, EPOLL_CTL_DEL, events[n].data.fd, &ev)
}
}
sem_post(&sem_cm)
sem_post(&sem_udp)
}
close(listener)
}
int DataProcess(LOVENIX *info) // 处理GPS数据
{
if(sflag == 0 &&(CacheRec != TotalRec)) // 缓存1可用且没有满
{
gps_cache[CacheRec].lat = info->lat
gps_cache[CacheRec].mileage = info->mileage
gps_cache[CacheRec].lon = info->lon
gps_cache[CacheRec].speed = atod(info->speed, strlen(info->speed))*0.514444444*3.6
gps_cache[CacheRec].udate = atoi(info->udate)
gps_cache[CacheRec].utime = atoi(info->utime)
gps_cache[CacheRec].dir = atoi(info->dir)
sprintf(gps_cache[CacheRec].tid ,"%s",info->tid)
CacheRec++
// printf("CacheRec %d\tTotalRec %d \t sflag:%d\n",CacheRec,TotalRec,sflag)
if(CacheRec == TotalRec)
{
sflag = 1
pthread_attr_init(&attr) // 初始化属性值,均设为默认值
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)// 设置线程为分离属性
if (pthread_create(&thread, &attr,(void*) OracleProcess,(void*)gps_cache)) // 创建数据处理线程
lprintf(lfd, FATAL, "oracle pthread_creat error!\n")
CacheRec = 0
}
}
else if(sflag == 1 &&(Cache1Rec != TotalRec)) // 缓存2可用且没有满
{
gps_cache1[Cache1Rec].mileage = info->mileage
gps_cache1[Cache1Rec].lat = info->lat
gps_cache1[Cache1Rec].lon = info->lon
gps_cache1[Cache1Rec].speed = atod(info->speed, strlen(info->speed))*0.514444444*3.6
gps_cache1[Cache1Rec].udate = atoi(info->udate)
gps_cache1[Cache1Rec].utime = atoi(info->utime)
gps_cache1[Cache1Rec].dir = atoi(info->dir)
sprintf(gps_cache1[Cache1Rec].tid ,"%s",info->tid)
Cache1Rec++
if(Cache1Rec == TotalRec)
{
sflag = 0
pthread_attr_init(&attr) // 初始化属性值,均设为默认值
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM)
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)// 设置线程为分离属性
if (pthread_create(&thread, &attr,(void*) OracleProcess,(void*)gps_cache1)) // 创建数据处理线程
lprintf(lfd, FATAL, "oracle pthread_creat error!\n")
Cache1Rec = 0
}
}
else
{
lprintf(lfd, FATAL, "No cache to use!\n")
return (0)
}
return (1)
}
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)