// set up the timer service for messages that need to be processed in the main RunUO thread for safety reasons
        public static void StartServerTimer(TimeSpan delay)
        {
            if (m_ServerTimer != null)
            {
                m_ServerTimer.Stop();
            }

            m_ServerTimer = new ServerTimer(delay);

            m_ServerTimer.Start();
        }
Exemple #2
0
        private void StartMenuItem_Click(Object sender, EventArgs e)
        {
            // Start the server.
            if (serverRunning)
            {
                return;
            }

            server.Start();
            serverRunning = true;

            ServerTimer.Start();

            log("Info", "Server starting...");

            StartMenuItem.Enabled = false;
            StopMenuItem.Enabled  = true;
        }
        // set up the timer service for messages that need to be processed in the main RunUO thread for safety reasons
        public static void StartServerTimer(TimeSpan delay)
        {
            if ( m_ServerTimer != null )
                m_ServerTimer.Stop();

            m_ServerTimer = new ServerTimer(delay);

            m_ServerTimer.Start();
        }
Exemple #4
0
        /// <summary></summary>
        public static async Task Main(string[] args)
        {
            // NOTE: このプログラム中では社員データ(もしくはユーザデータ)の同期を行わせないため,
            // 外部より任意の時点でそれらデータの同期を行わせる必要がある.

            // 蓄積したデータを対象として追加及び削除などの更新処理を行わせない.

            // データベース設定
            Db.DbFactory.GetInstance(
                await DbSettings.LoadAsync("db.conf"));

            try {
                readerSettings = await Settings.LoadAsync("settings.conf");
            } catch (Exception) {
                // 設定ファイルが存在しない場合や xml パースに失敗.
                readerSettings = new Settings()
                {
                    Id       = Guid.NewGuid(),
                    Hostname = "192.168.100.64"
                };
            } finally {
                if (readerSettings != null)
                {
                    readerId       = readerSettings.Id;
                    insideNumbers  = readerSettings.InsideAntennas;
                    outsideNumbers = readerSettings.OutsideAntennas;
                }
            }

            try {
                // データベースへ該当リーダのデータを追加
                await entleaving.Db.DAO.Reader.UpsertAsync(
                    readerSettings.Id,
                    readerSettings.Hostname,
                    null,
                    null);
            } catch {
                throw;
            }

            // FreeeAPI アクセストーク取得
            if (!File.Exists("access_token.json"))
            {
                throw new FileNotFoundException(
                          message:  null,
                          fileName: "access_token.json");
            }


            var freeeToken = await entleaving.freee.ResponseToken.LoadAsync("access_token.json");

            var freeeAPI = entleaving.freee.FreeeAPIFactory.GetInstance(freeeToken.AccessToken);

            freeeAPI.Token = freeeToken;
            try {
                var clientInfo = await entleaving.freee.FreeeAPIClientInfo.LoadAsync("freee_client.conf");

                freeeAPI.ClientId     = clientInfo.Id;
                freeeAPI.ClientSecret = clientInfo.Secret;
            } catch {
                Console.Error.WriteLine($"Warning # Freeee API のクライアント情報の取得に失敗. アクセストークンの更新が行えない可能性があります.");
            }


            // UHF 帯 RFID リーダ動作開始
            IUhfReader reader = new R420Reader();

            reader.ConnectionLost += OnUhfReaderConnectionLost;
            reader.DetectedTag    += OnUhfReaderDetectedTag;

            reader.Settings = readerSettings;
            reader.Open();
            reader.Start();

            Console.CancelKeyPress += OnCancelKeyPress;
            intervalTimer.Elapsed  += OnIntervalTimerElapsed;
            intervalTimer.Start();

            eventHandler = new EventWaitHandle(
                initialState: false,
                mode:         EventResetMode.ManualReset);
            eventHandler.WaitOne();

            reader.DetectedTag    -= OnUhfReaderDetectedTag;
            intervalTimer.Elapsed -= OnIntervalTimerElapsed;

            intervalTimer.Stop();
#if DEBUG
            Console.Error.WriteLine($"Debug Exit.");
#endif

            reader.Stop();
            reader.Close();
        }
