## 7 SMEP Algorithms
### AuxDataQueue Compression Algorithm
With these sensor data values and found absolute positions, _SensorDataRecovery_ procedure recovers the values of lost sensor data to the interpolated using _SensorDataLineInterplolation_ procedure described in the previous section. The more detailed algorithm is presented in Algorithm 6. The procedure, at first, finds the last zone of which the zone value is not zero (procedure line 3). The zones from the zone 0 to the non-zero-valued zone are the target zones for decompression and recovery. The zones with 0 as their value includes the original ground sensor data without any compression. Every sensor data in the 0 valued zones doesn't need any decompression and recovery at all but it just needs output for its value and absolute position. The algorithm pseudo code about this corresponds to the part from the procedure line 29 to 40. The pseudo codes that executes decompression and recovery for none zero-valued target zones are shown from procedure line 5 to 27. Each zone needs a base sensor data for the first decompression and recovery. The pseudo codes for determination of a base sensor data are shown from the procedure line 6 to 9. The base sensor data in the 0 th zone is _DataQueue[0]_ as \(S_{c,0}\) and its absolute address is 0 (procedure line 7), since \(S_{c,0}\) is always selected unconditionally in every compression. Meanwhile, the base sensor data for each target zones except the 0 th zone is the value and absolute position in _ZoneCompHistory_ to have in its previous zone the same number of compressions with the target zone (procedure line 8). In order to execute decompression and recovery on _DataQueue_ sensor data in each target zone with _DataQueue_, the procedure needs to know boundaries of _DataQueue_ space corresponding to the target zone. The lowest boundary is determined by the greatest boundary of the previous target zone. Hence, the procedure determines only the greatest boundary as shown from the procedure line 10 to 13. Then, the procedure proceeds decompression and recovery for all sensor data, repeatedly (from procedure line 15 to 21). During doing this, the procedure finds an absolute position of each new sensor data in _DataQueue_ through the _FindAbsolutePosition_ function (procedure line 17). Then, the procedure calls _SensorDataLineInterpolation_ with the values and absolute positions of two old and new sensor data so that each of lost sensor data between these two sensor data should be recovered to an line interpolated value and its absolute position and outputted (procedure line 18). The line interpolation needs two points. By the way, the last sensor data in each zone becomes one of two points as a partner of a previous or base sensor data but, in the next decompression and recovery, it needs a new partner for the line interpolation. So, the procedure uses as its new partner a sensor data of _ZoneCompHistory_ of which the value and absolute position had played a role as a base sensor data for the next zone (from the procedure line 22 to 25). Then, the procedure recovers and outputs the compressed and lost sensor data between the last sensor data and its partner by calling _SensorDataLineInterpolation_ (from the procedure line 26 to 29).