SDC C-Project CF Review 프로그램
LYW
2021-07-23 55615eba335d4cbc1f83330dc5078fe073034b7d
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
/* DPR.H  Header file for PMAC Dual Ported RAM communications.
 
HISTORY:
 
03Aug98 JET Added *_DPR_BASE definitions, added PmacDPRAddressRange() decl.
23Jan98 EBL Add TURBO PMAC changes
24May94 DES Removed bit defines, changed to bit fields.
18Nov92 DES Created
***************************************************************************/
#include "DPRRealT.h"
#include "DPRBkg.h"
#ifndef _DPR_H
  #define _DPR_H
 
  #define PMAC_DPR_BASE      0xD000
  #define TURBO_DPR_BASE     0x60000
  #define UMAC_DPR_BASE      0x6C000
 
  #define RETRY               5
  #define MAXAOUT             160 // ASCII interface max output string length
  #define MAXAIN              256 // ASCII interface max input string length
  #define MAX_VBGBUF_USERS    9   // Maximum number of vbg data buffer users
 
typedef enum { stop, run, step, hold, joghold, jogstop } PROGRAM;
typedef enum { inpos, jog, running, homing, handle, openloop, disabled } MOTION;
typedef enum { linear, rapid, circw, circcw, spline, pvt } MOTIONMODE;
 
typedef void (FAR WINAPI * DPRTESTMSGPROC) ( LONG NumErrors, LPTSTR action, LONG CURRENT_OFFSET );
typedef void (FAR WINAPI * DPRTESTPROGRESS) ( LONG Percent );
 
//      Return codes for PmacDPRrotput()
 
  #define RET_ERROR       -1 // Internal Rotary Buffer has zero size, or conversion error
  #define RET_BUSY        1  // Could not load Command Array into DPR Rotary Buffer
  #define RET_OKAY        0  // Loaded Command Array into DPR Rotary Buffer
 
///////////////////////////////////////////////////////////////////////////
//  Dual Ported RAM structure
//
 
// Control Panel ----------------------------------------------------------
struct cpanec { // cpanel motor/coord request structure
 
        USHORT  spare : 8;     // place holder
        USHORT  jogminus : 1;  // jog minus ( motor only )
        USHORT  jogplus : 1;   // jog plus ( motor only )
        USHORT  jogreturn : 1; // jog return ( motor only )
        USHORT  start : 1;     // start program ( coord only )
        USHORT  step : 1;      // step program ( coord only )
        USHORT  stop : 1;      // abort program ( coord only )
        USHORT  home : 1;      // home motor ( motor only )
        USHORT  hold : 1;      // hold program ( coord only )
};
 
struct cpanem { // cpanel motor/coord structure
 
        struct cpanec   request; // Y:$D001 motor/coord request
        USHORT  feedpot;         // X:$D001 feed pot override
};
 
struct cpane {
 
        USHORT request1 : 1;        // Y:$D000:B0 enable coord/motor 1
        USHORT request2 : 1;        // Y:$D000:B1 enable coord/motor 2
        USHORT request3 : 1;        // Y:$D000:B2 enable coord/motor 3
        USHORT request4 : 1;        // Y:$D000:B3 enable coord/motor 4
        USHORT request5 : 1;        // Y:$D000:B4 enable coord/motor 5
        USHORT request6 : 1;        // Y:$D000:B5 enable coord/motor 6
        USHORT request7 : 1;        // Y:$D000:B6 enable coord/motor 7
        USHORT request8 : 1;        // Y:$D000:B7 enable coord/motor 8
        USHORT notused : 8;         // Y:$D000:B8-B15 place holder
        USHORT feedoverride;        // X:$D000 reserved for feedpot override
        struct cpanem   mtrcrd[8 ]; // $D001 - $D008 for 8 coord/motor
};
 
 
///////////////////////////////////////////////////////////////////////////
// ASCII Interface Structure ----------------------------------------------
///////////////////////////////////////////////////////////////////////////
struct ascii {
        USHORT  sendready : 1;    // Y:$D18B($603A7) output control word
        USHORT  pad : 15;
        USHORT  ctrlchar;         // X:$D18B control character
        char    outstr[MAXAOUT ]; // $D18C - $D1B3 output string buffer
        USHORT  instatus;         // Y:$D1B4($603D0) input control word
        USHORT  charcount;        // X:$D1B4 input character count
        char    instr[MAXAIN ];   // $D1B5 - $D1F4 input string buffer
};
 
///////////////////////////////////////////////////////////////////////////
// ROT BUFFER Interface Structure
 
