Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC TWR2024用 #142

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e29939f
Disable Secure Transport
TetsuOtter Jul 28, 2024
759e424
AfterRemarksを太字に変更
TetsuOtter Jul 31, 2024
0d015a3
Timetable周りのフォントサイズを定数化
TetsuOtter Jul 31, 2024
cbed6c1
Convert処理をstatic化
TetsuOtter Jul 31, 2024
5328b26
SelectedDBTrainDataを廃止
TetsuOtter Jul 31, 2024
29bb43a
データとしてNextTrainIdを追加
TetsuOtter Jul 31, 2024
ff167b7
「次列車へ」ボタンを追加
TetsuOtter Jul 31, 2024
df29471
locationデータが来ていない場合は位置情報を更新しないように修正
TetsuOtter Aug 14, 2024
132cab1
Train選択削除に伴い、Work/WorkGroupを同じサイズで表示するようにした
TetsuOtter Aug 14, 2024
166f47a
「次列車へ」ボタンで列車を切り替えた場合もハコタブの選択に反映されるように
TetsuOtter Aug 14, 2024
c7b1b2d
LogViewを削除
TetsuOtter Aug 14, 2024
8397579
「行路添付」ボタンをdisabledに変更
TetsuOtter Aug 14, 2024
c787272
HakoViewRowをタップし直して選択を解除する仕様を削除
TetsuOtter Aug 17, 2024
bb366dd
DBTrainDataListを削除
TetsuOtter Aug 17, 2024
1070d25
警告抑制
TetsuOtter Aug 17, 2024
0d5dd8a
NetworkSyncService リトライを実装
TetsuOtter Aug 17, 2024
6a378b3
Exceptionの場合にcontinueする前にCancelしていたので修正
TetsuOtter Aug 17, 2024
ebaac1a
[RFC用] 初期状態の接続先をRFC用に固定
TetsuOtter Aug 17, 2024
2250212
MacもDisable Transport Security
TetsuOtter Aug 17, 2024
945c4f8
列車が変更された際は、自動でスクロール位置を戻すようにした
TetsuOtter Aug 17, 2024
fe0be3c
念のためイベントはメインスレッドで実行させるように
TetsuOtter Aug 17, 2024
7cd73c4
AppLink経由で開くため、LocationService時点でのNetworkServiceセットは不要
TetsuOtter Aug 17, 2024
5b687f2
その列車の運転を完了した時点で次の列車に進むための実装、列車を運転可能になった時点で運転開始状態にする実装
TetsuOtter Aug 17, 2024
2d53fe9
Revert "AppLink経由で開くため、LocationService時点でのNetworkServiceセットは不要"
TetsuOtter Aug 18, 2024
4accff4
Locationのnull対策
TetsuOtter Aug 18, 2024
beb3ed3
なんかDebug.WriteLine追加したら動くようになった?
TetsuOtter Aug 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion TRViS.IO/Loaders/LoaderJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ private LoaderJson(WorkGroupData[] workGroups)
TrainNumber = trainData.TrainNumber,
WorkId = workId,
WorkType = trainData.WorkType,
// TODO: JSONでのNextTrainIdのサポート
NextTrainId = trainIndex != trainList.Length - 1 ? trainList[trainIndex + 1].Id : null
},
trainData.TimetableRows.Select((v, i) => new TimetableRow(
Id: v.Id ?? i.ToString(),
Expand Down Expand Up @@ -207,7 +209,8 @@ public void Dispose()
IsRideOnMoving: t.IsRideOnMoving,

// TODO: E電時刻表用の線色設定のサポート
LineColor_RGB: null
LineColor_RGB: null,
NextTrainId: t.NextTrainId
);
}

Expand Down
8 changes: 7 additions & 1 deletion TRViS.IO/Models/DBStructure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,9 @@ public class TrainData : IHasRemarksProperty, IEquatable<TrainData>
[Column("color_id")]
public int? ColorId { get; set; }

[Column("next_train_id")]
public string? NextTrainId { get; set; }

