-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathptpwin.c
More file actions
138 lines (100 loc) · 4.16 KB
/
ptpwin.c
File metadata and controls
138 lines (100 loc) · 4.16 KB
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
/* POINT TO POINT PROTOCOL - APPLICATIE KOPPELSIGNALEN */
/* =================================================== */
/* (C) Copyright 1998-2020 by A.C.M. van Grinsven. All rights reserved. */
/* CCOL : versie 11.0 */
/* FILE : ptpwin.c */
/* DATUM: 30-04-2020 */
/* include files */
/* ============= */
#include "ptpvar.c" /* definitie PTP-structuur */
#include "ptpksvar.c" /* definitie structuur koppelsignalen */
#include "ptpkps.h" /* definitie data bewerkingen */
#include "ccolks.h" /* koppelsignalen */
/* struct ptpstruct PTPxx; */ /* definitie in regelapplicatie */
/* struct ptpksstruct PTPKSx;*/ /* definitie in regelapplicatie */
/* macrodefinities - gebruik CCOLKS-buffer */
/* --------------------------------------- */
#define PTP_PORT 0 /* plaats - poortnummer */
#define PTP_INIT 1 /* plaats - initialisatie vlag */
#define PTP_SRC 2 /* plaats - source */
#define PTP_DEST 3 /* plaats - destination */
#define PTP_HDR 4 /* lengte van de header - start data */
/* DEFINITIE APPLICATIE KOPPELSIGNALEN */
/* =================================== */
void ptp_application_ks(struct ptpstruct *PTP, struct ptpksstruct *PTPKS)
{
s_int16 i;
if (PTP->PORTNR%2) {
for (i=0; i<PTPKS->UKS_MAX; i++)
set_ks((s_int16) (PTP->PORTNR),(s_int16) (i+PTP_HDR), PTPKS->UKS[i] );
if ( PTP->SRC==get_ks( (s_int16) (PTP->PORTNR-1), (s_int16) (PTP_DEST)) ) { /* check source-destination */
PTPKS->OKE= TRUE;
for (i=0; i<PTPKS->IKS_MAX; i++)
PTPKS->IKS[i]= get_ks( (s_int16) (PTP->PORTNR-1), (s_int16) (i+PTP_HDR));
}
else {
PTPKS->OKE= FALSE;
for (i=0; i<PTPKS->IKS_MAX; i++)
PTPKS->IKS[i]= FALSE;
}
}
else {
for (i=0; i<PTPKS->UKS_MAX; i++)
set_ks((s_int16) (PTP->PORTNR), (s_int16) (i+PTP_HDR), PTPKS->UKS[i] );
if ( PTP->SRC==get_ks( (s_int16) (PTP->PORTNR+1), (s_int16) (PTP_DEST)) ) { /* check source-destination */
PTPKS->OKE= TRUE;
for (i=0; i<PTPKS->IKS_MAX; i++)
PTPKS->IKS[i]= get_ks( (s_int16) (PTP->PORTNR+1), (s_int16) (i+PTP_HDR));
}
else {
PTPKS->OKE= FALSE;
for (i=0; i<PTPKS->IKS_MAX; i++)
PTPKS->IKS[i]= FALSE;
}
}
}
/* PTP INIT */
/* ======== */
void ptp_init(struct ptpstruct *PTP)
{
/* set poortnummer en initvlag */
/* ---------------------------- */
set_ks((s_int16) (PTP->PORTNR), (s_int16) (PTP_PORT), (s_int16) (PTP->PORTNR)); /* set port nr */
set_ks((s_int16) (PTP->PORTNR), (s_int16) (PTP_INIT), (s_int16) (TRUE)); /* set init */
}
/* PTP CONTROL */
/* =========== */
void ptp_control(struct ptpstruct *PTP)
{
/* set source and destination */
/* -------------------------- */
if ( get_ks( (s_int16) (PTP->PORTNR), (s_int16) (PTP_INIT)) ) { /* check init-vlag */
set_ks((s_int16) (PTP->PORTNR), (s_int16) (PTP_SRC), PTP->SRC); /* set source */
set_ks((s_int16) (PTP->PORTNR), (s_int16) (PTP_DEST), PTP->DEST); /* set destination */
}
/* reset systeem vlaggen */
/* --------------------- */
PTP->DATAMSG_IN= FALSE; /* reset datamsg vlag */
#ifndef NO_CCOL800
// PTP->COMERROR= FALSE; /* reset storing bits */
#else
// PTP->ERROR= FALSE; /* reset storing bits */
#endif
}
/* PTP RESET */
/* ========= */
void ptp_application_reset(struct ptpstruct *PTP, struct ptpksstruct *PTPKS)
{
s_int16 i;
/* reset header */
/* ------------ */
set_ks((s_int16) (PTP->PORTNR), (s_int16) (PTP_PORT), (s_int16) (FALSE)); /* reset port nr */
set_ks((s_int16) (PTP->PORTNR), (s_int16) (PTP_INIT), (s_int16) (FALSE)); /* reset init */
set_ks((s_int16) (PTP->PORTNR), (s_int16) (PTP_SRC), (s_int16) (FALSE)); /* reset src */
set_ks((s_int16) (PTP->PORTNR), (s_int16) (PTP_DEST), (s_int16) (FALSE)); /* reset dest */
/* reset data */
/* ---------- */
for (i=0; i<PTPKS->UKS_MAX; i++) {
set_ks((s_int16) (PTP->PORTNR),(s_int16) (i+PTP_HDR), (s_int16) (FALSE) );
}
}