public static string ReadDeviceUID(int devhandle)
        {
            IntPtr errmsg = new IntPtr();

            errmsg = Marshal.AllocHGlobal(0x400);
            string str = null;

            lnk_sdk_interface.LNX_SDK_Interface_X64.DeviceInfoStruct data = new lnk_sdk_interface.LNX_SDK_Interface_X64.DeviceInfoStruct();
            DevInstanceMgr.SEQInfo info = new DevInstanceMgr.SEQInfo();
            int    seq  = lnk_sdk_interface.LNX_SDK_Interface_X64.read_device_info(nethandle, devhandle, 300, 3, m_send_read_device_info_callback_def, errmsg);
            string str2 = Marshal.PtrToStringAnsi(errmsg);

            Marshal.FreeHGlobal(errmsg);
            if (seq == -1)
            {
                return(str);
            }
            int num2 = 10;

            while (num2-- > 0)
            {
                info = DevInstanceMgr.SEQFindInfo(seq);
                if (info != null)
                {
                    data = (lnk_sdk_interface.LNX_SDK_Interface_X64.DeviceInfoStruct)info.Data;
                    break;
                }
                Thread.Sleep(100);
            }
            return(new string(data.uid));
        }
        public static bool UnInitialize()
        {
            IntPtr errmsg = new IntPtr();

            if (DevInstanceMgr.lsDevInfoIsNULL())
            {
                return(true);
            }
            bool flag = true;

            if (UnInitializeFlag)
            {
                return(UnInitializeSucceFlag);
            }
            if (lnk_sdk_interface.LNX_SDK_Interface_X64.close_comm_interface(nethandle, errmsg) < 0)
            {
                flag = false;
                UnInitializeSucceFlag = false;
                return(flag);
            }
            if (lnk_sdk_interface.LNX_SDK_Interface_X64.start_application() != 0)
            {
                flag = false;
                UnInitializeSucceFlag = false;
                return(flag);
            }
            UnInitializeFlag      = true;
            UnInitializeSucceFlag = true;
            InitializeFlag        = false;
            InitializeSucceFlag   = false;
            return(flag);
        }
        public static string[] ReadDeviceInfo(int devhandle)
        {
            IntPtr errmsg = new IntPtr();

            errmsg = Marshal.AllocHGlobal(0x400);
            List <string> list = new List <string>();

            string[] strArray = null;
            lnk_sdk_interface.LNX_SDK_Interface_X64.DeviceInfoStruct data = new lnk_sdk_interface.LNX_SDK_Interface_X64.DeviceInfoStruct();
            DevInstanceMgr.SEQInfo info = new DevInstanceMgr.SEQInfo();
            int    seq = lnk_sdk_interface.LNX_SDK_Interface_X64.read_device_info(nethandle, devhandle, 300, 3, m_send_read_device_info_callback_def, errmsg);
            string str = Marshal.PtrToStringAnsi(errmsg);

            Marshal.FreeHGlobal(errmsg);
            if (seq == -1)
            {
                return(strArray);
            }
            int num2 = 10;

            while (num2-- > 0)
            {
                info = DevInstanceMgr.SEQFindInfo(seq);
                if (info != null)
                {
                    data = (lnk_sdk_interface.LNX_SDK_Interface_X64.DeviceInfoStruct)info.Data;
                    break;
                }
                Thread.Sleep(100);
            }
            list.Add(new string(data.hardname));
            list.Add(new string(data.softver));
            list.Add(new string(data.macaddr));
            return(list.ToArray());
        }
Exemplo n.º 4
0
 public static string[] GetDeviceInfo(string ip)
 {
     string[] strArray = null;
     if (DevInstanceMgr.dicIPDevInfo.ContainsKey(ip) && !DevInstanceMgr.dicIPDevInfo[ip].conState)
     {
         return(strArray);
     }
     return(LNX_SDK_Operation_X86.ReadDeviceInfo(DevInstanceMgr.DevFindDevHandle(ip)));
 }
