#define DGT_BUS_REPEAT_CHANGES (0x04 | MESSAGE_BIT)
#define DGT_BUS_SET_START_GAME (0x05 | MESSAGE_BIT)
#define DGT_BUS_SEND_FROM_START (0x06 | MESSAGE_BIT)
#define DGT_BUS_PING (0x07 | MESSAGE_BIT)
#define DGT_BUS_END_BUSMODE (0x08 | MESSAGE_BIT)
#define DGT_BUS_RESET (0x09 | MESSAGE_BIT)
#define DGT_BUS_IGNORE_NEXT_BUS_PING (0x0a | MESSAGE_BIT)
#define DGT_BUS_SEND_VERSION (0x0b | MESSAGE_BIT)
// extra return headers for bus mode:
#define DGT_MSG_BUS_BRD_DUMP (0x03 | MESSAGE_BIT)
#define DGT_MSG_BUS_BWTIME (0x04 | MESSAGE_BIT)
#define DGT_MSG_BUS_UPDATE (0x05 | MESSAGE_BIT)
#define DGT_MSG_BUS_FROM_START (0x06 | MESSAGE_BIT)
#define DGT_MSG_BUS_PING (0x07 | MESSAGE_BIT)
#define DGT_MSG_BUS_START_GAME_WRITTEN (0x08 | MESSAGE_BIT)
#define DGT_MSG_BUS_VERSION (0x09 | MESSAGE_BIT)
// extra defines for bus length info:
#define DGT_SIZE_BUS_PING 6
#define DGT_SIZE_BUS_START_GAME_WRITTEN 6
#define DGT_SIZE_BUS_VERSION 8 // was 6 up to version 1.2
/* Definition of different commands&data
All commands DGT_BUS_xx have the following format:
byte 1: command, i.e. DGT_BUS_SEND_BDR (D7 always 1)
byte 2: MSB of addressed board (D7 always 0)
byte 3: LSB of addressed board (D7 always 0)
byte 4: checksum: this is the sum of all bytes from start of the message
upto the last byte before the checksum. (D7 always 0)
I.e. message code 0x81 0x10 0x06 will carry checksum byte 0x17
DGT_BUS_SEND_CLK
asks for clock information of addressed board.
Will result in a DGT_MSG_BUS_BWTIME message from the board.
DGT_BUS_SEND_BRD
asks for a board dump of addressed board.
Will result in a DGT_MSG_BUS_BRD_DUMP message from the board.
DGT_BUS_SEND_CHANGES
asks for all stored information changes from the moment of the last
DGT_BUS_SEND_CHANGES. Will result in a DGT_MSG_BUS_UPDATE message from
the board.
In case these data do not arrive properly, the data can be asked again
with the DGT_BUS_REPEAT_CHANGES command.
DGT_BUS_REPEAT_CHANGES
Causes the board to send last sent packet of changes again.
DGT_BUS_SET_START_GAME
sets an EE_START_TAG tag in the internal board changes buffer, for use in the
following command DGT_BUS_SEND_FROM_START. After this EE_START_TAG the
positions of the pieces are all logged in the file.
The command is answered with a DGT_MSG_BUS_START_GAME_WRITTEN message,
about 70 msec. after receipt of DGT_BUS_SET_START_GAME
DGT_BUS_SEND_FROM_START
causes the board to send a DGT_MSG_BUS_FROM_START message, containing
all update information starting with EE_START_TAG until the last registered
changes (excluding the moves that are to be sent with the DGT_BUS_SEND_CHANGES
command). Remember that after the EE_START_TAG all piece positions are written
in the eeprom file.
DGT_BUS_PING
causes the addressed board to send a DGT_MSG_BUS_PING message.
NB: when the DGT_BUS_PING command is sent with board address 0 (zero )
all connected boards will reply with a DGT_MSG_BUS_PING message, randomly
spread over a 1100 msec. interval. This to avoid collision. For reliable
identification of all connected boards, this process should be repeated
sometimes with checking of checksums!
DGT_IGNORE_NEXT_BUS_PING
is used in the process of detecting connected boards on a bus. After this
command (which itself sends a DGT_MSG_BUS_PING as handshake) the first
following DGT_BUS_PING with address zero (!) is ignored. This command
can be used to suppress response of already detected boards, and decreases
the chance of bus collisions.
This command responds immediately with a DGT_MSG_BUS_PING.
DGT_BUS_END_BUSMODE
causes the board to quit busmode, and go into single-connection mode.
Be careful not to use this command in a multiple board configuration!
NOTE: Any single-board command arriving during bus mode will
switch a board to single-board mode and will be processed. When sent
with address 0 the command is processed on all connected boards
DGT_BUS_RESET
forces a power-up reset procedure. NB: this procedure takes some seconds.
When sent with address 0 the command is processed on all conected boards
DEFINITION OF THE MESSAGE DATA FORMATS FROM BOARD TO PC
-------------------------------------------------------
General: the message format is:
byte 1: message type byte (MSB = 1)
byte 2: message length MSB (from byte 1 to checksum) (D7=0)
byte 3: message length LSB (containing D0 to D6 of the length (D7 = 0)
byte 4: board address MSB (D7=0)
byte 5: board address LSB (D7=0)
< data bytes: 0 to theoretically 16K-6 bytes >
last byte: checksum. This is the sum of all byte values from byte 1 to
the byte before this checksum. D7 is forced to 0
DGT_MSG_BUS_BRD_DUMP
the data area contains the piece codes from field 1 to field 64, in format
identical as the single board command
DGT_MSG_BUS_BWTIME
the data area contains the clock time information, in format identical as
the single board command
DGT_MSG_BUS_UPDATE
the data area contains a variable amount of change information, formatted
as described in the DGT_DUMP_EEMOVES message
DGT_MSG_BUS_FROM_START
the data area contains a variable amount of change information, formatted
as described in the DGT_DUMP_EEMOVES message
DGT_MSG_BUS_PING
the data area is empty: a message of 6 bytes is returned.
DGT_MSG_BUS_START_GAME_WRITTEN
The same format as for DGT_MSG_BUS_PING
DGT_MSG_BUS_VERSION
The two data bytes contain binary version number: first byte main number
second byte sub number.
Tips for usage of the bus mode:
A. On connection of power and starting of the communication process:
- Check communication with addressed DGT_BUS_PING commands to all expected
boards.
LOOP:
- Send DGT_BUS_IGNORE_NEXT_PING to all found boards
- Check eventually extra boards or unknown board busnumbers by using
a DGT_BUS_PING with address zero.
- Register the found boards, and go to LOOP:, until no more boards are found
B. At the start of an event: when all boards have pieces in starting
position, send DGT_BUS_SET_START_GAME commands to all boards.
- Read full clock times from all boards.
C. During a game: send DGT_BUS_SEND_CHANGES to all boards sequentially,
once every few seconds. The returned data should logically match
with the expected piece positions. When any mismatch occurs: ask full
position with DGT_BUS_SEND_BRD.
D. When previous data are lost: send a DGT_BUS_SEND_FROM_START command
which returns the full registered changes from the starting position.
On every sent message: The responce time at the board is within milliseconds
normally, except when the board is storing a measured change in the
internal EEPROM: Then the responce time can be up to 20 milliseconds.
So allow a time-out on sent messages of say 80 mS.
Checksum errors: when a received checksum does not match, resend the command
except on the DGT_BUS_SEND_CHANGES: then the command DGT_BUS_REPEAT_CHANGES
should be used, to avoid discarding of the changes sent by the board.
On clock data:
- reading data out of the clock and make them available
for communication causes a delay of up to 1 second between clock display
and received data.
*/
#endif
ПриложениеЖ
Общая структура транслятора шахматных партий
Приложение З
Общая структура регистратора шахматных партий
Приложение И
Анализ результатов тестовых испытаний
№ п/п | Показатель | Абсолютныйколичественный показатель | Относительный количественный показатель в % | Степень соответствия условиям соревновательного процесса (субъективная оценка главного арбитра соревнований) |
1 | Количество сбоев в работе СШПО в ходе всего сорев-новательного про-цесса | 0 | – | ПОЛНОСТЬЮ СООТВЕТСТВУЕТ |
2 | Количество вре-менных простоев в работе СШПО в ходе всего сорев-новательного про-цесса | 0 | – | ПОЛНОСТЬЮ СООТВЕТСТВУЕТ |
3 | Количество несоот-ветствий отобража-емого хода ходу, сделанному на ша-хматной доске | 5 | 0,48 | ПОЛНОСТЬЮ СООТВЕТСТВУЕТ |
4 | Количество вре-менных задержек в ходе отображения игрового процесса | 1 | 0,01 | ПОЛНОСТЬЮ СООТВЕТСТВУЕТ |
5 | Количество вре-менных задержек переноса шахмат-ных партий в элек-тронную форму | 1 | 0,01 | ПОЛНОСТЬЮ СООТВЕТСТВУЕТ |
Директор СП «ШК» Амзоров А.М.
Главный арбитр соревнований Федоров В.Н.
Приложение К
Листинг модуля вещания шахматных партий
// Фигура
var Figure = {
create: function(color, type, vertical) {
function figure() {}
var self = new figure();
self.id = color + type + vertical;
self.image = document.createElement('img');
self.image.src = get_image_path() + (color + type + '.gif').toLowerCase();
self.image.size = '8x8';
return self;
}
};
// Поледоски
var Field = {
create: function(vertical, horizontal) {
function field() {}
var self = new field();
// Идентификатор поля, соответствует ячейке в таблице, являющейся шахматной доской
self.id = "field" + vertical + horizontal;
self.horizontal = horizontal;
self.vertical = vertical;
self.cell = $(self.id);
//
function v(letter) {
letter = letter.toLowerCase();
if(letter == 'a') {
return 1;
}
if(letter == 'b') {
return 2;
}
if(letter == 'c') {
return 3;
}
if(letter == 'd') {
return 4;
}
if(letter == 'e') {
return 5;
}
if(letter == 'f') {
return 6;
}
if(letter == 'g') {
return 7;
}
if(letter == 'h') {
return 8;
}
return 0;
}
var vv = v(self.vertical);
var hh = parseInt(self.horizontal);
function isWhite(summa) {
var is_white = (summa / 2) - (Math.floor(summa / 2)) == 0;
//log(summa + ' - ' + is_white);
return !is_white;
}
self.cell.className = isWhite(vv + hh) ? 'board_white_field' : 'board_black_field';
self.set_figure = function(figure) {
if(figure == null) {
log('null in ' + self.id);
}
self.delete_figure();
self.cell.appendChild(figure.image);
self.current_figure = figure;
}
self.init_figure = function(figure) {
self.set_figure(figure);
self.first_figure = figure;
self.last_figure = figure;
}
self.delete_figure = function() {
this.cell.innerHTML = "";
}
self.first_figure = null;
self.current_figure = null;
self.last_figure = null;
return self;
}
};
// Ходшахматнойпартии
var Move = {
create: function() {
function move() {}
var self = new move();
self.color = '';
self.next = null;
self.prev = null;
self.number = 0;
self.field_from = null;
self.field_to = null;
self.figure = null;
self.figure_dead = null;
self.is_short_castling = false;
self.is_long_castling = false;
self.forward = function() {
if(self.is_short_castling || self.is_long_castling) {
self.field_from[0].delete_figure();
self.field_from[1].delete_figure();
self.field_to[0].set_figure(self.figure[0]);
self.field_to[1].set_figure(self.figure[1]);
} else {
self.field_from.delete_figure();
self.field_to.set_figure(self.figure);
}
}
return self;
}
};
var Chess = {
version: "2.0",
refresh_delay: 2, // интервал времени между обновлениями позиции в секундах
repaint_delay: 0.5, // интервал времени между перерисовками позиции в секундах
moves: '/main/game_moves/1',
createBoard: function() {
var board = Board.create();
board.init();
return board;
},
createField: function(vertical, horizontal) {
var self = Field.create(vertical, horizontal);
return self;
},
createFigure: function(color, type, vertical) {
var self = Figure.create(color, type, vertical);
return self;
},
createMove: function() {
var self = Move.create();
return self;
}
};
// Шахматнаядоска
var Board = {
create: function() {
function board() { }
var self = new board();
self.white_number = 0;
self.black_number = 0;
self.first_move = null;
self.current_move = null;
self.last_move = null;
// Могут быть состояния
// listen - следить за ходом партий, отображаются актуальные ходы
// custom - наблюдатель выбрал произвольную позицию в партии и навигирует по партии свободно
self.status = 'listen';
self.fields = new Array(64);
self.figures = new Array(32);
self.all_moves = '';
// Обновление позиции
self.refresh = function() {
function existsMove(color, annotation) {
var move = getMove(color, annotation);
var exists = move != "******" && move != "";
return exists;
}
function getMove(color, annotation) {
var m = annotation.substring(color == 'w' ? 0 : 6, color == 'w' ? 6 : 12);
return m;
}
function isCastling(color, type, annotation) {
var move = getMove(color, annotation);
var castling = (type == 'short' ? move.substring(0, 3) == 'O-O' : move.substring(0, 5) == 'O-O-O');
return castling;
}
function getField(is_short, is_long, target, color, annotation) {
if(is_short || is_long) {
if(color == 'w') {
if(is_short) {
return new Array(self.fields[target == 'from' ? 4 : 6], self.fields[target == 'from' ? 7 : 5]);
}
if(is_long) {
return new Array(self.fields[target == 'from' ? 4 : 2], self.fields[target == 'from' ? 0 : 3]);
}
}
if(color == 'b') {
if(is_short) {
return new Array(self.fields[target == 'from' ? 60 : 62], self.fields[target == 'from' ? 63 : 61]);
}
if(is_long) {
return new Array(self.fields[target == 'from' ? 60 : 58], self.fields[target == 'from' ? 56 : 59]);
}
}
}
var field = annotation.substring(color == 'w' ? (target == 'from' ? 1 : 4) : (target == 'from' ? 7 : 10), color == 'w' ? (target == 'from' ? 3 : 6) : (target == 'from' ? 9 : 12));
var v = field.substring(0, 1).toLowerCase();
var h = field.substring(1, 2).toLowerCase();
//log('getField: v ' + v + ' h: ' + h);
var iField = (parseInt(h) - 1) * 8;
//log('tmp ' + iField);
if(v == 'b') {
iField += 1;