Method and apparatus for sensing online / offline status of device
By generating a compressed bitmap of device status and using an XOR operation, the problem of quickly sensing changes in the online and offline status of IoT devices is solved, achieving efficient device status monitoring.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- SUZHOU OPPLE LIGHTING
- Filing Date
- 2025-12-24
- Publication Date
- 2026-07-02
AI Technical Summary
Existing technologies suffer from inefficiency in rapidly sensing changes in the online and offline status of a large number of IoT devices within a short period of time.
By generating a compressed bitmap of device status, storing device status information using a Roaring Bitmap data structure, and comparing the bitmaps at two different times using an XOR operation, changes in device status can be detected.
It enables rapid and accurate sensing of changes in the online and offline status of devices, reduces the amount of data analysis, and improves the system's response speed and scalability.
Smart Images

Figure CN2025145109_02072026_PF_FP_ABST
Abstract
Description
Online and offline sensing methods and devices for equipment
[0001] Cross-reference of related applications
[0002] This application claims priority to Chinese patent application No. 2024119201792, filed on December 24, 2024, entitled “Method and Apparatus for Online and Offline Sensing of Devices”, which is incorporated herein by reference in its entirety. Technical Field
[0003] This application relates to the field of information processing technology, and in particular to a method and apparatus for online and offline sensing of devices. Background Technology
[0004] With the continuous development of IoT devices, more and more smart devices are beginning to connect to the IoT. For example, many lighting devices can also be connected to the IoT to control them through the network.
[0005] In related technologies, smart devices maintain a connection with the system through a heartbeat mechanism so that the system can sense the online and offline status of the devices. However, how to quickly sense changes in the online and offline status of a large number of devices in a short period of time remains an urgent problem to be solved. Summary of the Invention
[0006] This application provides a method and apparatus for sensing online and offline status of devices, which solves the problem in traditional technology of how to quickly sense changes in the online and offline status of a large number of devices in a short period of time.
[0007] This application provides a device online / offline sensing method, including:
[0008] Based on the online and offline status cache information of each access device at the first moment, a compressed bitmap of the status of the first access device is generated;
[0009] Obtain the online / offline status cache information of each access device at the current moment, and generate a second access device status compressed bitmap; wherein, the first moment is one device status scan cycle earlier than the current moment;
[0010] By performing an XOR operation, the compressed bitmaps of the first and second access device statuses are compared and analyzed to obtain the online and offline status of the access devices.
[0011] Optionally, before the step of generating a first access device status compressed bitmap based on the online / offline status cache information of each access device at the first moment, the method further includes:
[0012] Obtain device status information reported by each access device, and hash and cache the device status information in the memory data storage system through range routing;
[0013] The device status information of each memory data storage system is scanned to obtain online and offline status cache information from each device status information.
[0014] Optionally, the access device status compressed bitmap includes: a running container, a bitmap container, and an array container.
[0015] Optionally, generating a first access device status compressed bitmap based on the online / offline status cache information of each access device at the first moment includes:
[0016] If the data distribution of the online and offline status cache information at the first moment is a dense data distribution, the online and offline status cache information is stored in the bitmap container;
[0017] If the data distribution of the online and offline status cache information at the first moment is sparse, the online and offline status cache information is stored in the array container;
[0018] If the online / offline status cache information is continuous data at the first moment, the online / offline status cache information is stored in the running container.
[0019] Optionally, the step of comparing and analyzing the first and second access device status compressed bitmaps through an XOR operation to obtain the online / offline status of the access device includes:
[0020] The change is obtained by comparing the first and second access device state compressed bitmaps bit by bit using an XOR operation.
[0021] Based on the change amount, determine whether each access device corresponding to the bit has experienced an online / offline change.
[0022] Optionally, after obtaining the change by comparing the first access device state compressed bitmap and the second access device state compressed bitmap bitmap bit-by-bit through an XOR operation, the method further includes:
[0023] When the change is not zero, the current device is determined to be the target access device;
[0024] The changes in the target access device and its device identity information are written into the status change device message queue, and the status change device message queue is pushed to the service end according to a preset period.
[0025] This application also provides an online / offline sensing device, comprising:
[0026] The first generation module is configured to generate a compressed bitmap of the status of the first access device based on the online and offline status cache information of each access device at the first moment.
[0027] The second generation module is configured to obtain the online and offline status cache information of each access device at the current moment and generate a second access device status compressed bitmap; wherein, the first moment is earlier than the current moment by one device status scan cycle;
[0028] The sensing module is configured to compare and analyze the first access device status compressed bitmap and the second access device status compressed bitmap through an XOR operation to obtain the online and offline status of the access device.
[0029] Optionally, the device is further configured to:
[0030] Obtain device status information reported by each access device, and hash and cache the device status information in the memory data storage system through range routing;
[0031] The device status information of each memory data storage system is scanned to obtain online and offline status cache information from each device status information.
[0032] Optionally, the device is further configured to:
[0033] Based on the range mapping relationship, the target sharding unit corresponding to the device status information is determined in the memory data storage system.
[0034] The online and offline status cache information is obtained by performing a task scanning operation through the target shard unit and stored in the corresponding target shard unit.
[0035] Optionally, the device is further configured to:
[0036] If the data distribution of the online and offline status cache information at the first moment is a dense data distribution, the online and offline status cache information is stored in the bitmap container;
[0037] If the data distribution of the online and offline status cache information at the first moment is sparse, the online and offline status cache information is stored in the array container;
[0038] If the online / offline status cache information is continuous data at the first moment, the online / offline status cache information is stored in the running container.
[0039] Optionally, the device is further configured to:
[0040] The change is obtained by comparing the first and second access device state compressed bitmaps bit by bit using an XOR operation.
[0041] Based on the change amount, determine whether each access device corresponding to the bit has experienced an online / offline change.
[0042] Optionally, the device is further configured to:
[0043] When the change is not zero, the current device is determined to be the target access device;
[0044] The changes in the target access device and its device identity information are written into the status change device message queue, and the status change device message queue is pushed to the service end according to a preset period.
[0045] This application also provides an online / offline sensing device for lighting fixtures, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps of any of the above-described online / offline sensing methods for the device.
[0046] This application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the online / offline sensing method for the device as described above.
[0047] The device online / offline sensing method and apparatus provided in this application generate a first access device status compressed bitmap and a second access device status compressed bitmap based on the online / offline status cache information of each access device. The compressed bitmap data structure can efficiently store and process the status information of a large number of devices. Then, by periodically scanning and comparing the first access device status compressed bitmap and the second access device status compressed bitmap, the amount of data analysis can be effectively reduced, and the changes in the online / offline status of access devices can be quickly and accurately sensed. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in this application or conventional technology, the drawings used in the description of the embodiments or conventional technology will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0049] Figure 1 is a schematic flowchart of the online and offline sensing method for devices provided in an embodiment of this application;
[0050] Figure 2 is a schematic diagram of the compressed bitmap structure provided in an embodiment of this application;
[0051] Figure 3 is a framework diagram of the online and offline sensing services for devices provided in an embodiment of this application;
[0052] Figure 4 is a schematic diagram of the online and offline sensing device structure provided in the embodiment of this application;
[0053] Figure 5 is a schematic diagram of the structure of the electronic device provided in an embodiment of this application. Detailed Implementation
[0054] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0055] Figure 1 is a schematic flowchart of the online and offline sensing method for devices provided in an embodiment of this application. As shown in Figure 1, it includes:
[0056] Step 110: Generate a compressed bitmap of the status of the first access device based on the online and offline status cache information of each access device at the first moment;
[0057] In this application, online / offline service is a system for monitoring and managing the online status of devices. It can sense the online or offline status of devices in real time and take corresponding actions accordingly.
[0058] In this application, the access device can specifically refer to a device that accesses the Internet of Things through an access service, such as a lamp or a lamp control device.
[0059] In this application, the online / offline status cache information at the first moment refers to data about the online or offline status of the device collected and stored at the first moment. This information is obtained through communication between the device and the online / offline service.
[0060] In this application, after receiving the device status, the online and offline services cache this status information. The cache is typically located in memory for fast access and processing.
[0061] The compressed bitmaps in this application may specifically include roar bitmaps, word-aligned hybrid compressed bitmaps, COMPAX bitmaps, etc.
[0062] Specifically, this application utilizes the Roaring Bitmap data structure to generate bitmaps. Roaring Bitmap is an efficient method for compressing bitmap representations, particularly suitable for bitmap operations on large-scale datasets.
[0063] Specifically, a unique bit position can be assigned to each device, and the value of this bit can be set according to the device's online / offline status (1 indicates online, 0 indicates offline). Based on the data distribution characteristics, the most suitable container type (BitmapContainer, ArrayContainer, RunContainer) will be automatically selected to store the bitmap, thereby optimizing the use of storage space.
[0064] Step 120: Obtain the online and offline status cache information of each access device at the current moment, and generate a second access device status compressed bitmap; wherein, the first moment is one device status scan cycle earlier than the current moment;
[0065] In this application, the device status scan cycle refers to the time interval at which the system periodically checks the online status of devices. This cycle can be a few minutes, a few hours, or any other time length suitable for the system's needs. At the beginning of each scan cycle, the system collects the current status of all devices and compares it with the status of the previous scan cycle.
[0066] At the beginning of each scan cycle, i.e., the first moment, the system records the online / offline status of all devices and generates a bitmap (first access device status compressed bitmap). At the current moment, the system again records the online / offline status of all devices and generates another bitmap (second access device status compressed bitmap).
[0067] Step 130: By performing an XOR operation, the first access device status compressed bitmap and the second access device status compressed bitmap are compared and analyzed to obtain the online and offline status of the access device.
[0068] In this application, by performing an XOR operation between the bitmap generated at the first moment and the bitmap generated at the current moment, devices whose states have changed between these two points in time can be detected. In the result of the XOR operation, a bit with a value of 1 indicates that the device state has changed (from online to offline, or from offline to online). The online / offline status of the accessed device is thus obtained.
[0069] In this application, access devices refer to those devices that are in a state during the monitoring period.
[0070] The online / offline status can specifically refer to a change in online / offline status, or a unchanged online / offline status. The status of a call occurring online / offline specifically refers to a change from online to offline or from offline to online.
[0071] In this application, the status information of a large number of devices can be efficiently stored and processed by using a roaring bitmap data structure. Then, by periodically scanning and comparing the first access device status compressed bitmap with the second access device status compressed bitmap, the changes in the online and offline status of the access devices can be quickly and accurately detected.
[0072] Optionally, before the step of generating a first access device status compressed bitmap based on the online / offline status cache information of each access device at the first moment, the method further includes:
[0073] Obtain device status information reported by each access device, and hash and cache the device status information in the memory data storage system through range routing;
[0074] The device status information of each memory data storage system is scanned to obtain online and offline status cache information from each device status information.
[0075] In this application, the in-memory data storage system may include Memcached and Redis, which are used as databases, caches, and message brokers.
[0076] In this application, each access device periodically or when its status changes, reports its status information to the access service. This information typically includes the device's unique identifier (such as a device ID) and its current online status (online or offline).
[0077] In this application, the access service uses range routing to hash and store device status information in an in-memory data storage system. Range routing is a data sharding strategy that distributes data to different in-memory data storage systems based on a range of device IDs.
[0078] Each in-memory data storage system is responsible for storing device status information within a certain range. This distributed storage can improve the parallelism and efficiency of data processing.
[0079] More specifically, the online and offline services scan the device status information of each memory data storage system to obtain the online and offline status cache information in each device status information.
[0080] To improve efficiency, scanning tasks can be fragmented, meaning each instance is only responsible for scanning a portion of the database in the in-memory data storage system. This allows for parallel data processing, accelerating the detection of online and offline status.
[0081] The online / offline service generates a compressed bitmap of the first access device status based on the scanned device status information. This bitmap is stored using a Roaring Bitmap data structure, where each bit represents the online or offline status of a device.
[0082] In this application, the status of a large number of devices can be managed and queried efficiently through range routing and in-memory data storage system.
[0083] Optionally, the step of obtaining the device status information reported by each access device and hashing and caching the device status information in the memory data storage system through range routing includes:
[0084] Based on the range mapping relationship, the target sharding unit corresponding to the device status information is determined in the memory data storage system.
[0085] The online and offline status cache information is obtained by performing a task scanning operation through the target shard unit and stored in the corresponding target shard unit.
[0086] In this application, the system determines the target sharding unit corresponding to the device status information in the memory data storage system based on the device status information and the preset range mapping relationship.
[0087] The range mapping relationship in this application is a logical correspondence rule used to quickly locate device status information to a specific storage location.
[0088] After identifying the target shard units, task scanning operations are performed through these units to collect and update the device's online / offline status cache information. Specifically, this involves reading the device status, analyzing changes, and comparing it with the previous status to determine whether the device has transitioned from online to offline.
[0089] In this application, the collected online and offline status cache information is then stored in the corresponding target shard unit to support rapid data updates and queries, thereby significantly improving the efficiency of data retrieval and updates.
[0090] This application also employs a compressed bitmap scheme, Roaring Bitmap, to further optimize data storage. Roaring Bitmap divides values into high 16 bits and low 16 bits using a bucketing method, and uses different containers to store data according to different data distributions, thereby greatly reducing the data storage space requirements while maintaining high performance.
[0091] Optionally, the access device status compressed bitmap includes: a running container, a bitmap container, and an array container.
[0092] Figure 2 is a schematic diagram of the compressed bitmap structure provided in the embodiment of this application. As shown in Figure 2, the Roaring Bitmap achieves efficient storage and retrieval by dividing the value into high 16 bits and low 16 bits.
[0093] The high 16 bits are used for bucketing, which divides the data into multiple buckets, each responsible for a relatively large range of values. The low 16 bits are used to store the specific value, i.e., the online / offline status of the device.
[0094] This bucketing mechanism allows Roaring Bitmap to select the most suitable storage method for each bucket, thereby optimizing the use of storage space.
[0095] Roaring Bitmap selects different container types to store data based on the data distribution characteristics in each bucket:
[0096] BitmapContainer: Suitable for densely distributed data, i.e., a bucket with a large number of online devices. BitmapContainer uses a long integer array to represent the bitmap, with each long integer storing 64 bits, suitable for situations with a large number of consecutive 1s.
[0097] ArrayContainer: Suitable for sparse data distribution, where only a small number of devices are online in a bucket. ArrayContainer uses a short integer array to store the positions of all bits that are 1, suitable for situations where the distribution of 1s is relatively scattered.
[0098] RunContainer: Suitable for situations where data is highly sequential, i.e., a bucket contains a large number of consecutive online devices. RunContainer uses a short integer array to store the starting position and length of consecutive 1s, suitable for situations with a large number of consecutive 1s.
[0099] Optionally, generating a first access device status compressed bitmap based on the online / offline status cache information of each access device at the first moment includes:
[0100] If the data distribution of the online and offline status cache information at the first moment is a dense data distribution, the online and offline status cache information is stored in the bitmap container;
[0101] If the data distribution of the online and offline status cache information at the first moment is sparse, the online and offline status cache information is stored in the array container;
[0102] If the online / offline status cache information is continuous data at the first moment, the online / offline status cache information is stored in the running container.
[0103] In this application, if the online / offline status cache information collected at the first moment shows that most devices are online, i.e., the data distribution is dense, the service stores the online / offline status cache information in a BitmapContainer.
[0104] The BitmapContainer uses a long integer array to represent a bitmap, with each long integer storing 64 bits. It is suitable for storing a large number of consecutive 1s, i.e., when most devices are online.
[0105] In this application, if the online and offline status cache information collected at the first moment shows that only a few devices are online, that is, the data distribution is sparse.
[0106] In this scenario, the service stores online / offline status cache information in an ArrayContainer. An ArrayContainer uses a short integer array to store the positions of all bits that are 1. This is suitable for storing a small number of scattered 1s, i.e., when only a few devices are online, thus saving storage space.
[0107] In this application, if the online / offline status cache information collected at the first moment shows that the device's online status is continuous, that is, there is a continuous period of time when the device is online, then the service will store the online / offline status cache information in the RunContainer.
[0108] RunContainer is a container that uses a short integer array to store the starting position and length of consecutive 1s. It is suitable for storing consecutive 1s, i.e., when there is a continuous range of devices online, thereby further reducing storage space usage.
[0109] In this application, Roaring Bitmap can adapt to various data distributions, achieving efficient storage and retrieval regardless of whether the dataset is dense or sparse. By selecting the most suitable container type based on the data distribution characteristics, Roaring Bitmap can significantly reduce storage space usage, especially in cases of uneven data distribution.
[0110] Optionally, the step of comparing and analyzing the first and second access device status compressed bitmaps through an XOR operation to obtain the online / offline status of the access device includes:
[0111] The change is obtained by comparing the first and second access device state compressed bitmaps bit by bit using an XOR operation.
[0112] Based on the change amount, determine whether each access device corresponding to the bit has experienced an online / offline change.
[0113] In this application, the XOR operation is a bitwise operation that compares two bits. If the two bits are the same (both are 0 or both are 1), the result is 0; if the two bits are different (one is 0 and the other is 1), the result is 1.
[0114] At the first and current moments, two bitmaps are generated: a compressed bitmap of the first access device status and a compressed bitmap of the second access device status. These two bitmaps represent the online and offline status of the device at two different points in time.
[0115] Perform an XOR operation on the two bitmaps. Specifically, compare each bit in the two bitmaps bit by bit. For example, if the bitmap at the first moment is 1010 and the bitmap at the current moment is 1100, then the result of the XOR operation will be 0110.
[0116] If the two bits being compared are the same (i.e., the XOR result is 0), it is determined that the access device corresponding to that bit has not undergone any online / offline changes.
[0117] If the two bits being compared are different (i.e., the XOR result is 1), it is determined that the access device corresponding to that bit has undergone an online / offline change.
[0118] In this application, the XOR operation allows for rapid detection of changes in device status without requiring individual checks on each device. This method enables real-time monitoring of device status changes, which is crucial for systems requiring rapid response.
[0119] Optionally, after obtaining the change by comparing the first access device state compressed bitmap and the second access device state compressed bitmap bitmap bit-by-bit through an XOR operation, the method further includes:
[0120] When the change is not zero, the current device is determined to be the target access device;
[0121] The changes in the target access device and its device identity information are written into the status change device message queue, and the status change device message queue is pushed to the service end according to a preset period.
[0122] In this application, devices whose states have changed (i.e., those with a non-zero change value) are identified from the XOR operation result. These devices are then determined to be target access devices, and their identity information (such as device ID) is extracted. This identity information is written into a dedicated state change device message queue. The message queue is a middleware used to transmit messages between different services or systems.
[0123] A preset period is set according to system requirements. This period can be real-time or at regular intervals (such as every minute or every hour). During each preset period, the system reads messages from the message queue and pushes status change information to the business side.
[0124] In this application, by writing the device identity information corresponding to the online / offline change access device into the status change device message queue and pushing the status change device message queue according to a preset period, the system can efficiently process and store the online / offline status of a large number of devices, while ensuring fast data access and system scalability.
[0125] Figure 3 is a framework diagram of the device online / offline sensing service provided in an embodiment of this application. As shown in Figure 3, each device (such as a lamp) will periodically or actively report its status (online or offline) to the system when its status changes. This is usually achieved through the device's built-in communication module, such as Wi-Fi, Bluetooth, or a dedicated IoT communication protocol.
[0126] The system's access service is responsible for receiving status information reported by devices. This service may run on a server or cloud platform and is responsible for handling all communication from devices. The access service hashes the status information from different devices and writes it to different Redis databases. Redis is a high-performance key-value store, ideally suited for storing and querying status information from large numbers of devices.
[0127] Redis offers a variety of data structures for storing state information, such as strings, hash tables, or bitmaps. Bitmaps are particularly well-suited for representing the online / offline status of a large number of devices.
[0128] The online / offline service periodically scans the Redis database for device status information. It compares the current status with previous states to detect changes (such as a device changing from online to offline). To improve query efficiency, the service may cache device status for faster response to query requests.
[0129] The device online / offline sensing device provided in this embodiment is described below. The device online / offline sensing device described below can be referred to in correspondence with the device online / offline sensing method described above.
[0130] Figure 4 is a schematic diagram of the online and offline sensing device structure provided in the embodiment of this application. As shown in Figure 4, it includes:
[0131] The first generation module 410 is configured to generate a compressed bitmap of the status of the first access device based on the online and offline status cache information of each access device at the first moment.
[0132] The second generation module 420 is configured to obtain the online and offline status cache information of each access device at the current time and generate a second access device status compressed bitmap; wherein, the first time is earlier than the current time by one device status scan cycle;
[0133] The sensing module 430 is configured to compare and analyze the first access device status compressed bitmap and the second access device status compressed bitmap through an XOR operation to obtain the online and offline status of the access device.
[0134] Optionally, the device is further configured to:
[0135] Obtain device status information reported by each access device, and hash and cache the device status information in the memory data storage system through range routing;
[0136] The device status information of each memory data storage system is scanned to obtain online and offline status cache information from each device status information.
[0137] Optionally, the device is further configured to:
[0138] Based on the range mapping relationship, the target sharding unit corresponding to the device status information is determined in the memory data storage system.
[0139] The online and offline status cache information is obtained by performing a task scanning operation through the target shard unit and stored in the corresponding target shard unit.
[0140] Optionally, the device is further configured to:
[0141] If the data distribution of the online and offline status cache information at the first moment is a dense data distribution, the online and offline status cache information is stored in the bitmap container;
[0142] If the data distribution of the online and offline status cache information at the first moment is sparse, the online and offline status cache information is stored in the array container;
[0143] If the online / offline status cache information is continuous data at the first moment, the online / offline status cache information is stored in the running container.
[0144] Optionally, the device is further configured to:
[0145] The change is obtained by comparing the first and second access device state compressed bitmaps bit by bit using an XOR operation.
[0146] Based on the change amount, determine whether each access device corresponding to the bit has experienced an online / offline change.
[0147] Optionally, the device is further configured to:
[0148] When the change is not zero, the current device is determined to be the target access device;
[0149] The changes in the target access device and its device identity information are written into the status change device message queue, and the status change device message queue is pushed to the service end according to a preset period.
[0150] In this application, a first access device status compressed bitmap and a second access device status compressed bitmap are generated based on the online and offline status cache information of each access device. The compressed bitmap data structure can efficiently store and process the status information of a large number of devices. Then, by periodically scanning and comparing the first access device status compressed bitmap and the second access device status compressed bitmap, the amount of data analysis can be effectively reduced, and the changes in the online and offline status of access devices can be quickly and accurately perceived.
[0151] Figure 5 is a schematic diagram of the electronic device provided in an embodiment of this application. As shown in Figure 5, the online / offline sensing device for lighting fixtures may include: a processor 510, a communication interface 520, a memory 530, and a communication bus 540. The processor 510, communication interface 520, and memory 530 communicate with each other via the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute an online / offline sensing method for the device. This method includes:
[0152] Based on the online and offline status cache information of each access device at the first moment, a compressed bitmap of the status of the first access device is generated;
[0153] Obtain the online / offline status cache information of each access device at the current moment, and generate a second access device status compressed bitmap; wherein, the first moment is one device status scan cycle earlier than the current moment;
[0154] By performing an XOR operation, the compressed bitmaps of the first and second access device statuses are compared and analyzed to obtain the online and offline status of the access devices.
[0155] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, essentially, or the part that contributes to conventional technology, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this embodiment. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0156] On the other hand, this embodiment also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when the program instructions are executed by a computer, the computer can execute the online and offline device sensing methods provided by the above methods, which include:
[0157] Based on the online and offline status cache information of each access device at the first moment, a compressed bitmap of the status of the first access device is generated;
[0158] Obtain the online / offline status cache information of each access device at the current moment, and generate a second access device status compressed bitmap; wherein, the first moment is one device status scan cycle earlier than the current moment;
[0159] By performing an XOR operation, the compressed bitmaps of the first and second access device statuses are compared and analyzed to obtain the online and offline status of the access devices.
[0160] In another aspect, this embodiment also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described online and offline sensing methods for devices, the method comprising:
[0161] Based on the online and offline status cache information of each access device at the first moment, a compressed bitmap of the status of the first access device is generated;
[0162] Obtain the online / offline status cache information of each access device at the current moment, and generate a second access device status compressed bitmap; wherein, the first moment is one device status scan cycle earlier than the current moment;
[0163] By performing an XOR operation, the compressed bitmaps of the first and second access device statuses are compared and analyzed to obtain the online and offline status of the access devices.
[0164] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0165] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to conventional technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0166] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this embodiment, and not to limit them; although this embodiment has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this embodiment.
Claims
1. A method for online and offline sensing of a device, comprising: Based on the online and offline status cache information of each access device at the first moment, a compressed bitmap of the status of the first access device is generated; Obtain the online / offline status cache information of each access device at the current moment, and generate a second access device status compressed bitmap; wherein, the first moment is one device status scan cycle earlier than the current moment; By performing an XOR operation, the compressed bitmaps of the first and second access device statuses are compared and analyzed to obtain the online and offline status of the access devices.
2. The online / offline sensing method for devices according to claim 1, wherein, Before the step of generating a first access device status compressed bitmap based on the online / offline status cache information of each access device at the first moment, the method further includes: Obtain device status information reported by each access device, and hash and cache the device status information in the memory data storage system through range routing; The device status information of each memory data storage system is scanned to obtain online and offline status cache information from each device status information.
3. The online / offline sensing method for devices according to claim 2, wherein, The step of obtaining device status information reported by each access device and hashing and caching the device status information in the memory data storage system through range routing includes: Based on the range mapping relationship, the target sharding unit corresponding to the device status information is determined in the memory data storage system. The online and offline status cache information is obtained by performing a task scanning operation through the target shard unit and stored in the corresponding target shard unit.
4. The online / offline sensing method for devices according to claim 1, wherein, The access device status compressed bitmap includes: a running container, a bitmap container, and an array container.
5. The online and offline sensing method for devices according to claim 4, wherein, The step of generating a compressed bitmap of the first access device status based on the online / offline status cache information of each access device at the first moment includes: If the data distribution of the online and offline status cache information at the first moment is a dense data distribution, the online and offline status cache information is stored in the bitmap container; If the data distribution of the online and offline status cache information at the first moment is sparse, the online and offline status cache information is stored in the array container; If the online / offline status cache information is continuous data at the first moment, the online / offline status cache information is stored in the running container.
6. The online and offline sensing method for devices according to claim 1, wherein, The step of comparing and analyzing the first and second access device status compressed bitmaps through an XOR operation to obtain the online / offline status of the access device includes: The change is obtained by comparing the first and second access device state compressed bitmaps bit by bit using an XOR operation. Based on the change amount, determine whether each access device corresponding to the bit has experienced an online / offline change.
7. The online and offline sensing method for devices according to claim 6, wherein, After obtaining the change by comparing the first access device state compressed bitmap and the second access device state compressed bitmap bitmap bit-by-bit through an XOR operation, the method further includes: When the change is not zero, the current device is determined to be the target access device; The changes in the target access device and its device identity information are written into the status change device message queue, and the status change device message queue is pushed to the service end according to a preset period.
8. An online / offline sensing device, comprising: The first generation module is configured to generate a compressed bitmap of the status of the first access device based on the online and offline status cache information of each access device at the first moment. The second generation module is configured to obtain the online and offline status cache information of each access device at the current moment and generate a second access device status compressed bitmap; wherein, the first moment is earlier than the current moment by one device status scan cycle; The sensing module is configured to compare and analyze the first access device status compressed bitmap and the second access device status compressed bitmap through an XOR operation to obtain the online and offline status of the access device.
9. A lighting fixture online / offline sensing device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the device online / offline sensing method as described in any one of claims 1 to 7.
10. A computer program product comprising a computer program that, when executed by a processor, implements the online / offline sensing method for a device as described in any one of claims 1 to 7.