struct rotbuf {
    USHORT    roterr : 8; // Y:$D1FC Error codes
    USHORT    spare0 : 6;
    USHORT    busy : 1;   // Y:$D1FC Internal Rotary buffer full
    USHORT    error : 1;  // Y:$D1FC Error Flag
    USHORT    coord;      // X:$D1FC coordinate system
    USHORT    hostindex;  // Y:$D1FD Host Index to Rotary Buffer
    USHORT    pmacindex;  // X:$D1FD PMAC Index to Rotary Buffer
    USHORT    bufsize;    // Y:$D1FE Size of rotary buffer
    USHORT    bufstart;   // X:$D1FE buffer start / TURBO = offset from fixed buf
};
 
///////////////////////////////////////////////////////////////////////////
// DATA GATHER Interface Structure
 
struct gatbuf {
        USHORT  bufsize;  // Y:$D1FF Size of rotary buffer
        USHORT  bufstart; // X:$D1FF buffer start index
};
 
//////////////////////////////////////////////////////////////////////////
// Functions
  #ifdef __cplusplus
extern "C" {
  #endif
 
  void _cdecl DPRLock( DWORD dwDevice );
  void _cdecl DPRUnlock( DWORD dwDevice );
 
  VOID    SaveConfiguration( DWORD dwDevice );
  DWORD   GetDPRAMAddress( DWORD dwDevice );
  BOOL    ConfigureDPRAM( DWORD dwDevice, DWORD dwDPRBaseAddress );
  BOOL    CardHasMem( DWORD dwDevice );
  LONG    CALLBACK PmacDPRTest();
  void    _cdecl   DPRTestThread( PCHAR dummy );
  void    CALLBACK PmacAbortDPRTest( void );
  void    CALLBACK PmacDPRStatus( DWORD dwDevice, UINT * comm, UINT * bg, UINT * bgv,
                   UINT * rt, UINT * cp, UINT * rot );
  BOOL    CALLBACK PmacDPRAvailable( DWORD dwDevice );
 
  // Numeric read/write functions
  PVOID   CALLBACK PmacDPRGetMem( DWORD dwDevice, DWORD offset, size_t count, PVOID val );
  PVOID   CALLBACK PmacDPRSetMem( DWORD dwDevice, DWORD offset, size_t count, PVOID val );
  BOOL    CALLBACK PmacDPRGetMemBits( DWORD dwDevice, DWORD offset, UINT startbit,UINT width, PDWORD val );
  BOOL    CALLBACK PmacDPRSetMemBits( DWORD dwDevice, DWORD offset, UINT startbit,UINT width, DWORD val );
  BOOL    CALLBACK PmacDPRGetMemBit( DWORD dwDevice, DWORD offset, UINT bit, PBOOL val );
  BOOL    CALLBACK PmacDPRSetMemBit( DWORD dwDevice, DWORD offset, UINT bit, BOOL val );
  BOOL    CALLBACK PmacDPRDWordBitSet( DWORD dwDevice, UINT offset, UINT bit );
  void    CALLBACK PmacDPRSetDWordBit( DWORD dwDevice, UINT offset, UINT bit );
  void    CALLBACK PmacDPRResetDWordBit( DWORD dwDevice, UINT offset, UINT bit );
  WORD    CALLBACK PmacDPRGetWord( DWORD dwDevice, UINT offset );
  void    CALLBACK PmacDPRSetWord( DWORD dwDevice, UINT offset, WORD val );
  DWORD   CALLBACK PmacDPRGetDWord( DWORD dwDevice, UINT offset );
  void    CALLBACK PmacDPRSetDWord( DWORD dwDevice, UINT offset, DWORD val );
  float   CALLBACK PmacDPRGetFloat( DWORD dwDevice, UINT offset );
  void    CALLBACK PmacDPRSetFloat( DWORD dwDevice, UINT offset, double val );
  void    CALLBACK PmacDPRSetDWordMask( DWORD dwDevice, UINT offset, DWORD val, BOOL onoff );
  DWORD   CALLBACK PmacDPRGetDWordMask( DWORD dwDevice, UINT offset, DWORD val );
 
  double  CALLBACK PmacDPRFloat( long d[], double scale );
  double  CALLBACK PmacDPRLFixed( long d[], double scale );
 
  double  CALLBACK PmacDPRVelocity( DWORD dwDevice, int mtr, double units );
  double  CALLBACK PmacDPRVectorVelocity( DWORD dwDevice, int num, int mtr[], double units[] );
 
  void    CALLBACK PmacDPRSetMotors( DWORD dwDevice, UINT n );
 
  // Function     pertaining to global status
  void CALLBACK PmacDPRGetGlobalStatus(DWORD dwDevice,VOID *gstatus);
  void CALLBACK PmacDPRGetGlobalStatusTurbo(DWORD dwDevice,struct gsTURBO *turbogstatus);
 
  BOOL CALLBACK PmacDPRMotionBufOpen( DWORD dwDevice );
  BOOL CALLBACK PmacDPRRotBufOpen( DWORD dwDevice );
  BOOL CALLBACK PmacDPRSysServoError( DWORD dwDevice );
  BOOL CALLBACK PmacDPRSysReEntryError( DWORD dwDevice );
  BOOL CALLBACK PmacDPRSysMemChecksumError( DWORD dwDevice );
  BOOL CALLBACK PmacDPRSysPromChecksumError( DWORD dwDevice );
 
 
  // Functions pertaining to individual motors
  //       Background-Functions pertaining to individual motors
  BOOL   CALLBACK PmacDPRAmpEnabled( DWORD dwDevice, int mtr );
  BOOL   CALLBACK PmacDPRWarnFError( DWORD dwDevice, int mtr );
  BOOL   CALLBACK PmacDPRFatalFError( DWORD dwDevice, int mtr );
  BOOL   CALLBACK PmacDPRAmpFault( DWORD dwDevice, int mtr );
  BOOL   CALLBACK PmacDPROnPositionLimit( DWORD dwDevice, int mtr );
  BOOL   CALLBACK PmacDPRHomeComplete( DWORD dwDevice, int mtr );
  BOOL   CALLBACK PmacDPRInposition( DWORD dwDevice, int mtr );
  double CALLBACK PmacDPRGetTargetPos( DWORD dwDevice, int motor, double posscale );
  double CALLBACK PmacDPRGetBiasPos( DWORD dwDevice, int motor, double posscale );
  long   CALLBACK PmacDPRTimeRemInMove( DWORD dwDevice, int cs );
  long   CALLBACK PmacDPRTimeRemInTATS( DWORD dwDevice, int cs );
  DWORD  CALLBACK PmacDPRGetAssignedCoord(DWORD dwDevice, int mtr ,DWORD bWaitForUpdate);
  DWORD  CALLBACK PmacDPRIsAssignedCoord(DWORD dwDevice, int mtr ,DWORD bWaitForUpdate);
 
  // Logical query functions
  PROGRAM     CALLBACK PmacDPRGetProgramMode( DWORD dwDevice, int csn );
  MOTIONMODE  CALLBACK PmacDPRGetMotionMode( DWORD dwDevice, int csn );
 
  ////////////////////////////////////////////////////////////////////////////
  // DPR Control Panel functions
  ////////////////////////////////////////////////////////////////////////////
  BOOL  CALLBACK PmacDPRControlPanel( DWORD dwDevice, long on );
  void  CALLBACK PmacDPRSetJogPosBit( DWORD dwDevice, long motor, long onoff );
  long  CALLBACK PmacDPRGetJogPosBit( DWORD dwDevice, long motor );
  void  CALLBACK PmacDPRSetJogNegBit( DWORD dwDevice, long motor, long onoff );
  long  CALLBACK PmacDPRGetJogNegBit( DWORD dwDevice, long motor );
  void  CALLBACK PmacDPRSetJogReturnBit( DWORD dwDevice, long motor, long onoff );
  long  CALLBACK PmacDPRGetJogReturnBit( DWORD dwDevice, long motor );
  void  CALLBACK PmacDPRSetRunBit( DWORD dwDevice, long cs, long onoff );
  long  CALLBACK PmacDPRGetRunBit( DWORD dwDevice, long cs );
  void  CALLBACK PmacDPRSetStopBit( DWORD dwDevice, long cs, long onoff );
  long  CALLBACK PmacDPRGetStopBit( DWORD dwDevice, long cs );
  void  CALLBACK PmacDPRSetHomeBit( DWORD dwDevice, long cs, long onoff );
  long  CALLBACK PmacDPRGetHomeBit( DWORD dwDevice, long cs );
  void  CALLBACK PmacDPRSetHoldBit( DWORD dwDevice, long cs, long onoff );
  long  CALLBACK PmacDPRGetHoldBit( DWORD dwDevice, long cs );
  long  CALLBACK PmacDPRGetStepBit( DWORD dwDevice, long cs );
  void  CALLBACK PmacDPRSetStepBit( DWORD dwDevice, long cs, long onoff );
  long  CALLBACK PmacDPRGetRequestBit( DWORD dwDevice, long mtrcrd );
  void  CALLBACK PmacDPRSetRequestBit( DWORD dwDevice, long mtrcrd, long onoff );
  long  CALLBACK PmacDPRGetFOEnableBit( DWORD dwDevice, long cs );
  void  CALLBACK PmacDPRSetFOEnableBit( DWORD dwDevice, long cs, long on_off );
  void  CALLBACK PmacDPRSetFOValue( DWORD dwDevice, long cs, long value );
  long  CALLBACK PmacDPRGetFOValue( DWORD dwDevice, long cs );
 
 
  ////////////////////////////////////////////////////////////////////////////
  // Uses both Realtime and background features
  ////////////////////////////////////////////////////////////////////////////
  MOTION CALLBACK PmacDPRGetMotorMotion( DWORD dwDevice, int mtr );
  double CALLBACK PmacDPRGetFeedRateMode( DWORD dwDevice, int csn, BOOL * mode );
  BOOL   CALLBACK  PmacDPRFixedBufferDataUpdate( DWORD dwDevice );
 
  ////////////////////////////////////////////////////////////////////////////
  // ASCII FUNCTIONS
  ////////////////////////////////////////////////////////////////////////////
  BOOL   CALLBACK PmacDPRComm( DWORD dwDevice, BOOL on );
  BOOL   CALLBACK PmacDPRReadReady( DWORD dwDevice );
  void   CALLBACK PmacDPRFlush( DWORD dwDevice );
 
  int    CALLBACK PmacDPRSendLineA( DWORD dwDevice, PCHAR outchar );
  int    CALLBACK PmacDPRSendCharA( DWORD dwDevice, CHAR outstr );
  int    CALLBACK PmacDPRSendCtrlCharA( DWORD dwDevice, CHAR outstr );
  int    CALLBACK PmacDPRGetLineA( DWORD dwDevice, PCHAR linebuf, UINT maxchar, PUINT nc );
  int    CALLBACK PmacDPRGetBufferA( DWORD dwDevice, PCHAR s, UINT       maxchar, PUINT nc );
  int    CALLBACK PmacDPRGetControlResponseA( DWORD dwDevice, PCHAR s, UINT maxchar, CHAR outchar );
  int    CALLBACK PmacDPRGetResponseA( DWORD dwDevice, PCHAR s, UINT     maxchar, PCHAR outstr );
  void   CALLBACK PmacDPRSendCommandA( DWORD dwDevice, PCHAR outchar );
 
  int    CALLBACK PmacDPRSendLineW( DWORD dwDevice, PWCHAR outchar );
  int    CALLBACK PmacDPRSendCharW( DWORD dwDevice, WCHAR outstr );
  int    CALLBACK PmacDPRSendCtrlCharW( DWORD dwDevice, WCHAR outstr );
  int    CALLBACK PmacDPRGetLineW( DWORD dwDevice, PWCHAR linebuf, UINT maxchar, PUINT nc );
  int    CALLBACK PmacDPRGetBufferW( DWORD dwDevice, PWCHAR s, UINT      maxchar, PUINT nc );
  int    CALLBACK PmacDPRGetControlResponseW( DWORD dwDevice, PWCHAR s, UINT maxchar, WCHAR outchar );
  int    CALLBACK PmacDPRGetResponseW( DWORD dwDevice, PWCHAR s, UINT    maxchar, PWCHAR outstr );
  void   CALLBACK PmacDPRSendCommandW( DWORD dwDevice, PWCHAR outchar );
  long   CALLBACK PmacDPRAddressRange( DWORD dwDevice, BOOL Upper, BOOL PC_offsets );
 
  #ifdef __cplusplus
}
  #endif
 
  #ifdef UNICODE
    #define PmacDPRSendLine PmacDPRSendLineW
    #define PmacDPRSendChar PmacDPRSendCharW
    #define PmacDPRSendCtrlChar PmacDPRSendCtrlCharW
    #define PmacDPRWaitGetLine PmacDPRWaitGetLineW
    #define PmacDPRGetLine PmacDPRGetLineW
    #define PmacDPRGetResponse PmacDPRGetResponseW
    #define PmacDPRGetControlResponse PmacDPRGetControlResponseW
    #define PmacDPRSendCommand PmacDPRSendCommandW
  #else
    #define PmacDPRSendLine PmacDPRSendLineA
    #define PmacDPRSendChar PmacDPRSendCharA
    #define PmacDPRSendCtrlChar PmacDPRSendCtrlCharA
    #define PmacDPRWaitGetLine PmacDPRWaitGetLineA
    #define PmacDPRGetLine PmacDPRGetLineA
    #define PmacDPRGetResponse PmacDPRGetResponseA
    #define PmacDPRGetControlResponse PmacDPRGetControlResponseA
    #define PmacDPRSendCommand PmacDPRSendCommandA
  #endif // !UNICODE
 
#endif