public bool Equals(TrainData? obj)
{
if (obj is null)
Expand Down Expand Up @@ -371,6 +374,8 @@ public bool Equals(TrainData? obj)
IsRideOnMoving == obj.IsRideOnMoving
&&
ColorId == obj.ColorId
&&
NextTrainId == obj.NextTrainId
);
}

Expand Down Expand Up @@ -401,11 +406,12 @@ public override int GetHashCode()
hashCode.Add(DayCount);
hashCode.Add(IsRideOnMoving);
hashCode.Add(ColorId);
hashCode.Add(NextTrainId);
return hashCode.ToHashCode();
}

public override string ToString()
=> $"TrainData[{WorkId} / {Id}](TrainNumber='{TrainNumber}', MaxSpeed='{MaxSpeed}', SpeedType='{SpeedType}', NominalTractiveCapacity='{NominalTractiveCapacity}', CarCount={CarCount}, Destination='{Destination}', BeginRemarks='{BeginRemarks}', AfterRemarks='{AfterRemarks}', Remarks='{Remarks}', BeforeDeparture='{BeforeDeparture}', TrainInfo='{TrainInfo}', Direction={Direction}, WorkType={WorkType}, AfterArrive='{AfterArrive}', BeforeDeparture_OnStationTrackCol='{BeforeDeparture_OnStationTrackCol}', AfterArrive_OnStationTrackCol='{AfterArrive_OnStationTrackCol}', DayCount={DayCount}, IsRideOnMoving={IsRideOnMoving}, ColorId={ColorId})";
=> $"TrainData[{WorkId} / {Id}](TrainNumber='{TrainNumber}', MaxSpeed='{MaxSpeed}', SpeedType='{SpeedType}', NominalTractiveCapacity='{NominalTractiveCapacity}', CarCount={CarCount}, Destination='{Destination}', BeginRemarks='{BeginRemarks}', AfterRemarks='{AfterRemarks}', Remarks='{Remarks}', BeforeDeparture='{BeforeDeparture}', TrainInfo='{TrainInfo}', Direction={Direction}, WorkType={WorkType}, AfterArrive='{AfterArrive}', BeforeDeparture_OnStationTrackCol='{BeforeDeparture_OnStationTrackCol}', AfterArrive_OnStationTrackCol='{AfterArrive_OnStationTrackCol}', DayCount={DayCount}, IsRideOnMoving={IsRideOnMoving}, ColorId={ColorId}, NextTrainId={NextTrainId})";
}

