コード例 #1
0
        /// <summary>
        ///修改设备IP和端口
        /// </summary>
        /// <param name="json">修改设备IP和端口json数据</param>
        /// <param name="len">修改设备IP和端口json数据长度</param>
        /// <param name="jsonResponse">返回给设备的json数据</param>
        /// <param name="lenResponse">返回给设备的json数据长度</param>
        /// <returns>0 返回操作结果码OPERATOR_</returns>
        public Int32 SmartDevice_ModifyDeviceIPAndPort(string strSend, Int32 len, IntPtr jsonResponse)  //ref Int32 lenResponse
        {
            byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend));
            strSend = UTF8Encoding.Default.GetString(byteUTF8);
            int    iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH;
            IntPtr szResponse   = Marshal.AllocHGlobal(iResponseLen);

            return(SmartDeviceInterface.SmartDevice_ModifyDeviceIPAndPort(strSend, strSend.Length, szResponse, ref iResponseLen));
        }
コード例 #2
0
        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("请选择设备");
            }
        }
コード例 #3
0
        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 += "请选择设备";
            }
        }
コード例 #4
0
ファイル: MainFrm.cs プロジェクト: wyx1994/1111111
        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";
            }
        }
コード例 #5
0
ファイル: MainFrm.cs プロジェクト: wyx1994/1111111
        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("请选择设备");
            }
        }
コード例 #6
0
        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);
        }
コード例 #7
0
ファイル: MainFrm.cs プロジェクト: wyx1994/1111111
 private void btn_DevSearch_Click(object sender, EventArgs e)
 {
     if (SmartDeviceInterface.SmartDevice_Search() == SmartDeviceInterface.OPERATOR_SUCCESS)
     {
         UpdateMsg("广播数据:" + "{\"command\":\"COM_DEV_SEARCH_JS\"}");
         txtDeviceMgr.Text += "设备搜索成功\r\n";
     }
     else
     {
         txtDeviceMgr.Text += "设备搜索失败\r\n";
     }
 }
コード例 #8
0
        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("请选择设备");
            }
        }
コード例 #9
0
        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";
            }
        }
コード例 #10
0
        /// <summary>
        ///智能设备通用函数接口,实现设备管理、
        ///系统管理、凭证管理、车位管理、黑白名单管理、设备操控
        /// </summary>
        /// <param name="deviceID">4位厂商编号+4位主设备编号+12位MAC地址数(或者唯一编号)共20位</param>
        /// <param name="cmd">命令字</param>
        /// <param name="json">设备上传的json数据</param>
        /// <param name="len">设备上传的json数据长度</param>
        /// <param name="jsonResponse">返回给设备的json数据</param>
        /// <param name="lenResponse">返回给设备的json数据长度</param>
        /// <returns>返回操作结果码OPERATOR_</returns>
        public int SmartDevice_Common(string deviceID, UInt16 cmd, string strSend, int len, IntPtr jsonResponse) //, ref Int32 lenResponse
        {
            byte[] byteUTF8     = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend));
            int    iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH;
            IntPtr szResponse   = Marshal.AllocHGlobal(iResponseLen);

            return(SmartDeviceInterface.SmartDevice_Common(deviceID,
                                                           SmartDeviceInterface.COM_MANUAL_THROUGH_JS,
                                                           strSend,
                                                           byteUTF8.Length,
                                                           szResponse,
                                                           ref iResponseLen));
        }
コード例 #11
0
ファイル: MainFrm.cs プロジェクト: wyx1994/1111111
        //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";
            }
        }
コード例 #12
0
ファイル: SnapPictureFrm.cs プロジェクト: wyx1994/1111111
        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";
            }
        }
コード例 #13
0
ファイル: GateControlFrm.cs プロジェクト: wyx1994/1111111
        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";
            }
        }
コード例 #14
0
ファイル: MainFrm.cs プロジェクト: wyx1994/1111111
        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";
            }
        }
コード例 #15
0
ファイル: MainFrm.cs プロジェクト: wyx1994/1111111
        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("请选择设备");
            }
        }
コード例 #16
0
        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("请选择设备");
            }
        }
コード例 #17
0
        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";
            }
        }
コード例 #18
0
ファイル: MainFrm.cs プロジェクト: wyx1994/1111111
        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";
            }
        }
コード例 #19
0
        public int testMethod(int a, int b)
        {
            string strSend = "{\"data\":[{\"credenceNo\":\"\",\"userID\":\"\",\"userType\":1,\"throughType\":0,\"ledDisplayText\":\"\",\"speakText\":\"\"}],\"command\":\"COM_MANUAL_THROUGH_JS\"}";

            byte[] byteUTF8 = Encoding.Convert(Encoding.Default, Encoding.UTF8, UnicodeEncoding.Default.GetBytes(strSend));

            int    iResponseLen = SmartDeviceInterface.MAX_DATA_LENGTH;
            IntPtr szResponse   = Marshal.AllocHGlobal(iResponseLen);

            int iResult = SmartDeviceInterface.SmartDevice_Common("20001",
                                                                  SmartDeviceInterface.COM_MANUAL_THROUGH_JS,
                                                                  strSend, byteUTF8.Length,
                                                                  szResponse, ref iResponseLen);

            //Console.Write("iResult: " + iResult);
            //Console.Write("iResponseLen: " + iResponseLen);

            return(iResult);
        }
