Iサーバー

概要

サーバーに関連する情報。

シグネチャ

1
public abstract interface IServer

 

名前空間

cAlgo.API.Internals

 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
 using cAlgo.API;
 namespace cAlgo
 {
     // このサンプルインジケーターは、サーバーおよび接続に関連するデータを取得するためにServerオブジェクトを使用する方法を示します。
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class ServerSample : Indicator
     {
         private TextBlock _isConnectedTextBlock;
         protected override void Initialize()
         {
             var grid = new Grid(4, 2)
             {
                 BackgroundColor = Color.Gold,
                 Opacity = 0.6,
                 HorizontalAlignment = HorizontalAlignment.Center,
                 VerticalAlignment = VerticalAlignment.Center,
             };
             var style = new Style();
             style.Set(ControlProperty.Padding, 5);
             style.Set(ControlProperty.Margin, 5);
             style.Set(ControlProperty.FontWeight, FontWeight.ExtraBold);
             style.Set(ControlProperty.BackgroundColor, Color.Black);
             grid.AddChild(new TextBlock { Text = "サーバー情報", Style = style, HorizontalAlignment = HorizontalAlignment.Center }, 0, 0, 1, 2);
             grid.AddChild(new TextBlock { Text = "時間", Style = style }, 1, 0);
             grid.AddChild(new TextBlock { Text = Server.Time.ToString("o"), Style = style }, 1, 1);
             grid.AddChild(new TextBlock { Text = "時間 (UTC)", Style = style }, 2, 0);
             grid.AddChild(new TextBlock { Text = Server.TimeInUtc.ToString("o"), Style = style }, 2, 1);
             grid.AddChild(new TextBlock { Text = "接続状態", Style = style }, 3, 0);
             _isConnectedTextBlock = new TextBlock
             {
                 Text = Server.IsConnected ? "はい" : "いいえ",
                 Style = style,
             };
             Server.Connected += () => _isConnectedTextBlock.Text = "はい";
             Server.Disconnected += () => _isConnectedTextBlock.Text = "いいえ";
             grid.AddChild(_isConnectedTextBlock, 3, 1);
             Chart.AddControl(grid);
         }
         public override void Calculate(int index)
         {
         }
     }
 }

プロパティ

Time

概要

サーバー時刻を返します。

シグネチャ

1
public abstract DateTime Time {get;}

 

戻り値

DateTime

1
 protected override void OnTick()
 {
     Print("サーバー時刻: {0}", Server.Time);
 }

TimeInUtc

概要

UTCでのサーバー時刻を返します。

シグネチャ

1
public abstract DateTime TimeInUtc {get;}

 

戻り値

DateTime

1
 protected override void OnTick()
 {
     Print("サーバーのUTC時刻: {0}", Server.TimeInUtc);
 }

IsConnected

概要

サーバーとの現在の接続状態を示します

シグネチャ

1
public abstract bool IsConnected {get;}

 

戻り値

bool

イベント

Connected

概要

サーバーに正常に接続されたときに発生するイベント

シグネチャ

1
public abstract event Action Connected;

Disconnected

概要

サーバーとの接続が切れたときに発生するイベント

シグネチャ

1
public abstract event Action Disconnected;
目次

このページについて