-
Notifications
You must be signed in to change notification settings - Fork 0
/
BalmackEpromfile.sql
174 lines (148 loc) · 12.1 KB
/
BalmackEpromfile.sql
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
EXECUTE BLOCK (
LINPUT BIGINT = :V,
LEPROM_CODEMODE BIGINT = :EPROM_CODEMODE,
LEPROM_CHARMODE BIGINT = :EPROM_CHARMODE,
LEPROM_DISPLAYMODE BIGINT = :EPROM_DISPLAYMODE,
LEPROM_MODEFILETRANSMIT BIGINT = :EPROM_MODEFILETRANSMIT,
LEPROM_MODEFILE BIGINT = :EPROM_MODEFILE)
RETURNS (
RDOCUMENTACAO BLOB SUB_TYPE 0 CHARACTER SET OCTETS,
RFILE BLOB SUB_TYPE 0 CHARACTER SET OCTETS)
AS
DECLARE VARIABLE HMATRIZ CHAR(16) = '0123456789ABCDEF';
DECLARE VARIABLE L0F BIGINT = 0X0F;
DECLARE VARIABLE LFOURBIT BIGINT;
DECLARE VARIABLE LEIGHTBIT BIGINT;
DECLARE VARIABLE LTWELVE BIGINT;
DECLARE VARIABLE LSIXTEEN BIGINT;
DECLARE VARIABLE LTWENTY BIGINT;
DECLARE VARIABLE LTWENTYEIGHT BIGINT;
DECLARE VARIABLE LTWENTYFOUR BIGINT;
DECLARE VARIABLE LONEBIT BIGINT;
DECLARE VARIABLE PHEADER BLOB SUB_TYPE 0 SEGMENT SIZE 80;
DECLARE VARIABLE REPROM_CODEMODE BLOB SUB_TYPE 0 CHARACTER SET OCTETS;
DECLARE VARIABLE REPROM_CHARMODE BLOB SUB_TYPE 0 CHARACTER SET OCTETS;
DECLARE VARIABLE EPROM_OUTPUT BLOB SUB_TYPE 0 CHARACTER SET OCTETS;
DECLARE VARIABLE EPROM_DISPLAYMODE BLOB SUB_TYPE 0 CHARACTER SET OCTETS;
DECLARE VARIABLE VEPROM_MODEFILETRANSMIT BLOB SUB_TYPE 0 CHARACTER SET OCTETS;
DECLARE VARIABLE VEPROM_MODEFILE BLOB SUB_TYPE 0 CHARACTER SET OCTETS;
DECLARE VARIABLE PRESULT VARCHAR(60);
BEGIN
LFOURBIT = BIN_AND(L0F, BIN_SHR(LINPUT, 4) );
LEIGHTBIT = BIN_AND(L0F, BIN_SHR(LINPUT, 8) );
LTWELVE = BIN_AND(L0F, BIN_SHR(LINPUT, 12) );
LSIXTEEN = BIN_AND(L0F, BIN_SHR(LINPUT, 16) );
LTWENTY = BIN_AND(L0F, BIN_SHR(LINPUT, 20) );
LTWENTYEIGHT = BIN_AND(L0F, BIN_SHR(LINPUT, 28) );
LTWENTYFOUR = BIN_AND(L0F, BIN_SHR(LINPUT, 24) );
LONEBIT = BIN_AND(L0F, LINPUT );
PRESULT = SUBSTRING( HMATRIZ FROM LFOURBIT +1 FOR 1 )||
SUBSTRING( HMATRIZ FROM LONEBIT +1 FOR 1)||
SUBSTRING( HMATRIZ FROM LTWELVE +1 FOR 1)||
SUBSTRING( HMATRIZ FROM LEIGHTBIT +1 FOR 1)||
SUBSTRING( HMATRIZ FROM LTWENTY +1 FOR 1)||
SUBSTRING( HMATRIZ FROM LSIXTEEN +1 FOR 1)||
SUBSTRING( HMATRIZ FROM LTWENTYEIGHT +1 FOR 1)||
SUBSTRING( HMATRIZ FROM LTWENTYFOUR +1 FOR 1);
PHEADER = '#-----------------------------------------------------------------'|| ASCII_CHAR(13) || ASCII_CHAR(10)||
'# PROGRAMA CONFIGURA EPROM BALMACK ORION 5 PARCEIRO '|| ASCII_CHAR(13) || ASCII_CHAR(10)||
'# ANALISTA: CARLOS A. D. S. FILHO '|| ASCII_CHAR(13) || ASCII_CHAR(10)||
'# REVISAO : 10/10/2022 '|| ASCII_CHAR(13) || ASCII_CHAR(10)||
'# OBJETO: '|| ASCII_CHAR(13) || ASCII_CHAR(10)||
'# "GERA O ARQUIVO DE ENVIO AO PROGRAMA PARA CONFIGURACAO LEOPARD '|| ASCII_CHAR(13) || ASCII_CHAR(10)
|| '# COMPATIBILIDADE D '|| ASCII_CHAR(13) || ASCII_CHAR(10)
|| '# INT16 - LITTLE ENDIAN (BA)' || ASCII_CHAR(13) || ASCII_CHAR(10)
|| '# UINT16 - LITTLE ENDIAN (BA)' || ASCII_CHAR(13) || ASCII_CHAR(10)
|| '# INT32 - LITTLE ENDIAN (DCBA)' || ASCII_CHAR(13) || ASCII_CHAR(10)
|| '# UINT32 - LITTLE ENDIAN (DCBA)"' || ASCII_CHAR(13) || ASCII_CHAR(10)
|| '# UINT32 - BIG ENDIAN (ABCD)"' || ASCII_CHAR(13) || ASCII_CHAR(10)
|| '# INT32 - BIG ENDIAN (ABCD)"' || ASCII_CHAR(13) || ASCII_CHAR(10)
|| '# -----------------------------------------------------------------'||
' '|| ASCII_CHAR(13) || ASCII_CHAR(10);
RDOCUMENTACAO = PHEADER
/*$$IBEC$$ '{ "Hex" : '
||PRESULT || ASCII_CHAR(13) || ASCII_CHAR(10)
||', "input" : '|| LINPUT || ASCII_CHAR(13) || ASCII_CHAR(10)
||',"deslocamento 1" : "BIN_AND(L0F, BIN_SHR(LINPUT, 4) -> '||SUBSTRING( HMATRIZ FROM LFOURBIT +1 FOR 1 )||'"' || ASCII_CHAR(13) || ASCII_CHAR(10)
||',"deslocamento 2" : "BIN_AND(L0F, LINPUT )'||SUBSTRING( HMATRIZ FROM LONEBIT +1 FOR 1)||'"'
||',"deslocamento 3" : "BIN_AND(L0F, BIN_SHR(LINPUT, 12) ) -> '||SUBSTRING( HMATRIZ FROM LTWELVE +1 FOR 1)||'"' || ASCII_CHAR(13) || ASCII_CHAR(10)
||',"deslocamento 4" : "BIN_AND(L0F, BIN_SHR(LINPUT, 8)) -> '||SUBSTRING( HMATRIZ FROM LEIGHTBIT +1 FOR 1)||'"' || ASCII_CHAR(13) || ASCII_CHAR(10)
||',"deslocamento 5" : "BIN_AND(L0F, BIN_SHR(LINPUT, 20) ) -> '||SUBSTRING( HMATRIZ FROM LTWENTY +1 FOR 1)||'"' || ASCII_CHAR(13) || ASCII_CHAR(10)
||',"deslocamento 6" : "BIN_AND(L0F, BIN_SHR(LINPUT, 16) ) -> '||SUBSTRING( HMATRIZ FROM LSIXTEEN +1 FOR 1)||'"' || ASCII_CHAR(13) || ASCII_CHAR(10)
||',"deslocamento 7" : "BIN_AND(L0F, BIN_SHR(LINPUT, 28) ) -> '||SUBSTRING( HMATRIZ FROM LTWENTYEIGHT +1 FOR 1)||'"' || ASCII_CHAR(13) || ASCII_CHAR(10)
||',"deslocamento 8" : "BIN_AND(L0F, BIN_SHR(LINPUT, 24) ) -> '||SUBSTRING( HMATRIZ FROM LTWENTYFOUR +1 FOR 1)||'"' || ASCII_CHAR(13) || ASCII_CHAR(10)
||' } ' $$IBEC$$*/;
REPROM_CODEMODE = '0XFA0 = '||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CODEMODE, 4))+1 FOR 1) ||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, LEPROM_CODEMODE)+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CODEMODE, 12))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CODEMODE, 8))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CODEMODE, 20))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CODEMODE, 16))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CODEMODE, 28))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CODEMODE, 24))+1 FOR 1) ;
REPROM_CHARMODE = '0XFAF = '|| SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CHARMODE, 4))+1 FOR 1) ||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, LEPROM_CHARMODE)+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CHARMODE, 12))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CHARMODE, 8))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CHARMODE, 20))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CHARMODE, 16))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CHARMODE, 28))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_CHARMODE, 24))+1 FOR 1);
EPROM_DISPLAYMODE = '0XFFF = '|| SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_DISPLAYMODE, 4))+1 FOR 1) ||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, LEPROM_DISPLAYMODE)+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_DISPLAYMODE, 12))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_DISPLAYMODE, 8))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_DISPLAYMODE, 20))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_DISPLAYMODE, 16))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_DISPLAYMODE, 28))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_DISPLAYMODE, 24))+1 FOR 1);
VEPROM_MODEFILETRANSMIT = '0XFAF = '|| SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILETRANSMIT, 4))+1 FOR 1) ||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, LEPROM_MODEFILETRANSMIT)+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILETRANSMIT, 12))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILETRANSMIT, 8))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILETRANSMIT, 20))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILETRANSMIT, 16))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILETRANSMIT, 28))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILETRANSMIT, 24))+1 FOR 1);
VEPROM_MODEFILE = '0XFAFF = '|| SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILE, 4))+1 FOR 1) ||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, LEPROM_MODEFILE)+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILE, 12))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILE, 8))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILE, 20))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILE, 16))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILE, 28))+1 FOR 1)||
SUBSTRING(HMATRIZ FROM BIN_AND(0X0F, BIN_SHR(LEPROM_MODEFILE, 24))+1 FOR 1);
EPROM_OUTPUT = REPROM_CODEMODE ||' -> '|| UDF_INTTOHEXBIGENDIAN( LEPROM_CODEMODE ,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||REPROM_CHARMODE ||' -> '|| UDF_INTTOHEXBIGENDIAN( LEPROM_CHARMODE ,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||EPROM_DISPLAYMODE||' -> '|| UDF_INTTOHEXBIGENDIAN( LEPROM_DISPLAYMODE,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||VEPROM_MODEFILETRANSMIT||' -> '|| UDF_INTTOHEXBIGENDIAN( LEPROM_MODEFILETRANSMIT,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||VEPROM_MODEFILE||' -> '|| UDF_INTTOHEXBIGENDIAN( LEPROM_MODEFILE,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10);
RDOCUMENTACAO = RDOCUMENTACAO || ASCII_CHAR(13) || ASCII_CHAR(10)
||'# INICIO ARQUIVO SAIDA PARA CONFERENCIA'|| ASCII_CHAR(13) || ASCII_CHAR(10)
||'# MODELOS RAMUZA USAR LITTLE ENDIAN '|| ASCII_CHAR(13) || ASCII_CHAR(10)
||'# MODELOS ORION USAR BIG ENDIAN '|| ASCII_CHAR(13) || ASCII_CHAR(10)
||'# MODO DA EPROM - ORION 5 SETAR VALOR 1 | ' || UDF_INTTOHEXBIGENDIAN( LEPROM_CODEMODE ,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||'# MODO PAGINA DE CODIGO - ORION 5 SETAR VALOR 55 | ' || UDF_INTTOHEXBIGENDIAN( LEPROM_CHARMODE ,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||'# MODO DE DISPLAY DA TORRE - ORION 5 SETAR VALOR 8 | ' || UDF_INTTOHEXBIGENDIAN( LEPROM_DISPLAYMODE,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||'# MODO DE TRANSMISSAO DO ARQUIVO - ORION 5 SETAR VALOR 2 | ' || UDF_INTTOHEXBIGENDIAN( LEPROM_MODEFILETRANSMIT,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||'# MODO DE DO ARQUIVO LAYOUT - ORION 5 SETAR VALOR 31 | ' || UDF_INTTOHEXBIGENDIAN( LEPROM_MODEFILE,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||''
|| ASCII_CHAR(13) || ASCII_CHAR(10)
||'# FORMATO DO ARQUIVO '||ASCII_CHAR(13) || ASCII_CHAR(10)
||'# CARACTERE ( # ) DESCONSIDERA LINHA '||ASCII_CHAR(13) || ASCII_CHAR(10)
||'# CARACTERE ( -> ) CONVERTE PARA VALOR ( NAO E DO ARQUIVO ) '||ASCII_CHAR(13) || ASCII_CHAR(10)
||'# ENDERECO | VALOR LITTLE ENDIAN | BIG ENDIAN SWAP '|| ASCII_CHAR(13)|| ASCII_CHAR(10)
||' '||ASCII_CHAR(13) || ASCII_CHAR(10)
||'------------------------------------------------------------'||ASCII_CHAR(13) || ASCII_CHAR(10)
||EPROM_OUTPUT;
/*
GERACAO DO ARQUIVO , NA APLICACAO FAZER PARSE USANDO COMO SEPARADOR O CARACTERE ('->')
*/
RFILE = REPROM_CODEMODE ||' -> '|| UDF_INTTOHEXBIGENDIAN( LEPROM_CODEMODE ,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||REPROM_CHARMODE ||' -> '|| UDF_INTTOHEXBIGENDIAN( LEPROM_CHARMODE ,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||EPROM_DISPLAYMODE ||' -> '|| UDF_INTTOHEXBIGENDIAN( LEPROM_DISPLAYMODE,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||VEPROM_MODEFILETRANSMIT||' -> '|| UDF_INTTOHEXBIGENDIAN( LEPROM_MODEFILETRANSMIT,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10)
||VEPROM_MODEFILE||' -> '|| UDF_INTTOHEXBIGENDIAN( LEPROM_MODEFILE,8 ) || ASCII_CHAR(13) || ASCII_CHAR(10);
SUSPEND;
END