comparison Discovery/Src/logbook.c @ 610:ae7f8333c900

Added access to logbook marker data: In previous version event data could only be stored in memory but read back and usage in the OSTC itself was not supported. After the events like a marker set by the diver may be retrieved from the log. Added visualization of markers to T3_Profile view
author Ideenmodellierer
date Thu, 14 Jan 2021 20:38:28 +0100
parents b33a8c1c72e5
children 4eba86129d35
comparison
equal deleted inserted replaced
609:1b243c6c7067 610:ae7f8333c900
677 * @param int32_t* sensor1, sensor2, sensor3: output Value 677 * @param int32_t* sensor1, sensor2, sensor3: output Value
678 * @param int32_t* cns: output Value 678 * @param int32_t* cns: output Value
679 * @return bytes read / 0 = reading Error 679 * @return bytes read / 0 = reading Error
680 */ 680 */
681 static uint16_t readSample(int32_t* depth, int16_t * gasid, int16_t* setpoint_cbar, int32_t* temperature, int32_t* sensor1, int32_t* sensor2, 681 static uint16_t readSample(int32_t* depth, int16_t * gasid, int16_t* setpoint_cbar, int32_t* temperature, int32_t* sensor1, int32_t* sensor2,
682 int32_t* sensor3, int32_t* cns, SManualGas* manualGas, int16_t* bailout, int16_t* decostopDepth, uint16_t* tank) 682 int32_t* sensor3, int32_t* cns, SManualGas* manualGas, int16_t* bailout, int16_t* decostopDepth, uint16_t* tank, uint8_t* event)
683 { 683 {
684 int length = 0; 684 int length = 0;
685 _Bool bEvent = 0; 685 _Bool bEvent = 0;
686 bit8_Type eventByte1, eventByte2; 686 bit8_Type eventByte1, eventByte2;
687 bit8_Type profileByteFlag; 687 bit8_Type profileByteFlag;
736 ext_flash_read_next_sample_part( &eventByte1.uw, 1); 736 ext_flash_read_next_sample_part( &eventByte1.uw, 1);
737 bytesRead ++; 737 bytesRead ++;
738 738
739 length--; 739 length--;
740 740
741 /* marker */
742 if(eventByte1.ub.bit1 && eventByte1.ub.bit2 && event != NULL)
743 {
744 *event = 1;
745 }
746
741 //second event byte 747 //second event byte
742 if(eventByte1.ub.bit7) 748 if(eventByte1.ub.bit7)
743 { 749 {
744 ext_flash_read_next_sample_part( &eventByte2.uw, 1); 750 ext_flash_read_next_sample_part( &eventByte2.uw, 1);
745 bytesRead ++; 751 bytesRead ++;
746 length--; 752 length--;
747 } 753 }
748 else 754 else
749 { 755 {
750 eventByte2.uw = 0; 756 eventByte2.uw = 0;
751 } 757 }
752 758
753 //manual Gas Set 759 //manual Gas Set
754 if( eventByte1.ub.bit4) 760 if( eventByte1.ub.bit4)
755 { 761 {
756 //Evaluate manual Gas 762 //Evaluate manual Gas
757 ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1); 763 ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1);
758 bytesRead +=1; 764 bytesRead +=1;
759 length -= 1; 765 length -= 1;
760 manualGas->percentageO2 = tempU8; 766 manualGas->percentageO2 = tempU8;
761 ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1); 767 ext_flash_read_next_sample_part( (uint8_t*)&tempU8, 1);
762 bytesRead +=1; 768 bytesRead +=1;
763 length -= 1; 769 length -= 1;
764 manualGas->percentageHe = tempU8; 770 manualGas->percentageHe = tempU8;
765 if(gasid) 771 if(gasid) *gasid = 0;
766 *gasid = 0;
767 } 772 }
768 //gas change 773 //gas change
769 if( eventByte1.ub.bit5) 774 if( eventByte1.ub.bit5)
770 { 775 {
771 ext_flash_read_next_sample_part( &tempU8, 1); 776 ext_flash_read_next_sample_part( &tempU8, 1);
942 * @param int32_t* cns : output array 947 * @param int32_t* cns : output array
943 * @return length of output 948 * @return length of output
944 */ 949 */
945 uint16_t logbook_readSampleData(uint8_t StepBackwards, uint16_t length,uint16_t* depth, uint8_t* gasid, int16_t* temperature, uint16_t* ppo2, 950 uint16_t logbook_readSampleData(uint8_t StepBackwards, uint16_t length,uint16_t* depth, uint8_t* gasid, int16_t* temperature, uint16_t* ppo2,
946 uint16_t* setpoint, uint16_t* sensor1, uint16_t* sensor2, uint16_t* sensor3, uint16_t* cns, uint8_t* bailout, 951 uint16_t* setpoint, uint16_t* sensor1, uint16_t* sensor2, uint16_t* sensor3, uint16_t* cns, uint8_t* bailout,
947 uint16_t* decostopDepth, uint16_t* tank) 952 uint16_t* decostopDepth, uint16_t* tank, uint8_t* event)
948 { 953 {
949 //Test read 954 //Test read
950 //SLogbookHeader header; 955 //SLogbookHeader header;
951 956
952 //logbook_getHeader(&header); 957 //logbook_getHeader(&header);
978 int32_t cnsLast = 0; 983 int32_t cnsLast = 0;
979 int16_t decostepDepthVal = 0; 984 int16_t decostepDepthVal = 0;
980 int16_t decostepDepthLast = 0; 985 int16_t decostepDepthLast = 0;
981 uint16_t tankVal = 0; 986 uint16_t tankVal = 0;
982 uint32_t small_profileLength = 0; 987 uint32_t small_profileLength = 0;
988 uint8_t eventdata;
983 989
984 SManualGas manualGasVal; 990 SManualGas manualGasVal;
985 SManualGas manualGasLast; 991 SManualGas manualGasLast;
986 manualGasLast.percentageO2 = 0; 992 manualGasLast.percentageO2 = 0;
987 manualGasLast.percentageHe = 0; 993 manualGasLast.percentageHe = 0;
1058 while ((bytesRead < totalNumberOfBytes) && (iNum < length)) 1064 while ((bytesRead < totalNumberOfBytes) && (iNum < length))
1059 { 1065 {
1060 ext_flash_set_entry_point(); 1066 ext_flash_set_entry_point();
1061 divisorBackup = divisor; 1067 divisorBackup = divisor;
1062 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, 1068 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal,
1063 &bailoutVal, &decostepDepthVal, &tankVal); 1069 &bailoutVal, &decostepDepthVal, &tankVal, &eventdata);
1064 1070
1065 if(retVal == 0) 1071 if(retVal == 0)
1066 { 1072 {
1067 //Error try to read again!!! 1073 //Error try to read again!!!
1068 ext_flash_reopen_read_sample_at_entry_point(); 1074 ext_flash_reopen_read_sample_at_entry_point();
1069 divisor = divisorBackup; 1075 divisor = divisorBackup;
1070 retVal = readSample(&depthVal,&gasidVal,&setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, 1076 retVal = readSample(&depthVal,&gasidVal,&setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal,
1071 &manualGasVal, &bailoutVal, &decostepDepthVal, &tankVal); 1077 &manualGasVal, &bailoutVal, &decostepDepthVal, &tankVal, &eventdata);
1072 1078
1073 if(retVal == 0) 1079 if(retVal == 0)
1074 break; 1080 break;
1075 } 1081 }
1076 bytesRead +=retVal; 1082 bytesRead +=retVal;
1186 sensor2[iNum] = (sensor2Val / 0xFFFF) & 0xFF; 1192 sensor2[iNum] = (sensor2Val / 0xFFFF) & 0xFF;
1187 if(sensor3) 1193 if(sensor3)
1188 sensor3[iNum] = (sensor3Val / 0xFFFF) & 0xFF; 1194 sensor3[iNum] = (sensor3Val / 0xFFFF) & 0xFF;
1189 iNum++; 1195 iNum++;
1190 counter = 0; 1196 counter = 0;
1197
1198 if(event)
1199 {
1200 event[iNum] = eventdata;
1201 eventdata = 0;
1202 }
1191 } 1203 }
1192 } 1204 }
1193 } 1205 }
1194 else 1206 else
1195 { 1207 {
1776 while (true) 1788 while (true)
1777 { 1789 {
1778 1790
1779 ext_flash_set_entry_point(); 1791 ext_flash_set_entry_point();
1780 divisorBackup = divisor; 1792 divisorBackup = divisor;
1781 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL); 1793 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL, NULL);
1782 if(retVal == 0) 1794 if(retVal == 0)
1783 { 1795 {
1784 //Error try to read again!!! 1796 //Error try to read again!!!
1785 ext_flash_reopen_read_sample_at_entry_point(); 1797 ext_flash_reopen_read_sample_at_entry_point();
1786 divisor = divisorBackup; 1798 divisor = divisorBackup;
1787 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL); 1799 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL, NULL);
1788 1800
1789 if(retVal == 0) 1801 if(retVal == 0)
1790 { 1802 {
1791 //Error try to read again!!! 1803 //Error try to read again!!!
1792 ext_flash_reopen_read_sample_at_entry_point(); 1804 ext_flash_reopen_read_sample_at_entry_point();
1793 divisor = divisorBackup; 1805 divisor = divisorBackup;
1794 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL); 1806 retVal = readSample(&depthVal,&gasidVal, &setPointVal, &temperatureVal, &sensor1Val, &sensor2Val, &sensor3Val, &cnsVal, &manualGasVal, &bailoutVal, NULL, NULL, NULL);
1795 1807
1796 if(retVal == 0) 1808 if(retVal == 0)
1797 { 1809 {
1798 ext_flash_reopen_read_sample_at_entry_point(); 1810 ext_flash_reopen_read_sample_at_entry_point();
1799 break; 1811 break;