private void btnOK_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { LoadCertificate lc = new LoadCertificate(); lc.command = SmartDeviceInterface.COM_LOAD_CERTIFICATE_JS_; lc.data = new Certificate[1]; lc.data[0] = new Certificate(); lc.data[0].startTime = dtpStartTime.Value.ToString(); lc.data[0].endTime = dtpEndTime.Value.ToString(); lc.data[0].subDeviceID = txtChildDeviceID.Text; lc.data[0].UserType = cbxUserType.SelectedIndex + 1; lc.data[0].credenceType = (CredenceType)(cbxCredenceType.SelectedIndex + 1); lc.data[0].credenceNo = txtCredenceNo.Text; lc.data[0].userName = txtUserName.Text; lc.data[0].userID = txtUserID.Text; lc.data[0].opTime = dtpOpTime.Value.ToString(); lc.data[0].placeNo = txtPlaceNo.Text; lc.data[0].placeLockNo = txtPlaceLockNo.Text; string strSend = JsonConvert.SerializeObject(lc); byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend)); strSend = UTF8Encoding.Default.GetString(byteUTF8); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_LOAD_CERTIFICATE_JS, strSend, byteUTF8.Length, szResponse, ref iResponseLen); if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS && iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); byte[] byteDefault = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteJsonResponse); strJsonResponse = Encoding.Default.GetString(byteDefault); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { } GloablInfo.sdk.txtCredetificateMgr.Text += GloablInfo.GetResultDescription(iResult); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { MessageBox.Show("请选择设备"); } }
private void btn_readCertificate_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { ReadCertificateSend lcs = new ReadCertificateSend(); lcs.command = SmartDeviceInterface.COM_READ_CERTIFICATE_JS_; lcs.data = new ReadCertificate[1]; lcs.data[0] = new ReadCertificate(); lcs.data[0].credenceNo = txtCredenceNo.Text; string strSend = JsonConvert.SerializeObject(lcs); byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend)); strSend = UTF8Encoding.Default.GetString(byteUTF8); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_READ_CERTIFICATE_JS, strSend, byteUTF8.Length, szResponse, ref iResponseLen); if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS && iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); byte[] byteDefault = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteJsonResponse); strJsonResponse = Encoding.Default.GetString(byteDefault); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { ReadCertificateResponse rcr = new ReadCertificateResponse(); rcr = JsonConvert.DeserializeObject <ReadCertificateResponse>(strJsonResponse); GloablInfo.sdk.txtCredetificateMgr.Text += "凭证编号:"; GloablInfo.sdk.txtCredetificateMgr.Text += rcr.data[0].credenceNo; GloablInfo.sdk.txtCredetificateMgr.Text += "开始时间:"; GloablInfo.sdk.txtCredetificateMgr.Text += rcr.data[0].startTime; GloablInfo.sdk.txtCredetificateMgr.Text += "结束时间:"; GloablInfo.sdk.txtCredetificateMgr.Text += rcr.data[0].endTime; GloablInfo.sdk.txtCredetificateMgr.Text += "\r\n"; } //MessageBox.Show(GloablInfo.GetResultDescription(iResult)); GloablInfo.sdk.txtCredetificateMgr.Text += GloablInfo.GetResultDescription(iResult); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { GloablInfo.sdk.txtCredetificateMgr.Text += "请选择设备"; } }
private void btn4_ManageConfirm_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { DownloadBlackAndWhiteListSend lc = new DownloadBlackAndWhiteListSend(); lc.command = SmartDeviceInterface.COM_DOWNLOAD_BLACK_AND_WHITE_LIST_JS_; lc.data = new DownloadBlackAndWhiteList[1]; lc.data[0] = new DownloadBlackAndWhiteList(); lc.data[0].status = cbxStatus.SelectedIndex; lc.data[0].startTime = dtpStartTime.Value.ToString(); lc.data[0].endTime = dtpEndTime.Value.ToString(); lc.data[0].userName = txtUserName.Text; lc.data[0].userID = txtUserID.Text; lc.data[0].carNo = txtCarNo.Text; lc.data[0].opTime = dtpOpTime.Value.ToString(); lc.data[0].remark = txtRemark.Text; lc.data[0].sheetType = cbxSheetType.SelectedIndex + 1; string strSend = JsonConvert.SerializeObject(lc); byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend)); strSend = UTF8Encoding.Default.GetString(byteUTF8); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_DOWNLOAD_BLACK_AND_WHITE_LIST_JS, strSend, byteUTF8.Length, szResponse, ref iResponseLen); if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS && iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); byte[] byteDefault = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteJsonResponse); strJsonResponse = Encoding.Default.GetString(byteDefault); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { } MessageBox.Show(GloablInfo.GetResultDescription(iResult)); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { MessageBox.Show("请选择设备"); } }
private void btn1_ModifyConfirm_Click(object sender, EventArgs e) { ModifyIpPortSend mip = new ModifyIpPortSend(); mip.command = SmartDeviceInterface.COM_DEV_SEARCH_JS_; mip.data = new ModifyIpPort[1]; mip.data[0] = new ModifyIpPort(); mip.data[0].type = int.Parse(txtDevType.Text); mip.data[0].hasInit = int.Parse(txtDevInit.Text); mip.data[0].deviceID = txtDeviceIDType + txtDeviceIDCodeNO.Text + txtDeviceIDMAC.Text; mip.data[0].manufacturer = txtManufacturer.Text; mip.data[0].macNO = int.Parse(txtMACNO.Text); mip.data[0].locationAddr = txtAddr.Text; mip.data[0].name = txtName.Text; mip.data[0].masterIP = txtWorkIP.Text; mip.data[0].mac = txtMac.Text; mip.data[0].ip = txtDevIP.Text; mip.data[0].mask = txtMask.Text; mip.data[0].gateWay = txtGateWay.Text; mip.data[0].port = int.Parse(txtPort.Text); mip.data[0].version = txtVersion.Text; string strSend = JsonConvert.SerializeObject(mip); byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend)); strSend = UTF8Encoding.Default.GetString(byteUTF8); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("SmartDevice_ModifyDeviceIPAndPort发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_ModifyDeviceIPAndPort(strSend, strSend.Length, szResponse, ref iResponseLen); if (iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); byte[] byteDefault = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteJsonResponse); strJsonResponse = Encoding.Default.GetString(byteDefault); } MessageBox.Show(GloablInfo.GetResultDescription(iResult)); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); }
private void btn1_ReadVolume_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { DeviceSendHead dsh = new DeviceSendHead(); dsh.command = SmartDeviceInterface.COM_READ_VOL_JS_; string strSend = JsonConvert.SerializeObject(dsh); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_READ_VOL_JS, strSend, strSend.Length, szResponse, ref iResponseLen); if (iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); strJsonResponse = System.Text.UTF8Encoding.Default.GetString(byteJsonResponse); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { ReadVolResponse rpr = new ReadVolResponse(); rpr = JsonConvert.DeserializeObject <ReadVolResponse>(strJsonResponse); txtDeviceMgr.Text += "非设定时段声音级别:"; txtDeviceMgr.Text += rpr.data[0].defualtLevel.ToString(); txtDeviceMgr.Text += "\r\n"; foreach (VolLevel vl in rpr.data[0].level) { txtDeviceMgr.Text += "设定时段声音级别:"; txtDeviceMgr.Text += vl.settedLevel.ToString(); txtDeviceMgr.Text += "开始时间:"; txtDeviceMgr.Text += vl.startTime.ToString(); txtDeviceMgr.Text += "结束时间:"; txtDeviceMgr.Text += vl.endTime.ToString(); txtDeviceMgr.Text += "\r\n"; } txtDeviceMgr.Text += "\r\n"; } txtDeviceMgr.Text += GloablInfo.GetResultDescription(iResult); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { txtDeviceMgr.Text += "请选择设备\r\n"; } }
private void btn2_NotifyConfirm_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { Thread th = new Thread(() => { NotifyDeviceUpdate st = new NotifyDeviceUpdate(); st.command = SmartDeviceInterface.COM_NOTIFY_UPDATE_JS_; st.data = new DeviceUpdateInfo[1]; st.data[0] = new DeviceUpdateInfo(); st.data[0].fileID = txtFileID.Text; string strSend = JsonConvert.SerializeObject(st); byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend)); strSend = UTF8Encoding.Default.GetString(byteUTF8); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); SmartDeviceInterface.SmartDevice_SetTimeOut(4 * 60 * 1000); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_NOTIFY_UPDATE_JS, strSend, byteUTF8.Length, szResponse, ref iResponseLen); SmartDeviceInterface.SmartDevice_SetTimeOut(1000); if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS && iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); byte[] byteDefault = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteJsonResponse); strJsonResponse = Encoding.Default.GetString(byteDefault); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { } MessageBox.Show(GloablInfo.GetResultDescription(iResult)); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); }); th.Start(); } else { MessageBox.Show("请选择设备"); } }
private void OK_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { ManualThroughSend lc = new ManualThroughSend(); lc.command = SmartDeviceInterface.COM_MANUAL_THROUGH_JS_; lc.data = new ManualThrough[1]; lc.data[0] = new ManualThrough(); lc.data[0].credenceNo = txtCredenceNO.Text; lc.data[0].userID = txtUserID.Text; lc.data[0].userType = (UserType)(cbxUserType.SelectedIndex + 1); lc.data[0].throughType = cbxReleaseType.SelectedIndex; lc.data[0].ledDisplayText = txtLEDText.Text; lc.data[0].speakText = txtVoiceText.Text; string strSend = JsonConvert.SerializeObject(lc); byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend)); strSend = UTF8Encoding.Default.GetString(byteUTF8); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_MANUAL_THROUGH_JS, strSend, byteUTF8.Length, szResponse, ref iResponseLen); if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS && iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); byte[] byteDefault = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteJsonResponse); strJsonResponse = Encoding.Default.GetString(byteDefault); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { } GloablInfo.sdk.txtDeviceControl.Text += GloablInfo.GetResultDescription(iResult); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { GloablInfo.sdk.txtDeviceControl.Text += "请选择设备\r\n"; } }
private void OK_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { DeviceSendHead dsh = new DeviceSendHead(); dsh.command = SmartDeviceInterface.COM_SNAP_PICTURE_JS_; string strSend = JsonConvert.SerializeObject(dsh); byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend)); strSend = UTF8Encoding.Default.GetString(byteUTF8); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_SNAP_PICTURE_JS, strSend, byteUTF8.Length, szResponse, ref iResponseLen); if (iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); byte[] byteDefault = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteJsonResponse); strJsonResponse = Encoding.Default.GetString(byteDefault); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { SnapPictureResponse spr = new SnapPictureResponse(); spr = JsonConvert.DeserializeObject <SnapPictureResponse>(strJsonResponse); GloablInfo.sdk.txtDeviceControl.Text += "文件路径:"; GloablInfo.sdk.txtDeviceControl.Text += spr.data[0].imageID; GloablInfo.sdk.txtDeviceControl.Text += "\r\n"; } GloablInfo.sdk.txtDeviceControl.Text += GloablInfo.GetResultDescription(iResult); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { GloablInfo.sdk.txtDeviceControl.Text += "请选择设备\r\n"; } }
//private void btn4_Del_Click(object sender, EventArgs e) //{ // MessageBox.Show("删除成功"); //} //private void btn4_Add_Click_1(object sender, EventArgs e) //{ // MessageBox.Show("增加成功"); //} private void btn3_ReadCertificateCount_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { DeviceSendHead dsh = new DeviceSendHead(); dsh.command = SmartDeviceInterface.COM_READ_CERTIFICATE_COUNT_JS_; string strSend = JsonConvert.SerializeObject(dsh); byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend)); strSend = UTF8Encoding.Default.GetString(byteUTF8); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_READ_CERTIFICATE_COUNT_JS, strSend, byteUTF8.Length, szResponse, ref iResponseLen); if (iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); byte[] byteDefault = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteJsonResponse); strJsonResponse = Encoding.Default.GetString(byteDefault); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { ReadCertificateCountResponse rccr = new ReadCertificateCountResponse(); rccr = JsonConvert.DeserializeObject <ReadCertificateCountResponse>(strJsonResponse); txtCredetificateMgr.Text += "凭证数量:"; txtCredetificateMgr.Text += rccr.data[0].count.ToString(); txtCredetificateMgr.Text += "\r\n"; } txtCredetificateMgr.Text += GloablInfo.GetResultDescription(iResult); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { txtCredetificateMgr.Text += "请选择设备\r\n"; } }
private void OK_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { GateControlSend lc = new GateControlSend(); lc.command = SmartDeviceInterface.COM_GATE_CONTROL_JS_; lc.data = new GateControl[1]; lc.data[0] = new GateControl(); lc.data[0].operateType = cbxOperateType.SelectedIndex; lc.data[0].locationAddr = GloablInfo.curDevInfo.deviceID; lc.data[0].userID = txtDevID.Text; lc.data[0].userType = (UserType)(cbxUserType.SelectedIndex + 1); string strSend = JsonConvert.SerializeObject(lc); byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend)); strSend = UTF8Encoding.Default.GetString(byteUTF8); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_GATE_CONTROL_JS, strSend, byteUTF8.Length, szResponse, ref iResponseLen); if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS && iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); byte[] byteDefault = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteJsonResponse); strJsonResponse = Encoding.Default.GetString(byteDefault); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { } GloablInfo.sdk.txtDeviceControl.Text += GloablInfo.GetResultDescription(iResult); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { GloablInfo.sdk.txtDeviceControl.Text += "请选择设备\r\n"; } }
private void btn1_DevMsgQuery_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { DeviceSendHead dsh = new DeviceSendHead(); dsh.command = SmartDeviceInterface.COM_QUERY_DEV_INFO_JS_; string strSend = JsonConvert.SerializeObject(dsh); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_QUERY_DEV_INFO_JS, strSend, strSend.Length, szResponse, ref iResponseLen); if (iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); strJsonResponse = System.Text.UTF8Encoding.Default.GetString(byteJsonResponse); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { ReadSubDeviceResponse rsdr = new ReadSubDeviceResponse(); rsdr = JsonConvert.DeserializeObject <ReadSubDeviceResponse>(strJsonResponse); foreach (SubDeviceInfo sdi in rsdr.data) { txtDeviceMgr.Text += "设备ID:"; txtDeviceMgr.Text += sdi.deviceID; txtDeviceMgr.Text += "设备名字:"; txtDeviceMgr.Text += sdi.deviceName; txtDeviceMgr.Text += "\r\n"; } } txtDeviceMgr.Text += GloablInfo.GetResultDescription(iResult); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { txtDeviceMgr.Text += "请选择设备\r\n"; } }
private void btn5_OK_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { RemainPlaceSend lc = new RemainPlaceSend(); lc.command = SmartDeviceInterface.PAK_LOAD_LEFT_CAR_SEAT_JS_; lc.data = new RemainPlace[1]; lc.data[0] = new RemainPlace(); lc.data[0].remaningSpace = int.Parse(txtRemaningSpace.Text); lc.data[0].allSpace = int.Parse(txtAllSpace.Text); string strSend = JsonConvert.SerializeObject(lc); byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend)); strSend = UTF8Encoding.Default.GetString(byteUTF8); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.PAK_LOAD_LEFT_CAR_SEAT_JS, strSend, byteUTF8.Length, szResponse, ref iResponseLen); if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS && iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); byte[] byteDefault = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteJsonResponse); strJsonResponse = Encoding.Default.GetString(byteDefault); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { } MessageBox.Show(GloablInfo.GetResultDescription(iResult)); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { MessageBox.Show("请选择设备"); } }
private void btn6_Voice_Confirm_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { TextSend lc = new TextSend(); lc.command = SmartDeviceInterface.COM_PLAY_VOICE_JS_; lc.data = new LEDDisplayVoiceText[1]; lc.data[0] = new LEDDisplayVoiceText(); lc.data[0].text = txtVoice.Text; string strSend = JsonConvert.SerializeObject(lc); byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend)); strSend = UTF8Encoding.Default.GetString(byteUTF8); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_PLAY_VOICE_JS, strSend, byteUTF8.Length, szResponse, ref iResponseLen); if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS && iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); byte[] byteDefault = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteJsonResponse); strJsonResponse = Encoding.Default.GetString(byteDefault); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { } GloablInfo.sdk.txtDeviceControl.Text += GloablInfo.GetResultDescription(iResult); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { GloablInfo.sdk.txtDeviceControl.Text += "请选择设备\r\n"; } }
private void btn1_SetVoiceConfrim_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { SetVolSend svs = new SetVolSend(); svs.command = SmartDeviceInterface.COM_SET_VOL_JS_; svs.data = new SetVol[1]; svs.data[0] = new SetVol(); svs.data[0].defualtLevel = int.Parse(txtDefaulLevel.Text); svs.data[0].levelCount = 1; svs.data[0].level = new VolLevel[1]; svs.data[0].level[0] = new VolLevel(); svs.data[0].level[0].settedLevel = int.Parse(txtSettedLevel.Text); svs.data[0].level[0].startTime = dtpStartTime.Value.ToShortTimeString(); svs.data[0].level[0].endTime = dtpEndTime.Value.ToShortTimeString(); string strSend = JsonConvert.SerializeObject(svs); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_SET_VOL_JS, strSend, strSend.Length, szResponse, ref iResponseLen); if (iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); strJsonResponse = System.Text.UTF8Encoding.Default.GetString(byteJsonResponse); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { } MessageBox.Show(GloablInfo.GetResultDescription(iResult)); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { MessageBox.Show("请选择设备"); } }
private void btn2_ReadOSVer_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { DeviceSendHead dsh = new DeviceSendHead(); dsh.command = SmartDeviceInterface.COM_READ_SYSTEM_VERSION_JS_; string strSend = JsonConvert.SerializeObject(dsh); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_READ_SYSTEM_VERSION_JS, strSend, strSend.Length, szResponse, ref iResponseLen); if (iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); strJsonResponse = System.Text.UTF8Encoding.Default.GetString(byteJsonResponse); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { ReadVersionInfoResponse rvr = new ReadVersionInfoResponse(); rvr = JsonConvert.DeserializeObject <ReadVersionInfoResponse>(strJsonResponse); txtSystemMgr.Text += "应用程序版本号:"; txtSystemMgr.Text += rvr.data[0].appVersionInfo; txtSystemMgr.Text += "算法版本号:"; txtSystemMgr.Text += rvr.data[0].algVersionInfo; txtSystemMgr.Text += "\r\n"; } txtSystemMgr.Text += GloablInfo.GetResultDescription(iResult); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { txtSystemMgr.Text += "请选择设备\r\n"; } }
private void btn2_SetTime_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { SetTime st = new SetTime(); st.command = SmartDeviceInterface.COM_SET_TIME_JS_; st.data = new TimeString[1]; st.data[0] = new TimeString(); st.data[0].time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string strSend = JsonConvert.SerializeObject(st); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_SET_TIME_JS, strSend, strSend.Length, szResponse, ref iResponseLen); if (iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); strJsonResponse = System.Text.UTF8Encoding.Default.GetString(byteJsonResponse); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { } txtSystemMgr.Text += GloablInfo.GetResultDescription(iResult); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { txtSystemMgr.Text += "请选择设备\r\n"; } }
//确认按钮 private void SetConfirm_Click(object sender, EventArgs e) { if (GloablInfo.curDevInfo != null) { SetParameterSend svs = new SetParameterSend(); svs.command = SmartDeviceInterface.COM_SET_PARAMETER_JS_; svs.data = new Parameter[1]; svs.data[0] = new Parameter(); svs.data[0].deviceID = GloablInfo.curDevInfo.deviceID; svs.data[0].fileServerUrl = txtFileServerUrl.Text; svs.data[0].ntpServer = txtNtpServer.Text; svs.data[0].httpUserName = txtUserName.Text; svs.data[0].httpPassword = txtPwd.Text; svs.data[0].talkIP1 = txtTalkIP1.Text; svs.data[0].talkPort1 = int.Parse(txtTalkPort1.Text); svs.data[0].startTime = dtpStartTime.Value.ToShortTimeString(); svs.data[0].endTime = dtpEndTime.Value.ToShortTimeString(); svs.data[0].talkIP2 = txtTalkIP2.Text; svs.data[0].talkPort2 = int.Parse(txtTalkPort2.Text); svs.data[0].macNo = int.Parse(txtMacNo.Text); svs.data[0].camera1RtspAddr = txtCamera1.Text; svs.data[0].camera2RtspAddr = txtCamera2.Text; svs.data[0].deviceEntryType = (DeviceEntryType)(cbxDeviceEnterType.SelectedIndex + 1); svs.data[0].camerasSynergism = cbxCamerasSynergism.SelectedIndex + 1; svs.data[0].openGateFlag = cbxOpenGateFlag.SelectedIndex + 1; svs.data[0].permitCardType = cbxPermitCardType.SelectedIndex + 1; string strSend = JsonConvert.SerializeObject(svs); byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend)); strSend = UTF8Encoding.Default.GetString(byteUTF8); int iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH; GloablInfo.UpdateMsg("发送数据:" + strSend); string strJsonResponse = ""; IntPtr szResponse = Marshal.AllocHGlobal(iResponseLen); int iResult = SmartDeviceInterface.SmartDevice_Common(GloablInfo.curDevInfo.deviceID, SmartDeviceInterface.COM_SET_PARAMETER_JS, strSend, byteUTF8.Length, szResponse, ref iResponseLen); if (iResponseLen > 0) { byte[] byteJsonResponse = new byte[iResponseLen]; Marshal.Copy(szResponse, byteJsonResponse, 0, iResponseLen); byte[] byteDefault = Encoding.Convert(Encoding.UTF8, Encoding.Default, byteJsonResponse); strJsonResponse = Encoding.Default.GetString(byteDefault); } if (iResult == SmartDeviceInterface.OPERATOR_SUCCESS) { } MessageBox.Show(GloablInfo.GetResultDescription(iResult)); Marshal.FreeHGlobal(szResponse); GloablInfo.UpdateMsg("接收数据:" + strJsonResponse); } else { MessageBox.Show("请选择设备"); } }