コード例 #20
0
ファイル: MainFrm.cs プロジェクト: wyx1994/1111111
        public SDK()
        {
            InitializeComponent();

            dtRecord.Columns.Add("deviceID");
            dtRecord.Columns.Add("onlineFlag");
            dtRecord.Columns.Add("recordTime");
            dtRecord.Columns.Add("recordType");
            dtRecord.Columns.Add("credenceType");
            dtRecord.Columns.Add("userID");
            dtRecord.Columns.Add("userType");
            dtRecord.Columns.Add("picture");
            dtRecord.Columns.Add("gateOpenMode");
            dtRecord.Columns.Add("credenceNo");
            dtRecord.Columns.Add("recCarNOColor");
            dtRecord.Columns.Add("carLogo");
            dtRecord.Columns.Add("carType");
            dtRecord.Columns.Add("deviceEntryType");
            dgvRecord.DataSource = dtRecord.DefaultView;

            dtEventRecord.Columns.Add("subDviceID");
            dtEventRecord.Columns.Add("eventType");
            dtEventRecord.Columns.Add("address");
            dtEventRecord.Columns.Add("time");
            dtEventRecord.Columns.Add("description");
            dtEventRecord.Columns.Add("picID");
            dgvEventRecord.DataSource = dtEventRecord.DefaultView;

            GloablInfo.sdk         = this;
            m_SmartDevice_CallBack = mySmartDevice_CallBack;
            SmartDeviceInterface.SmartDevice_SetCallBack(m_SmartDevice_CallBack);
            unsafe
            {
                m_SmartDeviceNeedResponse_CallBack = mySmartDeviceNeedResponse_CallBack;
            }
            SmartDeviceInterface.SmartDevice_SetNeedResponseCallBack(m_SmartDeviceNeedResponse_CallBack);
            m_SmartDeviceOffline_CallBack = mySmartDeviceOffline_CallBack;
            SmartDeviceInterface.SmartDevice_SetOfflineCallBack(m_SmartDeviceOffline_CallBack);
            //设计命令超时1000毫秒
            SmartDeviceInterface.SmartDevice_SetTimeOut(1000);
            //智能设备SDK初始化
            SmartDeviceInterface.SmartDevice_Init(20001, 0);
        }
コード例 #21
0
ファイル: MainFrm.cs プロジェクト: wyx1994/1111111
        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";
            }
        }
コード例 #22
0
ファイル: MainFrm.cs プロジェクト: wyx1994/1111111
        /// <summary>
        /// 更新设备树
        /// </summary>
        private void UpdateDeviceTreeImpl()
        {
            ClearAllNodes();

            tnRoot.Tag = "0";
            tvwDevice.Nodes.Add(tnRoot);
            lstNodes.Add(tnRoot);

            foreach (DeviceInfo di in GloablInfo.devMgr.lstDevs)
            {
                if (SmartDeviceInterface.SmartDevice_IsOnline(di.deviceID) ==
                    SmartDeviceInterface.OPERATOR_ONLINE)
                {
                    AddDeviceNode(di, 1);
                }
                else
                {
                    AddDeviceNode(di, 2);
                }
            }
            tnRoot.ExpandAll();
        }
コード例 #23
0
 /// <summary>
 ///设置设备超时毫秒数
 /// </summary>
 /// <param name="timeOut">超时毫秒数</param>
 /// <returns>无</returns>
 public void SmartDevice_SetTimeOut(Int32 timeOut)
 {
     SmartDeviceInterface.SmartDevice_SetTimeOut(timeOut);
 }
コード例 #24
0
 /// <summary>
 /// 智能设备SDK初始化
 /// </summary>
 /// <param name="tcpPort">TCP监听设备连接端口</param>
 /// <param name="logLevel">日志级别, 0 信息级别 1 警告级别 2 错误级别</param>
 /// <returns>初始化成功返回TRUE,失败返回false</returns>
 public bool SmartDevice_Init(UInt16 tcpPort, Int32 logLevel)
 {
     return(SmartDeviceInterface.SmartDevice_Init(tcpPort, logLevel));
 }
コード例 #25
0
 /// <summary>
 /// 智能设备SDK资源释放
 /// </summary>
 public void SmartDevice_Release()
 {
     SmartDeviceInterface.SmartDevice_Release();
 }
コード例 #26
0
 /// <summary>
 /// 智能设备SDK设置回调函数
 /// </summary>
 public void SmartDevice_SetCallBack(SmartDevice_CallBack CallBack)
 {
     SmartDeviceInterface.SmartDevice_SetCallBack(CallBack);
 }
コード例 #27
0
 /// <summary>
 /// 智能设备SDK设置需回应回调函数
 /// COM_DEV_REGISTER_JS 设备注册
 /// </summary>
 public void SmartDevice_SetNeedResponseCallBack(SmartDeviceNeedResponse_CallBack callback)
 {
     SmartDeviceInterface.SmartDevice_SetNeedResponseCallBack(callback);
 }
コード例 #28
0
 /// <summary>
 /// 智能设备SDK设置设备离线回调函数
 /// </summary>
 public void SmartDevice_SetOfflineCallBack(SmartDeviceOffline_CallBack callback)
 {
     SmartDeviceInterface.SmartDevice_SetOfflineCallBack(callback);
 }
コード例 #29
0
ファイル: SetParamFrm.cs プロジェクト: wyx1994/1111111
        //确认按钮
        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("请选择设备");
            }
        }
コード例 #30
0
ファイル: MainFrm.cs プロジェクト: wyx1994/1111111
 private void SDK_FormClosing(object sender, FormClosingEventArgs e)
 {
     //释放智能设备SDK资源
     SmartDeviceInterface.SmartDevice_Release();
 }