-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommands OLD - memory messages.cpp
63 lines (51 loc) · 1.44 KB
/
Commands OLD - memory messages.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Commands.h"
extern TCommand * Command;
extern THandle * ComHandle;
//---------------------------------------------------------------------------
#pragma package(smart_init)
void TestConnection()
{
Command = (TCommand *)MapViewOfFile(ComHandle,FILE_MAP_ALL_ACCESS,0,0,0);
Command->Code = 1;
Command->Sent = True;
Sleep(2000);
if(Command->Code == 0)
ShowMessage("Comunication OK");
else
ShowMessage("Comunication Time Out");
UnmapViewOfFile(Command);
}
bool IsConnected()
{
Command = (TCommand *)MapViewOfFile(ComHandle,FILE_MAP_ALL_ACCESS,0,0,0);
Command->Code = 1;
Command->Sent = True;
Sleep(20);
if(Command->Code == 0){
UnmapViewOfFile(Command);
return true;
}
UnmapViewOfFile(Command);
return false;
}
void SetTrackCommand(TTrack Track)
{
AnsiString tmp;
Command = (TCommand *)MapViewOfFile(ComHandle,FILE_MAP_ALL_ACCESS,0,0,0);
Command->Code = 2;
Command->Id = Track.Num;
Command->x1 = Track.X;
Command->y1 = Track.Y;
Command->z1 = Track.Z;
Command->x2 = 0; // unused
Command->y2 = 0; // unused
Command->z2 = 0; // unused
tmp = "Track ";
tmp += Track.Num;
strcpy(Command->Text,tmp.c_str());
Command->Sent = True;
UnmapViewOfFile(Command);
}