Exemplo n.º 1
0
BOOL CDlgCfgAlarmExAlarmBox::SetConfigToDevice()
{
	assert(m_pstuInfo != NULL);
	int nSel = m_cbSerialPort.GetCurSel();
	if (nSel == -1 || nSel >= m_nMaxExAlarmBox)
	{
		return FALSE;
	}

	char szJsonBuf[1024 * 2] = {0};
	BOOL bRet = CLIENT_PacketData(CFG_CMD_EXALARMBOX, m_pstuInfo, 
		sizeof(CFG_EXALARMBOX_INFO) * m_nCurExAlarmBoxCount, szJsonBuf, sizeof(szJsonBuf));
	if (!bRet)
	{
		MessageBox(ConvertString("Packet data for ExAlarmBox Configuration failed.", DLG_CFG_EXALARMBOX), ConvertString("Prompt"));
		return FALSE;
	}
	
	int nErr = 0, nRestart = 0;
	bRet = CLIENT_SetNewDevConfig(m_lLoginId, CFG_CMD_EXALARMBOX,
		-1, szJsonBuf, strlen(szJsonBuf), &nErr, &nRestart, SDK_API_WAIT);
	if (!bRet)
	{
		CString csOut;
		csOut.Format("%s %08x!", ConvertString("Set ExAlarmBox Configuration failed:", DLG_CFG_EXALARMBOX), CLIENT_GetLastError());
		MessageBox(csOut, ConvertString("Prompt"));
		return FALSE;
	}
	
	MessageBox(ConvertString("Set ExAlarmBox Configuration Successfully.", DLG_CFG_EXALARMBOX), ConvertString("Prompt"));
	return TRUE;
}
Exemplo n.º 2
0
BOOL CDlgCfgNetCollection::SetConfigToDevice()
{
    char szJsonBuf[1024 * 40] = {0};
    if (szJsonBuf == NULL)
    {
        return FALSE;
    }
    
    BOOL bRet = CLIENT_PacketData(CFG_CMD_NET_COLLECTION, &m_stuInfo, sizeof(m_stuInfo), szJsonBuf, sizeof(szJsonBuf));
    if (!bRet)
    {
        MessageBox(ConvertString(CString("packet NetCollection error..."), DLG_CFG_NETCOLLECTION), ConvertString("Prompt"));
        return FALSE;
    } 
    else
    {
		int nSelChn = m_cmbChannel.GetCurSel() == -1 ? 0 : m_cmbChannel.GetCurSel();
        int nerror = 0;
        int nrestart = 0;
        bRet = CLIENT_SetNewDevConfig(m_lLoginID, CFG_CMD_NET_COLLECTION, nSelChn, szJsonBuf, sizeof(szJsonBuf), &nerror, &nrestart, SDK_API_WAIT);
        if (!bRet)
        {
            CString csErr;
            csErr.Format("%s 0x%08x...", ConvertString("SetupConfig NetCollection failed:", DLG_CFG_NETCOLLECTION), CLIENT_GetLastError());
            MessageBox(csErr, ConvertString("Prompt"));
            return FALSE;
        }
        else
        {
            MessageBox(ConvertString(CString("SetConfig NetCollection ok!"), DLG_CFG_NETCOLLECTION), ConvertString("Prompt"));
        }
    }
    return TRUE;
}
Exemplo n.º 3
0
void CDlgQueryLog::OnQuerylogBtnTotalCount() 
{
	// TODO: Add your control notification handler code here
	NET_IN_GETCOUNT_LOG_PARAM stuIn = {sizeof(stuIn)};
	NET_OUT_GETCOUNT_LOG_PARAM stuOut = {sizeof(stuOut)};
	if (CLIENT_QueryDevLogCount(m_lLoginId, &stuIn, &stuOut, SDK_API_WAITTIME))
	{
		SetDlgItemInt(IDC_QUERYLOG_EDT_TOTALCOUNT, stuOut.nLogCount);
	}
	else
	{
		CString csOut;
		csOut.Format("%s:0x%08x", ConvertString("Query log total count failed", DLG_QUERYLOG), CLIENT_GetLastError());
		MessageBox(csOut, ConvertString("Prompt"));
	}
}
Exemplo n.º 4
0
BOOL CDlgCfgAlarmExAlarmBox::GetConfigFromDevice()
{
	assert(m_pstuInfo != NULL);
	int nSel = m_cbSerialPort.GetCurSel();
	if (nSel == -1 || nSel >= m_nMaxExAlarmBox)
	{
		return FALSE;
	}
	
	char szJsonBuf[1024 * 2] = {0};
	int nErr = 0;
	AV_int32 nRet = CLIENT_GetNewDevConfig(m_lLoginId, CFG_CMD_EXALARMBOX,
		-1, szJsonBuf, sizeof(szJsonBuf), &nErr, SDK_API_WAIT);
	if (!nRet)
	{
		CString csOut;
		csOut.Format("%s %08x\r\n\r\n%s", ConvertString("Query ExAlarmBox Configuration failed: ", DLG_CFG_EXALARMBOX), CLIENT_GetLastError(), szJsonBuf);
		MessageBox(csOut, ConvertString("Prompt"));
		return FALSE;
	}
	
	CFG_EXALARMBOX_INFO* pstuInfo = new CFG_EXALARMBOX_INFO[m_nMaxExAlarmBox];
	assert(pstuInfo != NULL);
	memset(pstuInfo, 0, sizeof(CFG_EXALARMBOX_INFO) * m_nMaxExAlarmBox);
	DWORD dwRetLen = 0;
	
	nRet = CLIENT_ParseData(CFG_CMD_EXALARMBOX, szJsonBuf, pstuInfo, sizeof(CFG_EXALARMBOX_INFO) * m_nMaxExAlarmBox, &dwRetLen);
	if (!nRet)
	{
		MessageBox(ConvertString("Parse data for ExAlarmBox Configuration failed!", DLG_CFG_EXALARMBOX), ConvertString("Prompt"));
		delete []pstuInfo;
		return FALSE;
	}

	int nCount = __min(m_nMaxExAlarmBox, dwRetLen / sizeof(CFG_EXALARMBOX_INFO));
	if (nCount > 0)
	{
		m_nCurExAlarmBoxCount = nCount;
		m_cbSerialPort.ResetContent();
		int i = 0;
		
		for (i = 0; i < m_nCurExAlarmBoxCount; i++)
		{
			CString csTemp;
			csTemp.Format("%s %02d", ConvertString("Channel", DLG_CFG_SERIAL), i + 1);
			m_cbSerialPort.InsertString(-1, csTemp);
		}
		m_cbSerialPort.SetCurSel(0);
	}
	memcpy(m_pstuInfo, pstuInfo, sizeof(CFG_EXALARMBOX_INFO) * nCount);
	delete []pstuInfo;
	return TRUE;
}
Exemplo n.º 5
0
BOOL CDlgCfgAnalogAlarm::OnInitDialog() 
{
	CDialog::OnInitDialog();
	g_SetWndStaticText(this, DLG_CFG_ANALOGALARM);
	// TODO: Add extra initialization here
	if (!m_hLoginID)
	{
		MessageBox(ConvertString("We haven't login yet!", DLG_CFG_ANALOGALARM), ConvertString("Prompt"));
		return FALSE;
	}

	int nRetLen = 0;

	BOOL bRet = CLIENT_QueryDevState(m_hLoginID,DH_DEVSTATE_GET_SENSORLIST,(char*)&m_stuSensorList, sizeof(m_stuSensorList),&nRetLen,SDK_API_WAIT);
	if (bRet == FALSE)
	{
		CString csErr;
		csErr.Format("%s %08x...",ConvertString("Query state GetSensorList failed:", DLG_CFG_ANALOGALARM), CLIENT_GetLastError());
		MessageBox(csErr, ConvertString("Prompt"));
		//return FALSE;
	} 

	GetConfigFromDevice();
	InitDlg();
	StuToDlg();
		
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Exemplo n.º 6
0
BOOL CDlgCfgPSTNBreakLine::SetConfigToDevice()
{
    char szJsonBuf[1024 * 40] = {0};
    if (szJsonBuf == NULL)
    {
        return FALSE;
    }
    
    BOOL bRet = CLIENT_PacketData(CFG_CMD_PSTN_BREAK_LINE, &m_stuInfo, sizeof(m_stuInfo), szJsonBuf, sizeof(szJsonBuf));
    if (!bRet)
    {
        MessageBox(ConvertString(CString("packet PSTNBreakLine error..."), DLG_CFG_PSTNBREAKLINE), ConvertString("Prompt"));
        return FALSE;
    } 
    else
    {
        int nerror = 0;
        int nrestart = 0;
        bRet = CLIENT_SetNewDevConfig(m_lLoginId, CFG_CMD_PSTN_BREAK_LINE, -1, szJsonBuf, sizeof(szJsonBuf), &nerror, &nrestart, SDK_API_WAIT);
        if (!bRet)
        {
            CString csErr;
            csErr.Format("%s 0x%08x...", ConvertString("SetupConfig PSTNBreakLine failed:", DLG_CFG_PSTNBREAKLINE), CLIENT_GetLastError());
            MessageBox(csErr, ConvertString("Prompt"));
            return FALSE;
        }
        else
        {
            MessageBox(ConvertString(CString("SetConfig PSTNBreakLine ok!"), DLG_CFG_PSTNBREAKLINE), ConvertString("Prompt"));
        }
    }
    return TRUE;
}
Exemplo n.º 7
0
static int 
dah_set_device_config(struct service *srv, int parm_id, void *parm)
{
    int ret = FALSE, err = 0;
    int user_id, cmd;

    proxy_ctrl_t *ctrl;
    proxy_task_t *task;

    dah_service_t *dah_srv;
    dah_config_t  *dah_cfg;
    dah_new_config_t *dah_new_cfg;

    DISKCTRL_PARAM *disk_ctrl;

    NMP_ASSERT(srv && parm_id && parm);

    dah_srv = (dah_service_t*)srv;
    user_id = dah_get_user_id(&dah_srv->parm);

    if (DAH_LOGOUT == user_id)
    {
        show_debug("Proxy device logout!!!!!!!!!!!!!!\n");
        return -1;
    }

    switch (parm_id)
    {
        case SET_SERIAL_CONFIG:
            goto SET_CFG;
        case SET_DEVICE_TIME:
            goto SET_CFG;
        case SET_NTP_CONFIG:
            goto SET_CFG;
        case SET_NETWORK_CONFIG:
            goto SET_CFG;
        case SET_PPPOE_CONFIG:
            goto SET_CFG;
        case SET_FTP_CONFIG:
            goto SET_CFG;
        case SET_SMTP_CONFIG:
            goto SET_CFG;
        case SET_DDNS_CONFIG:
            goto SET_CFG;
        case SET_UPNP_CONFIG:
            goto SET_CFG;

        case SET_DISK_FORMAT:
            disk_ctrl = (DISKCTRL_PARAM*)nmp_new(DISKCTRL_PARAM, 1);
            memcpy(disk_ctrl, ((dah_config_t*)parm)->buffer, sizeof(DISKCTRL_PARAM));
            ctrl = proxy_new_ctrl_2(srv, CTRL_CMD_FRMTDISK, disk_ctrl, 
                    sizeof(DISKCTRL_PARAM), dah_free_ctrl_user);
            if (!ctrl)
                ret = FALSE;
            else
            {
                task = proxy_new_task(CONTROL_DEVICE, ctrl, sizeof(ctrl), 
                        proxy_free_ctrl, dah_srv->owner);
                if (task)
                {
                    proxy_thread_pool_push(task);
                    ret = TRUE;
                }
                else
                {
                    proxy_free_ctrl((void*)ctrl, sizeof(ctrl));
                    ret = FALSE;
                }
            }
            break;

        case CONTROL_DEVICE_CMD:
            switch (((JControlDevice*)parm)->command)
            {
                case SHUTDOWN_DEVICE:
                    ret = TRUE;
                    cmd = CTRL_CMD_SHUTDOWN;
                    break;
                case RESTART_DEVICE:
                    ret = TRUE;
                    cmd = CTRL_CMD_REBOOT;
                    break;
                case RESTORE_DEFAULT:
                    ret = TRUE;
                    cmd = CTRL_CMD_RESET;
                    break;

                case DETECT_DEAL_PIX:
                    ret = FALSE;
                    break;
                case DETECT_IRIS:
                    ret = FALSE;
                    break;

                default:
                    ret = FALSE;
                    break;
            }

            if (ret)
            {
                ctrl = proxy_new_ctrl(srv, cmd, NULL);
                if (!ctrl)
                    ret = FALSE;
                else
                {
                    task = proxy_new_task(CONTROL_DEVICE, ctrl, sizeof(ctrl), 
                            proxy_free_ctrl, dah_srv->owner);
                    if (task)
                    {
                        proxy_thread_pool_push(task);
                        ret = TRUE;
                    }
                    else
                    {
                        proxy_free_ctrl((void*)ctrl, sizeof(ctrl));
                        ret = FALSE;
                    }
                }
            }
            break;

        case SET_ENCODE_CONFIG:
            goto SET_CFG;
        case SET_DISPLAY_CONFIG:
            goto SET_CFG;
        case SET_OSD_CONFIG:
            goto SET_CFG;
        case SET_PTZ_CONFIG:
            goto SET_NEW_CFG;
        case SET_RECORD_CONFIG:
            goto SET_CFG;
        case SET_HIDE_CONFIG:
            goto SET_CFG;
        case SET_MOTION_CONFIG:
            goto SET_CFG;
        case SET_VIDEO_LOST_CONFIG:
            goto SET_CFG;
        case SET_HIDE_ALARM_CONFIG:
            goto SET_CFG;
        case SET_IO_ALARM_CONFIG:
            goto SET_CFG;

        case CONTROL_PTZ_CMD:
            ret = CLIENT_PTZControl(user_id, 
                    (int  )((dah_ptz_ctrl_t*)parm)->channel, 
                    (DWORD)((dah_ptz_ctrl_t*)parm)->ptz_cmd, 
                    (DWORD)((dah_ptz_ctrl_t*)parm)->step, 
                    (BOOL )((dah_ptz_ctrl_t*)parm)->stop);
            break;

        case SET_PRESET_CONFIG:
            /*strm_info = find_stream_by_channel(&dah_srv->rtsp.real_strm_list, 
                            ((struct dah_preset*)parm)->channel);
            if (strm_info && DAH_INVALID_HANDLE != strm_info->handle)
            {
                handle = strm_info->handle;
            }

            if (DAH_INVALID_HANDLE != handle)
            {
                ret = NET_DVR_PTZPreset((LONG)handle, 
                    (DWORD)((struct dah_preset*)parm)->preset_cmd, 
                    (DWORD)((struct dah_preset*)parm)->preset_no);
show_debug("NET_DVR_PTZPreset: %s<-------------------------------\n", (ret == TRUE) ? "Success" : "Failure");
            }*/
            break;

        case SET_CRUISE_CONFIG:
        case ADD_CRUISE_CONFIG:
        case MDF_CRUISE_CONFIG:
            break;

        default:
            ret = FALSE;
            break;
    }
    
    if (TRUE == ret)
        return 0;
    else
        return -1;

SET_CFG:
    dah_cfg = (dah_config_t*)parm;
    ret = CLIENT_SetDevConfig(user_id, 
            (DWORD  )dah_cfg->command, 
            (LONG   )dah_cfg->channel, 
            (LPVOID )dah_cfg->buffer, 
            (DWORD  )dah_cfg->b_size, 
            (int    )dah_cfg->waittime);
    show_debug("CLIENT_SetDevConfig: %s<-------------------------------\n", 
        (ret == TRUE) ? "Success" : "Failure");

    if (TRUE == ret)
        return 0;
    else
    {
        show_debug("ERROR: 0x%x<-------------------------------\n", 
            CLIENT_GetLastError());
        return -1;
    }

SET_NEW_CFG:
    dah_new_cfg = (dah_new_config_t*)parm;
    ret = CLIENT_PacketData(
            dah_new_cfg->command, 
            dah_new_cfg->buffer, 
            dah_new_cfg->b_size, 
            dah_new_cfg->out_json, 
            DEF_OUT_JSON_SIZE);
    if (ret)
    {
        ret = CLIENT_SetNewDevConfig(user_id, 
                dah_new_cfg->command, 
                dah_new_cfg->channel, 
                dah_new_cfg->out_json, 
                DEF_OUT_JSON_SIZE, 
                &err, FALSE, dah_new_cfg->waittime);

        show_debug("CLIENT_SetNewDevConfig: %s<-------------------------------\n", 
            (ret == TRUE) ? "Success" : "Failure");
    }

    if (TRUE == ret)
        return 0;
    else
    {
        show_debug("ERROR: 0x%x, err: %d<-------------------------------\n", 
            CLIENT_GetLastError(), err);
        return -1;
    }
}
Exemplo n.º 8
0
static int 
dah_get_device_config(struct service *srv, int parm_id, void *parm)
{
    int user_id, ret = FALSE, err = 0;

    JDevCap *dev_cap;

    dah_service_t *dah_srv;
    dah_config_t  *dah_cfg;
    dah_new_config_t *dah_new_cfg;
    dah_query_t *query;

    NMP_ASSERT(srv && parm);

    dah_srv = (dah_service_t*)srv;
    user_id = dah_get_user_id(&dah_srv->parm);

    if (DAH_LOGOUT == user_id)
    {
        show_debug("Proxy device logout!!!!!!!!!!!!!!\n");
        return -1;
    }

    switch (parm_id)
    {
        case GET_DEVICE_CONFIG:
            goto GET_CFG;
        case GET_SERIAL_CONFIG:
            goto GET_CFG;
        case GET_DEVICE_TIME:
            goto GET_CFG;
        case GET_NTP_CONFIG:
            goto GET_CFG;
        case GET_NETWORK_CONFIG:
            goto GET_CFG;
        case GET_PPPOE_CONFIG:
            goto GET_CFG;
        case GET_FTP_CONFIG:
            goto GET_CFG;
        case GET_SMTP_CONFIG:
            goto GET_CFG;
        case GET_DDNS_CONFIG:
            goto GET_CFG;
        case GET_UPNP_CONFIG:
            goto GET_CFG;
        case GET_DISK_LIST:
            goto GET_DEV_STATE;
        case GET_ENCODE_CONFIG:
            goto GET_CFG;
        case GET_DISPLAY_CONFIG:
            goto GET_CFG;
        case GET_OSD_CONFIG:
            goto GET_CFG;
        case GET_PTZ_CONFIG:
            goto GET_NEW_CFG;
        case GET_RECORD_CONFIG:
            goto GET_CFG;
        case GET_HIDE_CONFIG:
            goto GET_CFG;
        case GET_MOTION_CONFIG:
            goto GET_CFG;
        case GET_VIDEO_LOST_CONFIG:
            goto GET_CFG;
        case GET_HIDE_ALARM_CONFIG:
            goto GET_CFG;
        case GET_IO_ALARM_CONFIG:
            goto GET_CFG;

        case GET_STORE_LOG:
            query = (dah_query_t*)parm;

            printf("user_id : %d\n", user_id);
            printf("channel  : %d\n", query->channel);
            printf("file_type: %d\n", query->file_type);
            if (CLIENT_QueryRecordFile((LLONG)user_id, 
                    query->channel,
                    query->file_type, 
                    &query->start, 
                    &query->end, 
                    query->card_id, 
                    (NET_RECORDFILE_INFO*)query->buffer, 
                    query->buf_size, 
                    &query->filecount,
                    query->waittime, FALSE))
            {
                show_info("count: %d<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n", query->filecount);
                ret = TRUE;
            }
            else
            {
                ret = FALSE;
                show_debug("ERROR: 0x%x<-------------------------------\n", 
                    CLIENT_GetLastError());
            }
            show_debug("CLIENT_QueryRecordFile: %s<-----------------\n", 
                (ret == TRUE) ? "Success" : "Failure");
            break;

        case GET_CRUISE_CONFIG:
            /*cruise = (dah_cruise_t*)parm;
            show_debug("crz_no: %d<--------------------\n", cruise->crz_no);
            ret = NET_DVR_GetPTZCruise(user_id, 
                    (LONG)cruise->channel, 
                    (LONG)cruise->crz_no, 
                    (NET_DVR_CRUISE_RET*)cruise->input);
            show_debug("NET_DVR_GetDVRConfig: %s<-------------------------------\n", 
                (ret == TRUE) ? "Success" : "Failure");
            if (FALSE == ret)
                show_debug("ERROR: 0x%x<-------------------------------\n", CLIENT_GetLastError());*/
            break;

        case GET_CAPABILITY_SET:
            dev_cap = (JDevCap*)parm;
            dev_cap->cap0 = DEV_CAP_VIDEO_IN | DEV_CAP_AUDIO | DEV_CAP_IRIS | DEV_CAP_PTZ | 
                DEV_CAP_ALARM_IN | DEV_CAP_ALARM_OUT | DEV_CAP_STORAGE | DEV_CAP_WEB | DEV_CAP_PLATFORM | 
                DEV_CAP_INTELLIGENT_ANALYSIS | DEV_CAP_UPDATE | DEV_CAP_VIDEO_OUT;// | DEV_CAP_IR;
            dev_cap->ftp_enable = 1;
            dev_cap->upnp_enable = 0;
            dev_cap->chn_cap.size = sizeof(JChnCap);
            dev_cap->chn_cap.encode = VIDEO_ENCODE_H264_E | VIDEO_ENCODE_MJPEG_E | 
                VIDEO_ENCODE_JPEG_E | VIDEO_ENCODE_MPEG4_E;
            dev_cap->chn_cap.supp_mask = 1;
            dev_cap->chn_cap.mask_count = 4;
            dev_cap->chn_cap.supp_hide_alarm = 1;
            dev_cap->chn_cap.hide_alarm_count = 1;
            dev_cap->chn_cap.supp_move_alarm = 1;
            dev_cap->chn_cap.move_alarm_count = 1;
            dev_cap->chn_cap.supp_video_lost_alarm = 1;
            dev_cap->chn_cap.osd_count = 1;
            dev_cap->chn_cap.stream_count = 2;
            dev_cap->chn_cap.stream_supp_resolution[0] = CAP_VIDEO_QCIF | CAP_VIDEO_CIF | CAP_VIDEO_HD1 | 
                CAP_VIDEO_D1 | CAP_VIDEO_QQVGA | CAP_VIDEO_QVGA | CAP_VIDEO_VGA | CAP_VIDEO_SVGA | 
                CAP_VIDEO_UXGA | CAP_VIDEO_720P | CAP_VIDEO_960 | CAP_VIDEO_1080P;
            dev_cap->chn_cap.stream_supp_resolution[1] = CAP_VIDEO_QCIF | CAP_VIDEO_CIF | CAP_VIDEO_HD1 | 
                CAP_VIDEO_D1 | CAP_VIDEO_QQVGA | CAP_VIDEO_QVGA | CAP_VIDEO_VGA | CAP_VIDEO_SVGA | 
                CAP_VIDEO_UXGA | CAP_VIDEO_720P | CAP_VIDEO_960 | CAP_VIDEO_1080P;
            dev_cap->chn_cap.stream_supp_resolution[2] = CAP_VIDEO_QCIF | CAP_VIDEO_CIF | CAP_VIDEO_HD1 | 
                CAP_VIDEO_D1 | CAP_VIDEO_QQVGA | CAP_VIDEO_QVGA | CAP_VIDEO_VGA | CAP_VIDEO_SVGA | 
                CAP_VIDEO_UXGA | CAP_VIDEO_720P | CAP_VIDEO_960 | CAP_VIDEO_1080P;
            dev_cap->chn_cap.stream_supp_resolution[3] = CAP_VIDEO_QCIF | CAP_VIDEO_CIF | CAP_VIDEO_HD1 | 
                CAP_VIDEO_D1 | CAP_VIDEO_QQVGA | CAP_VIDEO_QVGA | CAP_VIDEO_VGA | CAP_VIDEO_SVGA | 
                CAP_VIDEO_UXGA | CAP_VIDEO_720P | CAP_VIDEO_960 | CAP_VIDEO_1080P;
            dev_cap->chn_cap.stream_max_frate_rate[0] = 25;
            dev_cap->chn_cap.img_cap = IMA_BRIGHTNESS | IMA_CONTRAST | IMA_SATURATION | IMA_HUE | IMA_SHARPNESS;
            ret = TRUE;
            break;

        default:
            ret = FALSE;
            show_warn("parm_id Invalid!!!!!\n");
            break;
    }

    if (TRUE == ret)
        return 0;
    else
        return -1;

GET_CFG:
    dah_cfg = (dah_config_t*)parm;
    ret = CLIENT_GetDevConfig((LLONG)user_id, 
            (DWORD  ) dah_cfg->command, 
            (LONG   ) dah_cfg->channel, 
            (LPVOID ) dah_cfg->buffer, 
            (DWORD  ) dah_cfg->b_size, 
            (LPDWORD)&dah_cfg->returns, 
            (int    ) dah_cfg->waittime);
    show_debug("CLIENT_GetDevConfig: %s<-------------------------------\n", 
        (ret == TRUE) ? "Success" : "Failure");
    if (TRUE == ret)
        return 0;
    else
    {
        show_debug("ERROR: 0x%x<-------------------------------\n", CLIENT_GetLastError());
        return -1;
    }

GET_NEW_CFG:
    dah_new_cfg = (dah_new_config_t*)parm;
    ret = CLIENT_GetNewDevConfig((LLONG)user_id, 
            dah_new_cfg->command, 
            dah_new_cfg->channel, 
            dah_new_cfg->out_json, 
            DEF_OUT_JSON_SIZE, &err, 
            dah_new_cfg->waittime);

    show_debug("CLIENT_GetNewDevConfig: %s<-------------------------------\n", 
        (ret == TRUE) ? "Success" : "Failure");

    if (TRUE == ret)
    {
        CLIENT_ParseData(
            dah_new_cfg->command, 
            dah_new_cfg->out_json, 
            dah_new_cfg->buffer, 
            dah_new_cfg->b_size, NULL);
        return 0;
    }
    else
    {
        show_debug("ERROR: 0x%x, err: 0x%x<-------------------------------\n", 
            CLIENT_GetLastError(), err);
        return -1;
    }

GET_DEV_STATE:
    dah_cfg = (dah_config_t*)parm;
    ret = CLIENT_QueryDevState(user_id, 
            (DWORD) dah_cfg->command, 
            (char*) dah_cfg->buffer, 
            (DWORD) dah_cfg->b_size, 
            (int* )&dah_cfg->returns, 
            (int  ) dah_cfg->waittime);

    show_debug("CLIENT_QueryDevState: %s<-------------------------------\n", 
        (ret == TRUE) ? "Success" : "Failure");

    if (TRUE == ret)
        return 0;
    else
    {
        show_debug("ERROR: 0x%x, err: %d<-------------------------------\n", 
            CLIENT_GetLastError(), err);
        return -1;
    }
}
Exemplo n.º 9
0
static int 
dah_control_service(service_template_t *self, struct service *srv, int cmd, void *parm)
{
    int user_id, ret = -1;
    dah_service_t *dah_srv;
    dah_service_basic_t *dah_basic;

    NMP_ASSERT(self && srv);

    dah_srv = (dah_service_t*)srv;
    dah_basic = (dah_service_basic_t*)self;

    switch (cmd)
    {
        case CTRL_CMD_LOGOUT:
            if (!dah_logout((LONG)dah_get_user_id(&dah_srv->parm)))
            {
                ret = 0;
                dah_set_user_id(dah_srv, DAH_LOGOUT);
                dah_set_state(dah_srv, DAH_LOGOUT, 0);
            }
            break;
        case CTRL_CMD_LOGIN:
            dah_login(dah_srv);
            ret = 0;
            break;
        case CTRL_CMD_RESET:
            break;
        case CTRL_CMD_REBOOT:
            sleep(2);
            if (CLIENT_RebootDev((LONG)dah_get_user_id(&dah_srv->parm)))
            {
                ret = 0;
                dah_set_user_id(dah_srv, DAH_LOGOUT);
                dah_set_state(dah_srv, DAH_LOGOUT, 0);
            }
            break;
        case CTRL_CMD_SHUTDOWN:
            sleep(2);
            if (CLIENT_ShutDownDev((LONG)dah_get_user_id(&dah_srv->parm)))
            {
                ret = 0;
                dah_set_user_id(dah_srv, DAH_LOGOUT);
                dah_set_state(dah_srv, DAH_LOGOUT, 0);
            }
            break;

        case CTRL_CMD_FRMTDISK:
            CLIENT_ControlDevice(dah_get_user_id(&dah_srv->parm), 
                    (CtrlType)DH_CTRL_DISK, (void*)parm, (int)1000);
            show_debug("CLIENT_ControlDevice: %s, ERROR: 0x%x<-------------------------------\n", 
                (ret == TRUE) ? "Success" : "Failure", CLIENT_GetLastError());

            dah_submit_format_progress(dah_srv, ((DISKCTRL_PARAM*)parm)->nIndex);

            //Reboot
            dah_set_user_id(dah_srv, DAH_LOGOUT);
            dah_set_state(dah_srv, DAH_LOGOUT, 0);
            ret = 0;
            break;

        case CTRL_CMD_SUBMIT:
            break;

        case CTRL_CMD_COMPARE:
            user_id = (int)parm;
            if (user_id == dah_get_user_id(&dah_srv->parm))
                ret = 0;
            break;

        case CTRL_CMD_OBTAIN_HANDLER:
            *(int*)parm = (int)&dah_handler_table;
            ret = 0;
            break;
        case CTRL_CMD_OBTAIN_STRM_OPT:
            *(int*)parm = (int)&dah_strm_opt;
            ret = 0;
            break;
        case CTRL_CMD_OBTAIN_TALK_OPT:
            *(int*)parm = (int)&dah_talk_opt;
            ret = 0;
            break;

        default:
            break;
    }

    return ret;
}