[Table("timetable_row")]
Expand Down
3 changes: 2 additions & 1 deletion TRViS.IO/Models/TrainData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ public record TrainData(
string? AfterArriveOnStationTrackCol = null,
int DayCount = 0,
bool? IsRideOnMoving = null,
int? LineColor_RGB = null
int? LineColor_RGB = null,
string? NextTrainId = null
) : IHasRemarksProperty;
13 changes: 9 additions & 4 deletions TRViS.NetworkSyncService/HttpDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,13 @@ void UpdateNextUri()
public async Task<SyncedData> GetSyncedDataAsync(CancellationToken token)
{
using HttpResponseMessage response = await _HttpClient.GetAsync(nextUri, token);
System.Diagnostics.Debug.WriteLine($"Uri: {nextUri}");
// 接続に失敗等しない限り、成功として扱う
// (ログ出力は今後検討)
if (!response.IsSuccessStatusCode)
{
return new(
Location_m: 0,
Location_m: double.NaN,
Time_ms: (long)DateTime.Now.TimeOfDay.TotalMilliseconds,
CanStart: false
);
Expand All @@ -110,16 +111,20 @@ public async Task<SyncedData> GetSyncedDataAsync(CancellationToken token)
if (json is null)
{
return new(
Location_m: 0,
Location_m: double.NaN,
Time_ms: (long)DateTime.Now.TimeOfDay.TotalMilliseconds,
CanStart: false
);
}
JsonElement root = json.RootElement;
double location_m = 0;
double location_m = double.NaN;
try
{
location_m = root.GetProperty(LOCATION_M_JSON_KEY).GetDouble();
JsonElement location_m_element = root.GetProperty(LOCATION_M_JSON_KEY);
if (location_m_element.ValueKind == JsonValueKind.Null)
location_m = double.NaN;
else
location_m = location_m_element.GetDouble();
}
catch (KeyNotFoundException) {}
catch (FormatException) {}
Expand Down
2 changes: 1 addition & 1 deletion TRViS.NetworkSyncService/NetworkSyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public async Task TickAsync(CancellationToken? cancellationToken = null)

void UpdateCurrentStationWithLocation(double location_m)
{
if (StaLocationInfo is null || !IsEnabled)
if (StaLocationInfo is null || !IsEnabled || double.IsNaN(location_m))
return;

bool isIn(double threshold1, double threshold2)
Expand Down
8 changes: 8 additions & 0 deletions TRViS/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Runtime.CompilerServices;
using TRViS.RootPages;
using TRViS.ViewModels;
using TRViS.IO.RequestInfo;

namespace TRViS;

Expand Down Expand Up @@ -54,6 +55,13 @@ public AppShell()
InstanceManager.AppViewModel.WindowHeight = DeviceDisplay.Current.MainDisplayInfo.Height;
logger.Trace("Display Width/Height: {0}x{1}", InstanceManager.AppViewModel.WindowWidth, InstanceManager.AppViewModel.WindowHeight);

Task.Run(() => InstanceManager.AppViewModel.HandleAppLinkUriAsync(new AppLinkInfo(
AppLinkInfo.FileType.Json,
new(1,0,0),
ResourceUri: new("http://twr.railway-fan-club.com/api/v1/trvis/timetable.json"),
RealtimeServiceUri: new("http://twr.railway-fan-club.com/api/v1/trvis/state")
), CancellationToken.None));

logger.Trace("AppShell Created");
}

Expand Down
125 changes: 0 additions & 125 deletions TRViS/Controls/LogView.cs

This file was deleted.

3 changes: 2 additions & 1 deletion TRViS/Controls/ToggleButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace TRViS.Controls;

[DependencyProperty<bool>("IsChecked", DefaultBindingMode = DefaultBindingMode.TwoWay)]
[DependencyProperty<bool>("IsRadio", DefaultBindingMode = DefaultBindingMode.OneWay)]
public partial class ToggleButton : ContentView
{
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
Expand All @@ -21,7 +22,7 @@ public ToggleButton()
Point? pt = e.GetPosition(this);
logger.Debug("Tapped (Pont: {0}, IsEnabled: {1}, IsChecked Before: {2})", pt, IsEnabled, IsChecked);
if (IsEnabled)
IsChecked = !IsChecked;
IsChecked = IsRadio || !IsChecked;
}
catch (Exception ex)
{
Expand Down
13 changes: 10 additions & 3 deletions TRViS/DTAC/DTACElementStyles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public static readonly AppThemeGenericsBindingExtension<Brush> MarkerMarkButtonB
new(0x00, 0x80, 0x00),
new(0x00, 0x80, 0x00)
);
public static readonly AppThemeColorBindingExtension SemiDarkGreen = new(
new(0x00, 0x77, 0x00),
new(0x00, 0x77, 0x00)
);
public static readonly AppThemeColorBindingExtension DarkGreen = new(
new(0x00, 0x44, 0x00),
new(0x00, 0x33, 0x00)
Expand All @@ -61,6 +65,8 @@ public static readonly AppThemeGenericsBindingExtension<Brush> MarkerMarkButtonB
public static readonly double DefaultTextSize = 14;
public static readonly double DefaultTextSizePlus = 15;
public static readonly double LargeTextSize = 24;
public static readonly double TimetableFontSize = DeviceInfo.Current.Platform == DevicePlatform.iOS ? 28 : 26;
public static readonly double TimetableRunLimitFontSize = DeviceInfo.Current.Platform == DevicePlatform.iOS ? 24 : 22;

public const int BeforeDeparture_AfterArrive_Height = 45;

Expand Down Expand Up @@ -165,6 +171,7 @@ public static Style BeforeRemarksStyleResource
v.HorizontalOptions = LayoutOptions.Start;
v.VerticalOptions = LayoutOptions.Start;
v.FontSize = DefaultTextSizePlus;
v.FontAttributes = FontAttributes.Bold;
v.LineHeight = DeviceInfo.Platform == DevicePlatform.Android ? 1.0 : 1.6;
// LineHeight分だけ上に隙間が空くため、MarginTopは設定しない
v.Margin = new(32, 0, 0, 0);
Expand Down Expand Up @@ -251,7 +258,7 @@ public static Style TimetableLabelStyleResource
};

_timetableLabelStyleResource.Setters.Add(Label.TextColorProperty, TimetableTextColor);
_timetableLabelStyleResource.Setters.Add(Label.FontSizeProperty, DeviceInfo.Current.Platform == DevicePlatform.iOS ? 28 : 26);
_timetableLabelStyleResource.Setters.Add(Label.FontSizeProperty, TimetableFontSize);
_timetableLabelStyleResource.Setters.Add(Label.FontAttributesProperty, FontAttributes.Bold);
_timetableLabelStyleResource.Setters.Add(Label.InputTransparentProperty, true);

Expand All @@ -263,7 +270,7 @@ public static Style TimetableLabelStyleResource
T v = LabelStyle<T>();

TimetableTextColor.Apply(v, Label.TextColorProperty);
v.FontSize = DeviceInfo.Current.Platform == DevicePlatform.iOS ? 28 : 26;
v.FontSize = TimetableFontSize;
v.FontAttributes = FontAttributes.Bold;
v.InputTransparent = true;

Expand Down Expand Up @@ -305,7 +312,7 @@ public static Style TimetableLargeNumberLabelStyleResource
{
T v = TimetableLargeNumberLabel<T>();

v.FontSize = DeviceInfo.Current.Platform == DevicePlatform.iOS ? 24 : 22;
v.FontSize = TimetableRunLimitFontSize;
v.Margin = v.Padding = new(0);
v.VerticalOptions = LayoutOptions.Center;

Expand Down
14 changes: 5 additions & 9 deletions TRViS/DTAC/HakoParts/SimpleRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,13 @@ static Frame GenSelectTrainButtonFrame(Label TrainNumberLabel)
return v;
}

readonly ToggleButton SelectTrainButton = new();
readonly ToggleButton SelectTrainButton;
static ToggleButton GenSelectTrainButton(Frame SelectTrainButtonFrame, EventHandler<ValueChangedEventArgs<bool>> IsSelectedChanged, int rowIndex)
{
ToggleButton v = new()
{
Content = SelectTrainButtonFrame,
IsRadio = true,
};

Grid.SetColumn(v, 1);
Expand Down Expand Up @@ -130,26 +131,21 @@ static Line GenRouteLine(int rowIndex)
}

public TrainData TrainData { get; }
public IO.Models.DB.TrainData DBTrainData { get; }
public TimetableRow? FirstRow { get; } = null;
public TimetableRow? LastRow { get; } = null;

readonly Grid ParentGrid;

public SimpleRow(Grid parentGrid, int dataIndex, TrainData TrainData, IO.Models.DB.TrainData DBTrainData)
public SimpleRow(Grid parentGrid, int dataIndex, TrainData TrainData)
{
logger.Debug("Creating");

this.TrainData = TrainData;
this.DBTrainData = DBTrainData;

if (TrainData.Rows is not null)
{
FirstRow = TrainData.Rows.FirstOrDefault(v => !v.IsInfoRow);
LastRow = TrainData.Rows.LastOrDefault(v => !v.IsInfoRow);
}

ParentGrid = parentGrid;

int rowIndex_StaName_SelectBtn = dataIndex * 2;
int rowIndex_time = rowIndex_StaName_SelectBtn + 1;

Expand Down Expand Up @@ -177,7 +173,7 @@ public SimpleRow(Grid parentGrid, int dataIndex, TrainData TrainData, IO.Models.
parentGrid.Add(RouteLine);
parentGrid.Add(ToTimeLabel);

SelectTrainButton.IsChecked = InstanceManager.AppViewModel.SelectedDBTrainData?.Id == DBTrainData.Id;
SelectTrainButton.IsChecked = InstanceManager.AppViewModel.SelectedTrainData?.Id == TrainData.Id;
SetTrainNumberButtonState();

logger.Debug("Created");
Expand Down
Loading
Loading