Exemplo n.º 5
0
 public static bool UnInitialize(string ip)
 {
     if (DevInstanceMgr.DevSetDevCnt(ip, 2))
     {
         return(true);
     }
     DevInstanceMgr.DevRemoveByDevIP(ip);
     return(LNX_SDK_Operation_X86.UnInitialize());
 }
        public static bool CloseDev(string ip)
        {
            int    handle = DevInstanceMgr.DevFindDevHandle(ip);
            IntPtr errmsg = new IntPtr();

            if (lnk_sdk_interface.LNX_SDK_Interface_X64.close_device(handle, errmsg) < 0)
            {
                return(false);
            }
            return(true);
        }
        private static int default_send_callback_defPro(int nethandle, int devhandle, int sendid, int sendstatus, IntPtr errmsg)
        {
            string str = Marshal.PtrToStringAnsi(errmsg);

            if (sendstatus != -10)
            {
                DevInstanceMgr.SEQInfo sEQInfo = new DevInstanceMgr.SEQInfo {
                    SEQ = sendid
                };
                DevInstanceMgr.SEQAdd(sEQInfo);
            }
            return(0);
        }
        private static int send_read_device_info_callback_defPro(int nethandle, int devhandle, int sendid, int sendstatus, IntPtr errmsg, IntPtr devinfo)
        {
            string str = Marshal.PtrToStringAnsi(errmsg);

            if (sendstatus != -10)
            {
                lnk_sdk_interface.LNX_SDK_Interface_X64.DeviceInfoStruct struct2 = (lnk_sdk_interface.LNX_SDK_Interface_X64.DeviceInfoStruct)Marshal.PtrToStructure(devinfo, typeof(lnk_sdk_interface.LNX_SDK_Interface_X64.DeviceInfoStruct));
                DevInstanceMgr.SEQInfo sEQInfo = new DevInstanceMgr.SEQInfo {
                    SEQ  = sendid,
                    Data = struct2
                };
                DevInstanceMgr.SEQAdd(sEQInfo);
            }
            return(0);
        }
Exemplo n.º 9
0
        public static bool Initialize(string ip, int m_port, string userName, string passWord)
        {
            bool flag = false;

            if (DevInstanceMgr.DevSetDevCnt(ip, 1))
            {
                return(true);
            }
            flag = LNX_SDK_Operation_X86.Initialize();
            if (flag)
            {
                DevInstanceMgr.DevAdd(1, ip, m_port);
            }
            return(flag);
        }
Exemplo n.º 10
0
        public static bool DisConnect(string ip)
        {
            bool flag = false;

            if (DevInstanceMgr.DevSetConCnt(ip, 2))
            {
                return(true);
            }
            flag = LNX_SDK_Operation_X86.CloseDev(ip);
            if (flag && DevInstanceMgr.DevSetConState(false, -1, ip))
            {
                flag = true;
            }
            return(flag);
        }