Exemple #5
0
        /// <summary>
        /// Рисование карты
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void GameForm_Paint(object sender, PaintEventArgs e)
        {
            for (int i = 0; i < Server.number_of_strings; i++)
            {
                for (int j = 0; j < Server.number_of_columns; j++)
                {
                    switch (map[i, j])
                    {
                    case 0:     // трава
                    {
                        e.Graphics.DrawImage(Server.image_grass, Server.shift_of_map_Left + j * Server.size_of_cell, Server.shift_of_map_Top + i * Server.size_of_cell, Server.size_of_cell, Server.size_of_cell);
                        break;
                    }

                    case 1:     // непрогрызаемая стена
                    {
                        e.Graphics.DrawImage(Server.image_wall, Server.shift_of_map_Left + j * Server.size_of_cell, Server.shift_of_map_Top + i * Server.size_of_cell, Server.size_of_cell, Server.size_of_cell);
                        break;
                    }

                    case 2:     // бонус
                    {
                        e.Graphics.DrawImage(Server.image_bonus, Server.shift_of_map_Left + j * Server.size_of_cell, Server.shift_of_map_Top + i * Server.size_of_cell, Server.size_of_cell, Server.size_of_cell);
                        break;
                    }

                    case 3:     // сыр
                    {
                        e.Graphics.DrawImage(Server.image_cheese, Server.shift_of_map_Left + j * Server.size_of_cell, Server.shift_of_map_Top + i * Server.size_of_cell, Server.size_of_cell, Server.size_of_cell);
                        break;
                    }

                    case 4:     // обычная стена
                    {
                        e.Graphics.DrawImage(Server.image_wall, Server.shift_of_map_Left + j * Server.size_of_cell, Server.shift_of_map_Top + i * Server.size_of_cell, Server.size_of_cell, Server.size_of_cell);
                        break;
                    }

                    case 5:     // мышеловка
                    {
                        e.Graphics.DrawImage(Server.image_trap, Server.shift_of_map_Left + j * Server.size_of_cell, Server.shift_of_map_Top + i * Server.size_of_cell, Server.size_of_cell, Server.size_of_cell);
                        break;
                    }
                    }
                }
            }
            // Если мышь не одна, то прорисовываем остальных
            if (Mouse.mice.Count == 4)
            {
                e.Graphics.DrawImage(Mouse.mice[mouse0].image_mouse, Mouse.mice[mouse0].position);
                e.Graphics.DrawImage(Mouse.mice[mouse1].image_mouse, Mouse.mice[mouse1].position);
                e.Graphics.DrawImage(Mouse.mice[mouse2].image_mouse, Mouse.mice[mouse2].position);
                e.Graphics.DrawImage(Mouse.mice[mouse3].image_mouse, Mouse.mice[mouse3].position);
                ServerTimer.Start(); // Запускаем цикличную отправку/получения данных с сервера
            }
            // Прорисовываем текущую мышь
            e.Graphics.DrawImage(Mouse.mice[current_mouse].image_mouse, Mouse.mice[current_mouse].position);
            // Отображение некоторых данных на экране
            p1_number.Text = "Игрок №" + Convert.ToString(mouse0 + 1);
            p1_cheese.Text = "Собрано сыра: " + Mouse.mice[mouse0].number_of_cheeses.ToString();
            if (Mouse.mice.Count == 4)
            {
                p2_number.Text = "Игрок №" + Convert.ToString(mouse1 + 1);
                p2_cheese.Text = "Собрано сыра: " + Mouse.mice[mouse1].number_of_cheeses.ToString();
                p3_number.Text = "Игрок №" + Convert.ToString(mouse2 + 1);
                p3_cheese.Text = "Собрано сыра: " + Mouse.mice[mouse2].number_of_cheeses.ToString();
                p4_number.Text = "Игрок №" + Convert.ToString(mouse3 + 1);
                p4_cheese.Text = "Собрано сыра: " + Mouse.mice[mouse3].number_of_cheeses.ToString();
            }
        }