Пример #1
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("请选择设备");
            }
        }
Пример #2
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 += "请选择设备";
            }
        }
Пример #3
0
        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("请选择设备");
            }
        }
Пример #4
0
        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
        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";
            }
        }
Пример #6
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("请选择设备");
            }
        }
Пример #7
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));
        }
Пример #8
0
        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";
            }
        }
Пример #9
0
        //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";
            }
        }
Пример #10
0
        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";
            }
        }
Пример #11
0
        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";
            }
        }
Пример #12
0
        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("请选择设备");
            }
        }
Пример #13
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";
            }
        }
Пример #14
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("请选择设备");
            }
        }
Пример #15
0
        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";
            }
        }
Пример #16
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);
        }
Пример #17
0
        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";
            }
        }
Пример #18
0
        //确认按钮
        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("请选择设备");
            }
        }