Ejemplo n.º 1
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";
            }
        }
Ejemplo n.º 2
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";
            }
        }
Ejemplo n.º 3
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";
            }
        }
Ejemplo n.º 4
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";
            }
        }
Ejemplo n.º 5
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";
            }
        }