an Aircraft can fly 13 hours. but the disk of Aircraft only can store the datas of 2 hours. when an Aircraft was down,we must get the last 2 hours datas for knowing what's happen. so, the datas of disk must be refreshed at everytime.
assumes:
an Aircraft creates about 2k datas at one second,there are 14400k datas between 2 hours.
for refreshing the datas, everytime we need to move the old 14398k datas for storing the new 2k datas. a lot of work is moving datas.
the following code simulates this case.
.386
.model flat,stdcall
option casemap:none
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\ws2_32.inc
include \masm32\include\debug.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\ws2_32.lib
includelib \masm32\lib\debug.lib
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include \masm32\macros\macros.asm
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.const
EditID equ 4
DATASIZEMAX equ 32
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.data
ClassName db "AircraftStorage",0
AppName db "TestStoreLogic",0
buffer db DATASIZEMAX*13+1 dup(0)
IndexOfData dd 0H
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hwndEdit HWND ?
FullBufFlag BOOL ?
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.code
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
iRand proc _dwMin:DWORD, _dwMax:DWORD
local @dwRet:dword, @dqFreq:qword
pushad
invoke QueryPerformanceCounter,addr @dqFreq
mov eax,dword ptr @dqFreq
mov ecx, 13
mul ecx
add eax, 5
mov ecx, _dwMax
sub ecx, _dwMin
inc ecx
xor edx, edx
div ecx
mov @dwRet, edx
popad
mov eax, @dwRet
add eax,_dwMin ; eax = Rand_Number
ret
iRand endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CenterScreen PROC USES esi edi hWnd:DWORD
LOCAL wRect:RECT
xor eax, eax
push eax
lea eax, DWORD PTR [ebp-16]
push eax
mov eax, hWnd
push eax
call GetWindowRect
mov esi, wRect.bottom
sub esi, wRect.top
push esi
shr esi, 1
mov edi, wRect.right
sub edi, wRect.left
push edi
shr edi, 1
mov eax, SM_CYSCREEN
push eax
call GetSystemMetrics
shr eax, 1
sub eax, esi
push eax
mov eax, SM_CXSCREEN
push eax
call GetSystemMetrics
shr eax, 1
sub eax, edi
push eax
mov eax, hWnd
push eax
call MoveWindow
ret
CenterScreen ENDP
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FullBuf_MovStorage PROC USES ebx esi edi pBufStorage:DWORD,pBufStorageSize:DWORD,pNewData:DWORD,pNewDataSize:dword
mov ebx,pNewDataSize
;old data out
mov edi,pBufStorage
mov esi,pBufStorage
add esi,ebx
mov ecx,pBufStorageSize
sub ecx,ebx
mov eax, ecx
shr ecx, 2
rep movsd
mov ecx, eax
and ecx, 3
rep movsb
;new data in
mov edi,pBufStorage
add edi,pBufStorageSize
sub edi,ebx
mov esi,pNewData
mov ecx,ebx
mov eax, ecx
shr ecx, 2
rep movsd
mov ecx, eax
and ecx, 3
rep movsb
ret
FullBuf_MovStorage ENDP
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WndProc proc uses ebx esi edi hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL rt:RECT
LOCAL tempbuf[32]:byte
LOCAL dwWritten:dword
mov eax,uMsg
.if eax==WM_CREATE
mov FullBufFlag,FALSE
invoke CenterScreen,hWnd
invoke CreateWindowEx,NULL, CTXT("RichEdit20A"),0,WS_CHILD or WS_VISIBLE or ES_MULTILINE \
or WS_VSCROLL or ES_NOHIDESEL,0,0,500,400,hWnd,EditID,hInstance,0
mov hwndEdit,eax
invoke SetTimer,hWnd,0,1000,0
.elseif eax==WM_TIMER
invoke iRand,0,15000
mov [tempbuf],0
invoke wsprintf,addr tempbuf, CTXT("%06d:","%05d,"),IndexOfData,eax
.if FullBufFlag == TRUE
invoke lstrlen,addr tempbuf
mov ecx,eax
invoke FullBuf_MovStorage,addr buffer,DATASIZEMAX*13,addr tempbuf,ecx
.else
invoke lstrcat,addr buffer,addr tempbuf
invoke lstrlen,addr buffer
.if eax>=DATASIZEMAX*13
mov FullBufFlag,TRUE
.endif
.endif
invoke SetWindowText,hwndEdit,addr buffer
inc IndexOfData
.elseif eax==WM_DESTROY
invoke KillTimer,hWnd,0
invoke PostQuitMessage,NULL
.elseif eax == WM_SIZE
invoke GetClientRect, hWnd, addr rt
mov eax,rt.right
sub eax,rt.left
mov ecx,rt.bottom
sub ecx,rt.top
invoke MoveWindow,hwndEdit,0,0,eax,ecx, TRUE
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszClassName,offset ClassName
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
invoke CreateWindowEx,WS_EX_CLIENTEDGE,addr ClassName,addr AppName,\
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,500,\
400,NULL,NULL,hInst,NULL
mov hwnd,eax
invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.while TRUE
invoke GetMessage, addr msg,NULL,0,0
.break .if (!eax)
invoke TranslateMessage, addr msg
invoke DispatchMessage, addr msg
.endw
mov eax,msg.wParam
ret
WinMain endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke LoadLibrary,CTXT("Riched20.dll")
push eax
invoke GetCommandLine
invoke WinMain, hInstance,NULL,eax, SW_SHOWDEFAULT
pop eax
invoke FreeLibrary,eax
invoke ExitProcess,NULL
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
end start
...
i haven't worked in that industry for 25 or 30 years
but, i can tell you that advances are made at a snails pace - lol
they are still using some of the stuff i worked on, even as far back as 1979
part of the reason is type-acceptance
once a method, component, or device has been approved, it tends to be used until forced out
that's because the approval cycles are long and expensive
for example, i happen to know that they are still using analog computers in a few places
old tech, 8-pin metal can 741 op-amps, and so on :P
as to the original question....
i would use a circular buffer, rather than continually moving the data
if you remember the BIOS data area at 40h, the keyboard buffer provides an example
they maintained "head" and "tail" pointers into the buffer
hi,vertograd
thanks for this information. :t
Quoteso you're speaking about voice data ?
"voice data" and "State Flight Datas"(et. Height/Speed/Pressure/Longitude/Latitude/Warninfo/Faultinfo...)
i take an attention on how they could be recorded.
Quoteavionics is a whole different world.
that's indeed.
hi,dedndave
thanks your help. :t
Quotei would use a circular buffer, rather than continually moving the data
if you remember the BIOS data area at 40h, the keyboard buffer provides an example
they maintained "head" and "tail" pointers into the buffer.
a few days passed. i solved the question on your guide.
here, thank you very much again.
i'll show up the codes in a moment.
edit:
recordedata
.386
.model flat,stdcall
option casemap:none
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\gdi32.inc
include \masm32\include\debug.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\debug.lib
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include \masm32\macros\macros.asm
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.const
EditID equ 4
DATASIZEMAX equ 64
DATASIZEONE equ 13
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AIRCRAFTDATASTT struct
g_HeadDataIndex dword ?
g_FullStoreFlag byte ?
g_StartUpTime SYSTEMTIME <?>
g_DataBuffer byte DATASIZEMAX*DATASIZEONE+1 dup(?)
AIRCRAFTDATASTT ends
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.data
ClassName db "AircraftStorage",0
AppName db "TestStoreLogic",0
hMapFile HANDLE 0
IndexOfData dd 0
IndexOfStoreData dd 0
dwDataPointer dd 0
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hFile HANDLE ?
hwndEdit HWND ?
pMemory DWORD ?
SizeWritten DWORD ?
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.code
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
iRand proc _dwMin:DWORD, _dwMax:DWORD
local @dwRet:dword, @dqFreq:qword
pushad
invoke QueryPerformanceCounter,addr @dqFreq
mov eax,dword ptr @dqFreq
mov ecx, 13
mul ecx
add eax, 5
mov ecx, _dwMax
sub ecx, _dwMin
inc ecx
xor edx, edx
div ecx
mov @dwRet, edx
popad
mov eax, @dwRet
add eax,_dwMin ; eax = Rand_Number
ret
iRand endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CenterScreen PROC USES esi edi hWnd:DWORD
LOCAL wRect:RECT
xor eax, eax
push eax
lea eax, DWORD PTR [ebp-16]
push eax
mov eax, hWnd
push eax
call GetWindowRect
mov esi, wRect.bottom
sub esi, wRect.top
push esi
shr esi, 1
mov edi, wRect.right
sub edi, wRect.left
push edi
shr edi, 1
mov eax, SM_CYSCREEN
push eax
call GetSystemMetrics
shr eax, 1
sub eax, esi
push eax
mov eax, SM_CXSCREEN
push eax
call GetSystemMetrics
shr eax, 1
sub eax, edi
push eax
mov eax, hWnd
push eax
call MoveWindow
ret
CenterScreen ENDP
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CloseMapFile PROC
invoke CloseHandle,hMapFile
mov hMapFile,0
invoke CloseHandle,hFile
ret
CloseMapFile endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
StoreNewData PROC USES ebx esi edi pBufStorage:DWORD,dwIndex:DWORD,pNewData:DWORD
mov edi,pBufStorage
mov esi,pNewData
mov ebx,DATASIZEONE
mov eax,dwIndex
mul ebx
add edi,eax
push eax
mov ecx,DATASIZEONE
mov eax, ecx
shr ecx, 2
rep movsd
mov ecx, eax
and ecx, 3
rep movsb
pop eax
ret
StoreNewData ENDP
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WndProc proc uses ebx esi edi hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL rt:RECT
LOCAL tempbuf[32]:byte
LOCAL dwWritten:dword
mov eax,uMsg
.if eax==WM_CREATE
invoke CenterScreen,hWnd
invoke CreateWindowEx,NULL, CTXT("RichEdit20A"),0,WS_CHILD or WS_VISIBLE or ES_MULTILINE \
or WS_VSCROLL or ES_NOHIDESEL,0,0,500,400,hWnd,EditID,hInstance,0
mov hwndEdit,eax
invoke CreateFont,36,26,20,20,FW_NORMAL,TRUE,FALSE,FALSE, \
ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, \
DEFAULT_QUALITY,DEFAULT_PITCH, CTXT("Courier New")
mov ecx, eax
invoke SendMessage,hwndEdit,WM_SETFONT,ecx, 0
invoke SetTimer,hWnd,0,1000,0
invoke CreateFile,CTXT("rundata1.txt"),GENERIC_READ or GENERIC_WRITE,FILE_SHARE_READ or FILE_SHARE_WRITE,\
NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL
mov hFile,eax
invoke CreateFileMapping,hFile,NULL,PAGE_READWRITE,0,0,NULL
mov hMapFile,eax
invoke MapViewOfFile,hMapFile,FILE_MAP_READ OR FILE_MAP_WRITE,0,0,0
mov pMemory,eax
lea esi,pMemory
mov (AIRCRAFTDATASTT Ptr [esi]).g_FullStoreFlag,FALSE
lea ecx,(AIRCRAFTDATASTT Ptr [esi]).g_StartUpTime
invoke GetLocalTime, ecx
invoke SetFilePointer,hFile,5,NULL,FILE_BEGIN
add esi,5
invoke WriteFile,hFile,esi,sizeof SYSTEMTIME,addr dwWritten, NULL
.elseif eax==WM_TIMER
invoke iRand,0,15000
mov [tempbuf],0
invoke wsprintf,addr tempbuf, CTXT("%06d:","%05d,"),IndexOfData,eax
lea esi,pMemory
mov eax,IndexOfStoreData
mov (AIRCRAFTDATASTT Ptr [esi]).g_HeadDataIndex,eax
.if eax>=DATASIZEMAX
mov IndexOfStoreData,0
mov (AIRCRAFTDATASTT Ptr [esi]).g_FullStoreFlag,TRUE
.endif
invoke SetFilePointer,hFile,NULL,NULL,FILE_BEGIN
mov ecx,5
invoke WriteFile,hFile,esi,ecx,addr dwWritten, NULL
lea edx,(AIRCRAFTDATASTT Ptr [esi]).g_DataBuffer
invoke StoreNewData,edx,IndexOfStoreData,addr tempbuf
mov dwDataPointer,eax
add eax,5
add eax,sizeof SYSTEMTIME
invoke SetFilePointer,hFile,eax,NULL,FILE_BEGIN
lea edx,(AIRCRAFTDATASTT Ptr [esi]).g_DataBuffer
add edx,dwDataPointer
mov ecx,DATASIZEONE
invoke WriteFile,hFile,edx,ecx,addr dwWritten, NULL
lea edx,(AIRCRAFTDATASTT Ptr [esi]).g_DataBuffer
invoke SetWindowText,hwndEdit,edx
inc IndexOfData
inc IndexOfStoreData
.elseif eax==WM_DESTROY
invoke UnmapViewOfFile,pMemory
.if hMapFile!=0
call CloseMapFile
.endif
invoke KillTimer,hWnd,0
invoke PostQuitMessage,NULL
.elseif eax == WM_SIZE
invoke GetClientRect, hWnd, addr rt
mov eax,rt.right
sub eax,rt.left
mov ecx,rt.bottom
sub ecx,rt.top
invoke MoveWindow,hwndEdit,0,0,eax,ecx, TRUE
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszClassName,offset ClassName
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
invoke CreateWindowEx,WS_EX_CLIENTEDGE,addr ClassName,addr AppName,\
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,500,\
400,NULL,NULL,hInst,NULL
mov hwnd,eax
invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.while TRUE
invoke GetMessage, addr msg,NULL,0,0
.break .if (!eax)
invoke TranslateMessage, addr msg
invoke DispatchMessage, addr msg
.endw
mov eax,msg.wParam
ret
WinMain endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke LoadLibrary,CTXT("Riched20.dll")
push eax
invoke GetCommandLine
invoke WinMain, hInstance,NULL,eax, SW_SHOWDEFAULT
pop eax
invoke FreeLibrary,eax
invoke ExitProcess,eax
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
end start
readData:
.386
.model flat,stdcall
option casemap:none
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\ws2_32.inc
include \masm32\include\debug.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\ws2_32.lib
includelib \masm32\lib\debug.lib
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include \masm32\macros\macros.asm
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.const
EditID equ 4
DATASIZEMAX equ 64
DATASIZEONE equ 13
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AIRCRAFTDATASTT struct
g_HeadDataIndex dword ?
g_FullStoreFlag byte ?
g_StartUpTime SYSTEMTIME <?>
g_DataBuffer byte DATASIZEMAX*DATASIZEONE+1 dup(?)
AIRCRAFTDATASTT ends
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.data
ClassName db "AircraftStorage",0
AppName db "TestStoreLogic",0
buffer db 1024 dup(0)
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
hFile HANDLE ?
hwndEdit HWND ?
pBuffer DWORD ?
SizeWritten DWORD ?
dqFileSize dq ?
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.code
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ErrorMessage Proc lpCaption:dword
Local lpErrorMessage:DWORD
call GetLastError
lea edx,lpErrorMessage
invoke FormatMessage, FORMAT_MESSAGE_ALLOCATE_BUFFER or FORMAT_MESSAGE_FROM_SYSTEM, NULL, EAX, LANG_NEUTRAL,EDX,0,NULL
invoke MessageBox,0, lpErrorMessage,lpCaption, MB_OK or MB_ICONERROR
invoke LocalFree, lpErrorMessage
ret
ErrorMessage EndP
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CenterScreen PROC USES esi edi hWnd:DWORD
LOCAL wRect:RECT
xor eax, eax
push eax
lea eax, DWORD PTR [ebp-16]
push eax
mov eax, hWnd
push eax
call GetWindowRect
mov esi, wRect.bottom
sub esi, wRect.top
push esi
shr esi, 1
mov edi, wRect.right
sub edi, wRect.left
push edi
shr edi, 1
mov eax, SM_CYSCREEN
push eax
call GetSystemMetrics
shr eax, 1
sub eax, esi
push eax
mov eax, SM_CXSCREEN
push eax
call GetSystemMetrics
shr eax, 1
sub eax, edi
push eax
mov eax, hWnd
push eax
call MoveWindow
ret
CenterScreen ENDP
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NoFullProcessingDataOrder PROC USES ebx esi edi pBufStorage:DWORD,dwIndex:DWORD,pNewBuf:DWORD
mov edi,pNewBuf
mov esi,pBufStorage
inc dwIndex
mov eax,dwIndex
mov ecx,13
mul ecx
mov ecx,eax
mov eax, ecx ;
shr ecx, 2
rep movsd
mov ecx, eax
and ecx, 3
rep movsb
ret
NoFullProcessingDataOrder ENDP
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FullProcessingDataOrder PROC USES ebx esi edi pBufStorage:DWORD,dwIndex:DWORD,pNewBuf:DWORD
mov edi,pNewBuf
mov esi,pBufStorage
mov ecx,DATASIZEMAX*13
inc dwIndex
mov eax,dwIndex
mov ebx,13
mul ebx
sub ecx,eax
add esi,eax
mov eax, ecx ;copy behind datas
shr ecx, 2
rep movsd
mov ecx, eax
and ecx, 3
rep movsb
mov esi,pBufStorage
mov eax,dwIndex
mov ebx,13
mul ebx
mov ecx,eax
mov eax, ecx ;copy Front datas
shr ecx, 2
rep movsd
mov ecx, eax
and ecx, 3
rep movsb
ret
FullProcessingDataOrder ENDP
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WndProc proc uses ebx esi edi hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL rt:RECT
LOCAL dwReadBytes:dword
LOCAL tempbuf[32]:BYTE
LOCAL dbuffer[32]:BYTE
LOCAL tbuffer[32]:BYTE
mov eax,uMsg
.if eax==WM_CREATE
invoke CenterScreen,hWnd
invoke CreateWindowEx,NULL, CTXT("RichEdit20A"),0,WS_CHILD or WS_VISIBLE or ES_MULTILINE \
or WS_VSCROLL or ES_NOHIDESEL,0,0,500,400,hWnd,EditID,hInstance,0
mov hwndEdit,eax
invoke CreateFile,CTXT("rundata1.txt"),GENERIC_READ,NULL,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL
.if eax==INVALID_HANDLE_VALUE
invoke ErrorMessage,CTXT("CreateFile")
ret
.endif
mov hFile,eax
invoke GetFileSizeEx,hFile,addr dqFileSize
mov eax,DWORD ptr dqFileSize
mov edx,DWORD ptr dqFileSize+4
invoke GlobalAlloc,GHND,eax
mov pBuffer,eax
invoke ReadFile,hFile,pBuffer,sizeof AIRCRAFTDATASTT,addr dwReadBytes, NULL
mov esi,pBuffer
invoke wsprintf,addr tempbuf, CTXT("Data-Index: %d",13,10),(AIRCRAFTDATASTT Ptr [esi]).g_HeadDataIndex
lea ecx,(AIRCRAFTDATASTT Ptr [esi]).g_StartUpTime
invoke GetDateFormat,LOCALE_USER_DEFAULT,NULL,ecx,CTXT("yyyy-MM-dd / "), addr dbuffer, sizeof dbuffer
lea ecx,(AIRCRAFTDATASTT Ptr [esi]).g_StartUpTime
invoke GetTimeFormat,LOCALE_USER_DEFAULT,NULL,ecx,CTXT("HH:mm:ss"), addr tbuffer, sizeof tbuffer
invoke lstrcat,addr buffer,addr tempbuf
invoke lstrcat,addr buffer,addr dbuffer
invoke lstrcat,addr buffer,addr tbuffer
invoke lstrcat,addr buffer,CTXT(13,10)
invoke lstrlen,addr buffer
lea edi,buffer
add edi,eax
mov al,(AIRCRAFTDATASTT Ptr [esi]).g_FullStoreFlag
lea ecx,(AIRCRAFTDATASTT Ptr [esi]).g_DataBuffer
.if al==TRUE
invoke FullProcessingDataOrder,ecx,(AIRCRAFTDATASTT Ptr [esi]).g_HeadDataIndex,edi
.else
invoke NoFullProcessingDataOrder,ecx,(AIRCRAFTDATASTT Ptr [esi]).g_HeadDataIndex,edi
.endif
invoke SetWindowText,hwndEdit,addr buffer
.elseif eax==WM_DESTROY
invoke GlobalFree,pBuffer
invoke CloseHandle,hFile
invoke PostQuitMessage,NULL
.elseif eax == WM_SIZE
invoke GetClientRect, hWnd, addr rt
mov eax,rt.right
sub eax,rt.left
mov ecx,rt.bottom
sub ecx,rt.top
invoke MoveWindow,hwndEdit,0,0,eax,ecx, TRUE
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszClassName,offset ClassName
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
invoke CreateWindowEx,WS_EX_CLIENTEDGE,addr ClassName,addr AppName,\
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,500,\
400,NULL,NULL,hInst,NULL
mov hwnd,eax
invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.while TRUE
invoke GetMessage, addr msg,NULL,0,0
.break .if (!eax)
invoke TranslateMessage, addr msg
invoke DispatchMessage, addr msg
.endw
mov eax,msg.wParam
ret
WinMain endp
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke LoadLibrary,CTXT("Riched20.dll")
push eax
invoke GetCommandLine
invoke WinMain, hInstance,NULL,eax, SW_SHOWDEFAULT
pop eax
invoke FreeLibrary,eax
invoke ExitProcess,eax
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
end start
You can get away with not using the header/tail pointers
If you're going to migrate this to actual CVRs and/or FDRs with Flash ram, using the circular buffer method, you could insert a small ID Start Block structure(IDSB), followed by the recorded info. This IDSB moves in the circular buffer, so when extracting the data you look for this structure signature and then extract backwards.
Otherwise if one keeps the header/pointer or IDSB structures separate from the data, you'll want to make sure these are written to the section of Flash that can handle a larger amount of write cycles (Damn ..forgotten the name of this block :dazzled:)
:biggrin:
hi,K_F
thanks your help. :t
if you have any better idea, please show me up.
to write the some new datas into the disk is heavry work at everytime.
do you think whether the cache is to be needed?
another approach would be to place the time stamp in each "data packet"
it's probably a requirement, anyways
when you read the data file, you will be able to tell where the data starts and ends by the time stamps
True.. that sounds like a better idea!
:)