Exemplo n.º 1
0
/* Function Definitions */
void b_asin(const emlrtStack *sp, real_T x[2])
{
  boolean_T p;
  int32_T k;
  emlrtStack st;
  emlrtStack b_st;
  st.prev = sp;
  st.tls = sp->tls;
  b_st.prev = &st;
  b_st.tls = st.tls;
  p = false;
  for (k = 0; k < 2; k++) {
    if (p || ((x[k] < -1.0) || (x[k] > 1.0))) {
      p = true;
    } else {
      p = false;
    }
  }

  if (p) {
    st.site = &rb_emlrtRSI;
    b_st.site = &rb_emlrtRSI;
    e_error(&b_st);
  }

  for (k = 0; k < 2; k++) {
    x[k] = muDoubleScalarAsin(x[k]);
  }
}
Exemplo n.º 2
0
/**
 * @brief  收到服务端发送过来的数据
 * @param  base 数据的基址
 * @param  len  数据的长度
 * @return void
 */
static void deal_net_data(const void *base, size_t len) /* base 内存需管理 */
{
    net_notify_t *nty = NULL;
    n_login_res_t *login_res = NULL;
    n_register_res_t *reg_res = NULL;
    n_send_msg_res_t *snd_msg_res = NULL;
    int idx = -1;/* 会话id, 用于标识请求, 控制请求的生命周期, 清理资源等 */

    nty = (net_notify_t *)base;
    if (NULL == nty)
    {
        e_debug("deal_net_data", "data transfered from server is empty!");
    }

    idx = nty->idx;
    validate_dlg(idx);
    switch (nty->cmd)
    {
        case EV_LOGIN:
            login_res = nty->nty;
            
            e_debug("deal_net_data",
                    "transfered from server success, type[%s] result[%d]",
                    "EV_LOGIN", login_res->result);
            break;
            
        case EV_REGISTER:
            reg_res = nty->nty;

            e_debug("deal_net_data",
                    "transfered from server success, type[%s] result[%d]",
                    "EV_REGISTER", reg_res->result);
            break;

        case EV_SEND_MSG:
            snd_msg_res = nty->nty;
            
            e_debug("deal_net_data",
                    "transfered from server success, type[%s] result[%d]",
                    "EV_SEND_MSG", snd_msg_res->result);
            break;
            
        default:
            e_error("deal_net_data", "unknown data type!");
            
            break;
    }
        
    e_debug("deal_net_data", "received data from server, dialog id[%d]", idx);

    dlg[idx].ack = nty;
    dlg[idx].result = DLG_RES_ACK;
    deal_dialog(idx); /* 到服务端的请求结束, 在客户端处理与UI交付及资源的清理 */
}
Exemplo n.º 3
0
int main(int argc,char* argv[]){
	int sfd,port;
	struct sockaddr_in addr;
	bzero((struct sockaddr_in*)&addr,sizeof(addr));

	port = atoi(argv[1]);

	sfd = socket(AF_INET,SOCK_STREAM,0);
	if(sfd < 0){
		e_error("socket() error");
	}

	addr.sin_family = AF_INET;
	addr.sin_addr.s_addr = htons(INADDR_ANY);
	addr.sin_port = htons(port);

	int x = connect(sfd,(struct sockaddr*)&addr,sizeof(addr));

	if(x < 0){
		e_error("connect() error");
	}
	printf("Connected..\n");
	read(sfd,&port,SIZE);

	close(sfd);

	sfd = socket(AF_INET,SOCK_STREAM,0);

	addr.sin_port = htons(port);
	x = connect(sfd,(struct sockaddr*)&addr,sizeof(addr));

	if(x<0){
		e_error("connect() error");
	}

	char msg[] = "train reached....";
	write(sfd,msg,SIZE);
	sleep(1);
	write(sfd,"exit",SIZE);
	close(sfd);
}
Exemplo n.º 4
0
void c_asin(const emlrtStack *sp, real_T *x)
{
  emlrtStack st;
  emlrtStack b_st;
  st.prev = sp;
  st.tls = sp->tls;
  b_st.prev = &st;
  b_st.tls = st.tls;
  if ((*x < -1.0) || (*x > 1.0)) {
    st.site = &rb_emlrtRSI;
    b_st.site = &rb_emlrtRSI;
    e_error(&b_st);
  }

  *x = muDoubleScalarAsin(*x);
}
Exemplo n.º 5
0
/* TODO 记录dlg_id, 并交给协议打包模块, 由协议处理模块发送及接收解析, 将在接收线程处处理 */
static void deal_net_req(void *base, size_t len)
{
    int idx = -1;
    net_req_t *req = NULL;

    req = (net_req_t*)base;
    if (req == NULL)
    {
        e_error("deal_net_req",
                "data transfer to netagent is NULL, req[%s]!",
                req == NULL ? "NULL" : "NOT NULL");

        return;
    }

    e_debug("deal_net_req", "new data has transferd to netagent!");
    
    /* 获取请求的会话id */
    idx = deal_ctrl_net(req->cmd, req->req);
    /* 传递数据 */    
    dlg[idx].net_req = (net_req_t *)base;
}