Exemplo n.º 11
0
 public static bool SendCommand(string ip, int command)
 {
     if (DevInstanceMgr.dicIPDevInfo.ContainsKey(ip))
     {
         if (!DevInstanceMgr.dicIPDevInfo[ip].conState)
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
     return(LNX_SDK_Operation_X86.BarrierSend(DevInstanceMgr.DevFindDevHandle(ip), command));
 }
Exemplo n.º 12
0
        public static bool Connect(string m_ip)
        {
            bool flag = false;

            if (DevInstanceMgr.DevSetConCnt(m_ip, 1))
            {
                return(true);
            }
            int devhandle = LNX_SDK_Operation_X86.CreateDev(m_ip, DevInstanceMgr.DevFindDevPort(m_ip));

            if ((devhandle >= 0) && DevInstanceMgr.DevSetConState(true, devhandle, m_ip))
            {
                flag = true;
            }
            return(flag);
        }
        public static bool BarrierSend(int devhandle, int command)
        {
            IntPtr errmsg = new IntPtr();
            bool   flag   = true;
            int    seq    = -1;

            if (command == 2)
            {
                seq = lnk_sdk_interface.LNX_SDK_Interface_X64.stop_gate(nethandle, devhandle, 300, 3, m_default_send_callback_def, errmsg, 500);
                if (seq == -1)
                {
                    return(false);
                }
            }
            if (command == 1)
            {
                seq = lnk_sdk_interface.LNX_SDK_Interface_X64.open_gate(nethandle, devhandle, 300, 3, m_default_send_callback_def, errmsg, 500);
                if (seq == -1)
                {
                    return(false);
                }
            }
            if (command == 0)
            {
                seq = lnk_sdk_interface.LNX_SDK_Interface_X64.close_gate(nethandle, devhandle, 300, 3, m_default_send_callback_def, errmsg, 500);
                if (seq == -1)
                {
                    return(false);
                }
            }
            int num2 = 10;

            while (num2-- > 0)
            {
                if (DevInstanceMgr.SEQIsFind(seq))
                {
                    return(true);
                }
                Thread.Sleep(100);
                flag = false;
            }
            return(flag);
        }
        private static void DeviceStatusCallBackPro(int nethandle, int devhandle, int alive_status, int status_handle)
        {
            string ip = string.Empty;

            ip = DevInstanceMgr.DevFindDevIP(devhandle);
            DeviceStateChangedEventArgs args = new DeviceStateChangedEventArgs(alive_status, ip);

            if (DevInstanceMgr.dicIPDevInfo.ContainsKey(ip))
            {
                if (DevInstanceMgr.dicIPDevInfo[ip].type == 1)
                {
                    LNK_BARRIER_ISDK_X64.ExuteDelegate(1, args);
                }
                if (DevInstanceMgr.dicIPDevInfo[ip].type == 2)
                {
                    LNK_LED_ISDK_X64.ExuteDelegate(1, args);
                }
            }
        }
Exemplo n.º 15
0
        public static bool SendCommand(LED_PARAMETER_STRUCT param)
        {
            bool flag = false;

            if (param.Msg == null)
            {
                return(flag);
            }
            if (DevInstanceMgr.dicIPDevInfo.ContainsKey(param.ip))
            {
                if (!DevInstanceMgr.dicIPDevInfo[param.ip].conState)
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
            return(LNX_SDK_Operation_X86.LEDSend(DevInstanceMgr.DevFindDevHandle(param.ip), param));
        }
        public static bool VoiceSend(int devhandle, VOICE_PARAMETER_STRUCT param)
        {
            bool   flag   = true;
            IntPtr errmsg = new IntPtr();
            int    seq    = lnk_sdk_interface.LNX_SDK_Interface_X64.voice_cmd(nethandle, devhandle, 300, 3, m_default_send_callback_def, errmsg, param.volume, param.content, 1);

            if (seq == -1)
            {
                return(false);
            }
            int num2 = 10;

            while (num2-- > 0)
            {
                if (DevInstanceMgr.SEQIsFind(seq))
                {
                    return(true);
                }
                Thread.Sleep(100);
                flag = false;
            }
            return(flag);
        }
Exemplo n.º 17
0
 public static bool VoviceSend(VOICE_PARAMETER_STRUCT param)
 {
     return(LNX_SDK_Operation_X86.VoiceSend(DevInstanceMgr.DevFindDevHandle(param.ip), param));
 }
Exemplo n.º 18
0
 public static bool SetDeviceInfo(ROADGATE_NETCONFIG_STRUCT param)
 {
     return(LNX_SDK_Operation_X86.ModifyDeviceInfo(DevInstanceMgr.DevFindDevHandle(param.srcip), param.deviceName, param.desip, param.port, param.mac));
 }
 public static void SEQOutTimeRemovePro(object obj)
 {
     DevInstanceMgr.RemoveOutTimeSeqPro();
 }
        private static unsafe int gate_event_callbackPro(int nethandle, int devhandle, int gate_id, IntPtr pevent, int event_cnt, int event_handle)
        {
            int num;
            DataArrivedEventArgs args;
            ROADGATE_INFO_STRUCT roadgate_info_struct = new ROADGATE_INFO_STRUCT();

            if (devhandle >= 0)
            {
                byte[] source      = new byte[] { 0, 4, 0, 0 };
                IntPtr ptr         = Marshal.AllocHGlobal(0x400);
                IntPtr valuetype   = Marshal.AllocHGlobal(4);
                IntPtr destination = Marshal.AllocHGlobal(4);
                Marshal.Copy(source, 0, destination, 4);
                lnk_sdk_interface.LNX_SDK_Interface_X64.read_device_handle(devhandle, 3, valuetype, ptr, destination);
                num = Marshal.ReadInt32(destination);
                byte[] buffer2 = new byte[num];
                Marshal.Copy(ptr, buffer2, 0, num);
                roadgate_info_struct.ip = Encoding.Default.GetString(buffer2).Trim();
                Marshal.FreeHGlobal(ptr);
                Marshal.FreeHGlobal(valuetype);
                Marshal.FreeHGlobal(destination);
            }
            if (event_cnt > 0)
            {
                int[] numArray = new int[event_cnt];
                Marshal.Copy(pevent, numArray, 0, event_cnt);
                for (int i = 0; i < event_cnt; i++)
                {
                    DeviceMonitorEventArgs args2;
                    if ((numArray[i] == 4) || (numArray[i] == 5))
                    {
                        roadgate_info_struct.isManual = true;
                        args = new DataArrivedEventArgs(roadgate_info_struct);
                        LNK_BARRIER_ISDK_X64.ExuteDelegate(3, args);
                    }
                    if (numArray[i] == 14)
                    {
                        args2           = DevInstanceMgr.DevFindDeviceMonitorEventArgs(roadgate_info_struct.ip);
                        args2.IP        = roadgate_info_struct.ip;
                        args2.IsPressed = true;
                        LNK_BARRIER_ISDK_X64.ExuteDelegate(2, args2);
                    }
                    if (numArray[i] == 15)
                    {
                        args2           = DevInstanceMgr.DevFindDeviceMonitorEventArgs(roadgate_info_struct.ip);
                        args2.IP        = roadgate_info_struct.ip;
                        args2.IsPressed = false;
                        LNK_BARRIER_ISDK_X64.ExuteDelegate(2, args2);
                    }
                    if (numArray[i] == 0x18)
                    {
                        args2       = DevInstanceMgr.DevFindDeviceMonitorEventArgs(roadgate_info_struct.ip);
                        args2.IP    = roadgate_info_struct.ip;
                        args2.State = 0;
                        LNK_BARRIER_ISDK_X64.ExuteDelegate(2, args2);
                    }
                    if (numArray[i] == 0x1c)
                    {
                        args2       = DevInstanceMgr.DevFindDeviceMonitorEventArgs(roadgate_info_struct.ip);
                        args2.IP    = roadgate_info_struct.ip;
                        args2.State = 1;
                        LNK_BARRIER_ISDK_X64.ExuteDelegate(2, args2);
                    }
                }
            }
            if (event_handle >= 0)
            {
                int num4;
                int num3 = 0;
                num = 4;
                if ((lnk_sdk_interface.LNX_SDK_Interface_X64.read_gate_event(nethandle, devhandle, gate_id, event_handle, 11, &num3, (void *)&num4, &num) == 0) && ((num3 == 1) && (num == 4)))
                {
                    roadgate_info_struct.Counter = num4;
                    args = new DataArrivedEventArgs(roadgate_info_struct);
                    LNK_BARRIER_ISDK_X64.ExuteDelegate(3, args);
                }
            }
            return(0);
        }
        public static bool LEDSend(int devhandle, LED_PARAMETER_STRUCT param)
        {
            IntPtr errmsg   = new IntPtr();
            bool   flag     = true;
            string ledtext  = string.Empty;
            int    staytime = -1;
            int    loopcnt  = -1;
            int    seq      = -1;

            if (param.Msg != null)
            {
                int num7;
                if ((param.Msg.Length + param.rowIndex) > 5)
                {
                    staytime          = ((4 - param.rowIndex) + 1) * 0x5dc;
                    loopcnt           = -1;
                    param.displayMode = 12;
                    ledtext           = string.Empty;
                    foreach (string str2 in param.Msg)
                    {
                        char[]        chArray = str2.ToArray <char>();
                        StringBuilder builder = new StringBuilder();
                        for (int i = 0; i < chArray.Length; i++)
                        {
                            string str4;
                            int    length;
                            int    num6;
                            builder.Append(chArray[i]);
                            if (Encoding.Default.GetBytes(builder.ToString()).Length == 8)
                            {
                                str4    = builder.ToString();
                                ledtext = ledtext + str4;
                                builder.Clear();
                            }
                            if (Encoding.Default.GetBytes(builder.ToString()).Length > 8)
                            {
                                builder.Remove(builder.Length - 1, 1);
                                str4    = builder.ToString();
                                length  = Encoding.Default.GetBytes(str4).Length;
                                num6    = 8 - length;
                                str4    = str4.PadRight(num6 + str4.Length, ' ');
                                ledtext = ledtext + str4;
                                builder.Clear();
                                builder.Append(chArray[i]);
                            }
                            if (i == (chArray.Length - 1))
                            {
                                str4 = builder.ToString();
                                if (str4 != "")
                                {
                                    length  = Encoding.Default.GetBytes(str4).Length;
                                    num6    = 8 - length;
                                    str4    = str4.PadRight(num6 + str4.Length, ' ');
                                    ledtext = ledtext + str4;
                                    builder.Clear();
                                }
                            }
                        }
                    }
                    seq = lnk_sdk_interface.LNX_SDK_Interface_X64.led_show(nethandle, devhandle, 300, 3, m_default_send_callback_def, errmsg, param.rowIndex, param.fontColor, param.displayMode, staytime, loopcnt, ledtext, 0);
                    if (seq == -1)
                    {
                        return(false);
                    }
                    num7 = 10;
                    while (num7-- > 0)
                    {
                        if (DevInstanceMgr.SEQIsFind(seq))
                        {
                            return(true);
                        }
                        Thread.Sleep(100);
                        flag = false;
                    }
                    return(flag);
                }
                foreach (string str2 in param.Msg)
                {
                    ledtext = str2;
                    seq     = lnk_sdk_interface.LNX_SDK_Interface_X64.led_show(nethandle, devhandle, 300, 3, m_default_send_callback_def, errmsg, param.rowIndex++, param.fontColor, param.displayMode, staytime, loopcnt, ledtext, 0);
                    if (seq == -1)
                    {
                        return(false);
                    }
                    num7 = 10;
                    while (num7-- > 0)
                    {
                        if (DevInstanceMgr.SEQIsFind(seq))
                        {
                            flag = true;
                            break;
                        }
                        Thread.Sleep(100);
                        flag = false;
                    }
                }
            }
            return(flag);
        }