Commit e3319fdc authored by sugita mamoru's avatar sugita mamoru

Merge commit '1e705b85' into develop

parents 73b67541 1e705b85
...@@ -1140,6 +1140,7 @@ ...@@ -1140,6 +1140,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Sailassist/Sailassist.entitlements; CODE_SIGN_ENTITLEMENTS = Sailassist/Sailassist.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Sailassist/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"Sailassist/Preview Content\"";
...@@ -1169,6 +1170,7 @@ ...@@ -1169,6 +1170,7 @@
OTHER_SWIFT_FLAGS = "-D CANARY -D COCOAPODS"; OTHER_SWIFT_FLAGS = "-D CANARY -D COCOAPODS";
PRODUCT_BUNDLE_IDENTIFIER = com.jrc.sailassist.canary; PRODUCT_BUNDLE_IDENTIFIER = com.jrc.sailassist.canary;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0; SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2"; TARGETED_DEVICE_FAMILY = "1,2";
......
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Release" buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = ""
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.IDEFoundation.Launcher.PosixSpawn"
launchStyle = "0" launchStyle = "0"
useCustomWorkingDirectory = "NO" useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO" ignoresPersistentStateOnLaunch = "NO"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import Foundation import Foundation
import CoreLocation import CoreLocation
#if false #if true
//ECA Coordinates China //ECA Coordinates China
var chinaShore:[CLLocationCoordinate2D] = [ var chinaShore:[CLLocationCoordinate2D] = [
CLLocationCoordinate2D(latitude: 39.82805556, longitude: 124.16833333), CLLocationCoordinate2D(latitude: 39.82805556, longitude: 124.16833333),
...@@ -4313,26 +4313,27 @@ class EcaCoordinatesTable : NSObject { ...@@ -4313,26 +4313,27 @@ class EcaCoordinatesTable : NSObject {
} }
var ecaDataTable:[ecaData] = [ var ecaDataTable:[ecaData] = [
// ecaData(id: 11, name: "North American Atlantic Coasts", table: northAmericanAtlanticCoasts) ecaData(id: 1, name: "Iceland", table: iceland),
// ecaData(id: 12, name: "North American Hawai", table: northAmericanHawai), ecaData(id: 11, name: "North American Atlantic Coasts", table: northAmericanAtlanticCoasts),
// ecaData(id: 31, name: "Unites States Caribbean", table: unitesStatesCaribbean), ecaData(id: 12, name: "North American Hawai", table: northAmericanHawai),
// ecaData(id: 21, name: "North Sea 1", table: northSea1), //err ecaData(id: 13, name: "North American Pacific Coasts", table: northAmericanPacificCoasts),
// ecaData(id: 22, name: "North Sea 2", table: northSea2), ecaData(id: 21, name: "North Sea 1", table: northSea1), //err
// ecaData(id: 1, name: "Iceland", table: iceland), ecaData(id: 22, name: "North Sea 2", table: northSea2),
// ecaData(id: 7, name: "China Shore", table: chinaShore), ecaData(id: 31, name: "Unites States Caribbean", table: unitesStatesCaribbean),
// ecaData(id: 8, name: "China Hainan", table: chinaHainan), ecaData(id: 41, name: "China Shore", table: chinaShore),
// ecaData(id: 9, name: "China Yangtzi Shuifu,Yunnan", table: chinaYangtziShuifuYunnan), //err ecaData(id: 42, name: "China Hainan", table: chinaHainan),
// ecaData(id: 10, name: "China Yangtzi Liuhekou,Jiangsu1", table: chinaYangtziLiuhekouJiangsu1), ecaData(id: 43, name: "China Yangtzi Shuifu,Yunnan", table: chinaYangtziShuifuYunnan), //err
// ecaData(id: 11, name: "China Yangtzi Liuhekou,Jiangsu2", table: chinaYangtziLiuhekouJiangsu2), ecaData(id: 44, name: "China Yangtzi Liuhekou,Jiangsu1", table: chinaYangtziLiuhekouJiangsu1),
// ecaData(id: 12, name: "China Xijiang Nanning,Guangxi", table: chinaXijiangNanningGuangxi), //err ecaData(id: 45, name: "China Yangtzi Liuhekou,Jiangsu2", table: chinaYangtziLiuhekouJiangsu2),
// ecaData(id: 13, name: "China Xijiang Zhaoqing,Guangdong", table: chinaXijiangNanningGuangdong), //err ecaData(id: 46, name: "China Xijiang Nanning,Guangxi", table: chinaXijiangNanningGuangxi), //err
// ecaData(id: 14, name: "Korea Incheon, PyeongtaekDangjin Port", table: incheonPyeongtaekDanjinPort), ecaData(id: 47, name: "China Xijiang Zhaoqing,Guangdong", table: chinaXijiangNanningGuangdong), //err
// ecaData(id: 15, name: "Korea Yeosu, Gwangyang Port", table: yeosuGwangyangPort), ecaData(id: 51, name: "Korea Incheon, PyeongtaekDangjin Port", table: incheonPyeongtaekDanjinPort),
// ecaData(id: 16, name: "Korea Busan Port", table: koreaBusanPort), ecaData(id: 52, name: "Korea Yeosu, Gwangyang Port", table: yeosuGwangyangPort),
// ecaData(id: 17, name: "Korea Busan Port West", table: koreaBusanPortWest), ecaData(id: 53, name: "Korea Busan Port", table: koreaBusanPort),
// ecaData(id: 18, name: "Korea Ulsan Port", table: koreaUlsanPort), ecaData(id: 54, name: "Korea Busan Port West", table: koreaBusanPortWest),
// ecaData(id: 19, name: "Panama Canal Atlantic Entrance", table: panamaCanalAtlanticEntrance), ecaData(id: 55, name: "Korea Ulsan Port", table: koreaUlsanPort),
ecaData(id: 20, name: "Panama Canal Pacific Entrance", table: panamaCanalPacificEntrance) ecaData(id: 61, name: "Panama Canal Atlantic Entrance", table: panamaCanalAtlanticEntrance),
ecaData(id: 62, name: "Panama Canal Pacific Entrance", table: panamaCanalPacificEntrance)
] ]
func setEcaData() { func setEcaData() {
......
...@@ -46,9 +46,8 @@ class EcaTask { ...@@ -46,9 +46,8 @@ class EcaTask {
SharingData.my.dataTime = res.dataTime //2023-11-02T05:25:49.4362123Z SharingData.my.dataTime = res.dataTime //2023-11-02T05:25:49.4362123Z
SharingData.my.setLocation() SharingData.my.setLocation()
if Preferences.LocationType == 1 {
checkEca() checkEca()
}
} }
case .failure(let errorCode): case .failure(let errorCode):
print(debug: errorCode) print(debug: errorCode)
...@@ -58,42 +57,92 @@ class EcaTask { ...@@ -58,42 +57,92 @@ class EcaTask {
func checkEca() { func checkEca() {
let runningEca = eca.ecaArea.first(where: {(key, value) in value.isRunning == true}) let runningEca = eca.ecaArea.first(where: {(key, value) in value.isRunning == true})
if let eca = runningEca?.value { if var eca = runningEca?.value {
if let location = SharingData.my.location { if let location = SharingData.my.location {
if let distance = LocationCalculation.checkPolyline(objPos: eca.points, shipPos: location) { if var distance = LocationCalculation.checkPolyline(objPos: eca.points, shipPos: location) {
//起動時に状態を設定
if SharingData.my.ecaStatus == nil {
eca = runningEcaStatus(eca: eca, distance: distance)
}
if eca.swNotice >= Float(distance) && eca.status == EcaState.running { if eca.swNotice >= Float(distance) && eca.status == EcaState.running {
notificationEca(point: SwitchingEca.Notice) notificationEca(point: SwitchingEca.Notice)
SharingData.eca.isShowEcaAlert = true SharingData.eca.isShowEcaAlert = true
var newData = eca SharingData.my.ecaStatus = EcaState.noticePass
newData.status = EcaState.noticePass
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Notice)
} }
if eca.swStart >= Float(distance) && eca.status == EcaState.noticePass { if eca.swStart >= Float(distance) && eca.status == EcaState.noticePass {
notificationEca(point: SwitchingEca.Start) notificationEca(point: SwitchingEca.Start)
SharingData.eca.isShowEcaAlert = true SharingData.eca.isShowEcaAlert = true
var newData = eca SharingData.my.ecaStatus = EcaState.startPass
newData.status = EcaState.startPass
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Start)
} }
if eca.swFinish >= Float(distance) && eca.status == EcaState.startPass { if eca.swFinish >= Float(distance) && 0.0 < Float(distance) && eca.status == EcaState.startPass {
notificationEca(point: SwitchingEca.Finish) notificationEca(point: SwitchingEca.Finish)
SharingData.eca.isShowEcaAlert = true SharingData.eca.isShowEcaAlert = true
var newData = eca SharingData.my.ecaStatus = EcaState.finishPass
newData.status = EcaState.finishPass
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Finish)
} }
if 0.0 <= Float(distance) && eca.status == EcaState.finishPass { if 0.0 >= Float(distance) && eca.status == EcaState.startPass {
SharingData.eca.isShowEcaAlert = true SharingData.eca.isShowEcaAlert = true
var newData = eca SharingData.my.ecaStatus = EcaState.incomplete
newData.status = EcaState.incomplete
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Incomplete)
} }
} }
} }
} else {
SharingData.my.ecaStatus = nil
}
}
func runningEcaStatus(eca: RegisteredEca, distance: Double) -> RegisteredEca {
var result = false
var newData = eca
if 0.0 >= Float(distance){
newData.status = EcaState.incomplete
result = true
}
if eca.swFinish >= Float(distance) && result == false{
newData.status = EcaState.startPass
result = true
}
if eca.swStart >= Float(distance) && result == false{
newData.status = EcaState.startPass
result = true
}
if eca.swNotice >= Float(distance) && result == false{
newData.status = EcaState.noticePass
}
return newData
}
func chengeEcaStatus(eca: RegisteredEca) {
if eca.status == EcaState.running {
var newData = eca
newData.status = EcaState.noticePass
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Notice)
}
if eca.status == EcaState.noticePass {
var newData = eca
newData.status = EcaState.startPass
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Start)
}
if eca.status == EcaState.startPass {
var newData = eca
newData.status = EcaState.finishPass
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Finish)
}
if eca.status == EcaState.finishPass {
var newData = eca
newData.status = EcaState.incomplete
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Incomplete)
} }
} }
} }
...@@ -33,6 +33,9 @@ class GetEcaList { ...@@ -33,6 +33,9 @@ class GetEcaList {
if ecaList.status & serverRunning == serverRunning { if ecaList.status & serverRunning == serverRunning {
value.isRunning = true value.isRunning = true
value.status = setEcaServer(status: ecaList.status) value.status = setEcaServer(status: ecaList.status)
} else {
value.isRunning = false
value.status = EcaState.register
} }
ecaData.ecaArea.updateValue(value, forKey: ecaList.taskName) ecaData.ecaArea.updateValue(value, forKey: ecaList.taskName)
} }
...@@ -45,9 +48,8 @@ class GetEcaList { ...@@ -45,9 +48,8 @@ class GetEcaList {
} }
private func setEcaServer(status: Int) -> EcaState { private func setEcaServer(status: Int) -> EcaState {
let statusInf = status ^ serverRunning
var state = EcaState.register var state = EcaState.register
switch statusInf { switch status {
case serverRunning: case serverRunning:
state = EcaState.running state = EcaState.running
case serverNoticePass: case serverNoticePass:
......
...@@ -21,9 +21,9 @@ enum EcaState { ...@@ -21,9 +21,9 @@ enum EcaState {
let serverRegister = 0x00000000 //登録 let serverRegister = 0x00000000 //登録
let serverRunning = 0x10000000 //ECAタスク実行開始 let serverRunning = 0x10000000 //ECAタスク実行開始
let serverNoticePass = 0x00000001 //ECA通知円到達 let serverNoticePass = 0x10000001 //ECA通知円到達
let serverStartPass = 0x00000002 //ECA開始円到達 let serverStartPass = 0x10000002 //ECA開始円到達
let serverFinishPass = 0x00000004 //ECAタスク終了円到達 let serverFinishPass = 0x10000004 //ECAタスク終了円到達
let serverEnd = 0x00000100 //ECAタスク完了(燃料切替実施済み) let serverEnd = 0x00000100 //ECAタスク完了(燃料切替実施済み)
let serverIncomplete = 0x00000200 //ECAタスク未完了 (燃料切替未実施で終了) let serverIncomplete = 0x00000200 //ECAタスク未完了 (燃料切替未実施で終了)
let serverCancel = 0x00000400 //ECAタスクキャンセル (タスク終了・タスク未完了前にキャンセル) let serverCancel = 0x00000400 //ECAタスクキャンセル (タスク終了・タスク未完了前にキャンセル)
......
...@@ -50,20 +50,38 @@ enum HttpRequestType : String { ...@@ -50,20 +50,38 @@ enum HttpRequestType : String {
//MARK: 運用サーバー用 //MARK: 運用サーバー用
enum HttpRequestType : String { enum HttpRequestType : String {
case Terms = "https://tacmistorage.blob.core.windows.net/$web/terms/terms.mobile.html?sv=2021-10-04&st=2023-11-22T06%3A26%3A32Z&se=2023-11-23T06%3A26%3A32Z&sr=b&sp=r&sig=wS6kbbT5SvNVTkRsnRk%2BiDceZAsQ3Y56vrqTUO1X50E%3D" case Terms = "https://tacmistorage.blob.core.windows.net/$web/terms/terms.mobile.html?sv=2021-10-04&st=2023-11-22T06%3A26%3A32Z&se=2023-11-23T06%3A26%3A32Z&sr=b&sp=r&sig=wS6kbbT5SvNVTkRsnRk%2BiDceZAsQ3Y56vrqTUO1X50E%3D"
case RegisterLogin = "https://ssv.jmarinecloud.com/sailassistlogin" case RegisterLogin = "https://ssv-canary-web.azurewebsites.net/sailassistlogin"
case SitePolicy = "https://ssv.jmarinecloud.com/sitepolicy" case SitePolicy = "https://ssv-canary-web.azurewebsites.net/sitepolicy"
case CookiePolicy = "https://ssv.jmarinecloud.com/cookiepolicy" case CookiePolicy = "https://ssv-canary-web.azurewebsites.net/cookiepolicy"
case PrivacyPolicy = "https://ssv.jmarinecloud.com/inapp?" //+バージョン番号 case PrivacyPolicy = "https://ssv-canary-web.azurewebsites.net/inapp?" //+バージョン番号
case TaskList = "https://ssv.jmarinecloud.com/api/sailassist/tasklist/XXXXX" case TaskList = "https://ssv-canary-web.azurewebsites.net/api/sailassist/tasklist/XXXXX"
case EcaArea = "https://ssv.jmarinecloud.com/api/sailassist/ecaarea" case EcaArea = "https://ssv-canary-web.azurewebsites.net/api/sailassist/ecaarea/XXXXX"
case ShipStatus = "https://ssv.jmarinecloud.com/api/sailassist/shipstatus/XXXXX" case ShipStatus = "https://ssv-canary-web.azurewebsites.net/api/sailassist/shipstatus/XXXXX"
case ShipMonitoringRoute = "https://ssv.jmarinecloud.com/api/sailassist/shipmonitoringroute/XXXXX" case ShipMonitoringRoute = "https://ssv-canary-web.azurewebsites.net/api/sailassist/shipmonitoringroute/XXXXX"
case GetMessage = "https://ssv.jmarinecloud.com/api/chatdata/getmessages?shipId=XXXXX" case GetMessage = "https://ssv-canary-web.azurewebsites.net/api/chatdata/getmessages?shipId=XXXXX"
case SignalR = "https://ssv.jmarinecloud.com/signalr/shore" case SignalR = "https://ssv-canary-web.azurewebsites.net/signalr/shore"
case PushHistory = "https://ssv.jmarinecloud.com/api/sailassist/pushhistory/XXXXX" case PushHistory = "https://ssv-canary-web.azurewebsites.net/api/sailassist/pushhistory/XXXXX"
case UploadImage = "https://ssv.jmarinecloud.com/api/chatdata/uploadimage" case UploadImage = "https://ssv-canary-web.azurewebsites.net/api/chatdata/uploadimage"
case ConnectionString = "Endpoint=sb://tacmihub.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=/IOJAYGLZmS2JvlsHT5aT+ETlPXqNt1+VGuMNDt4bzw=" case ConnectionString = "Endpoint=sb://ssv-canary-notification.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=zHzVMA757FciMum5jVG4NMl82YpYVzclUgCiKOVRKf8="
case HubName = "tacmihub" case HubName = "ssv-canary-sailassist-notification"
case storage = "https://tacmistorage.z31.web.core.windows.net/" case storage = "https://ssvcanarystorage.z1.web.core.windows.net/"
} }
//enum HttpRequestType : String {
// case Terms = "https://tacmistorage.blob.core.windows.net/$web/terms/terms.mobile.html?sv=2021-10-04&st=2023-11-22T06%3A26%3A32Z&se=2023-11-23T06%3A26%3A32Z&sr=b&sp=r&sig=wS6kbbT5SvNVTkRsnRk%2BiDceZAsQ3Y56vrqTUO1X50E%3D"
// case RegisterLogin = "https://ssv.jmarinecloud.com/sailassistlogin"
// case SitePolicy = "https://ssv.jmarinecloud.com/sitepolicy"
// case CookiePolicy = "https://ssv.jmarinecloud.com/cookiepolicy"
// case PrivacyPolicy = "https://ssv.jmarinecloud.com/inapp?" //+バージョン番号
// case TaskList = "https://ssv.jmarinecloud.com/api/sailassist/tasklist/XXXXX"
// case EcaArea = "https://ssv.jmarinecloud.com/api/sailassist/ecaarea"
// case ShipStatus = "https://ssv.jmarinecloud.com/api/sailassist/shipstatus/XXXXX"
// case ShipMonitoringRoute = "https://ssv.jmarinecloud.com/api/sailassist/shipmonitoringroute/XXXXX"
// case GetMessage = "https://ssv.jmarinecloud.com/api/chatdata/getmessages?shipId=XXXXX"
// case SignalR = "https://ssv.jmarinecloud.com/signalr/shore"
// case PushHistory = "https://ssv.jmarinecloud.com/api/sailassist/pushhistory/XXXXX"
// case UploadImage = "https://ssv.jmarinecloud.com/api/chatdata/uploadimage"
// case ConnectionString = "Endpoint=sb://tacmihub.servicebus.windows.net/;SharedAccessKeyName=DefaultListenSharedAccessSignature;SharedAccessKey=/IOJAYGLZmS2JvlsHT5aT+ETlPXqNt1+VGuMNDt4bzw="
// case HubName = "tacmihub"
// case storage = "https://tacmistorage.z31.web.core.windows.net/"
//}
#endif #endif
...@@ -711,10 +711,10 @@ class LocationCalculation{ ...@@ -711,10 +711,10 @@ class LocationCalculation{
if (rtn1.retCode) { if (rtn1.retCode) {
distance = nil distance = nil
} else { } else {
distance = rtn1.xte distance = rtn1.xte * -1
} }
} else { } else {
distance = rtn.xte distance = rtn.xte * -1
} }
if let dist = distance { if let dist = distance {
...@@ -869,7 +869,7 @@ class LocationCalculation{ ...@@ -869,7 +869,7 @@ class LocationCalculation{
if outside { if outside {
distance *= -1 distance *= -1
} }
print(debug: "checkPolyLine \(distance)") print(debug: "pointsDistance \(distance)")
return (lineOut, distance) return (lineOut, distance)
} }
......
...@@ -20,11 +20,12 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate { ...@@ -20,11 +20,12 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
super.init() super.init()
locationManager.delegate = self locationManager.delegate = self
locationManager.activityType = .automotiveNavigation
locationManager.distanceFilter = 100 //100mぐらい移動したら位置情報取得
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.allowsBackgroundLocationUpdates = true // バックグラウンド実行中も座標取得する場合、trueにする locationManager.allowsBackgroundLocationUpdates = true // バックグラウンド実行中も座標取得する場合、trueにする
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.distanceFilter = 10 //10mぐらい移動したら位置情報取得
locationManager.pausesLocationUpdatesAutomatically = false locationManager.pausesLocationUpdatesAutomatically = false
locationManager.activityType = .otherNavigation
locationManager.startUpdatingLocation() locationManager.startUpdatingLocation()
} }
...@@ -39,14 +40,13 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate { ...@@ -39,14 +40,13 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let newLocation = locations.last { if let newLocation = locations.last {
lastSeenLocation = locations.first print(debug: "called")
lastSeenLocation = newLocation
let targetCoordinate : CLLocationCoordinate2D = lastSeenLocation!.coordinate let targetCoordinate : CLLocationCoordinate2D = lastSeenLocation!.coordinate
SharingData.my.gps = targetCoordinate SharingData.my.gps = targetCoordinate
SharingData.my.setLocation() SharingData.my.setLocation()
if Preferences.LocationType == 0 { ecaTask.checkEca()
ecaTask.checkEca()
}
} }
} }
......
...@@ -181,7 +181,10 @@ struct LoginView: View { ...@@ -181,7 +181,10 @@ struct LoginView: View {
Preferences.lastLoginDate_Int64 = DateTextLib.Date2UnixTime(date: Date()) Preferences.lastLoginDate_Int64 = DateTextLib.Date2UnixTime(date: Date())
isLogin = true isLogin = true
timer = Timer.scheduledTimer(withTimeInterval: 60.0, repeats: true) { _ in // let ecaArea = EcaArea()
// ecaArea.start()
timer = Timer.scheduledTimer(withTimeInterval: 60.0 * 10, repeats: true) { _ in
print(debug: "called timer") print(debug: "called timer")
let eca = EcaTask() let eca = EcaTask()
eca.start() eca.start()
......
...@@ -21,7 +21,7 @@ struct InputUserNameView: View { ...@@ -21,7 +21,7 @@ struct InputUserNameView: View {
var body: some View { var body: some View {
VStack{ VStack{
VStack(alignment: .leading, spacing: 0) { VStack(alignment: .leading, spacing: 0) {
Text("JRC Ship") Text(SharingData.my.company)
.font(FontStyle.TitleSBold.font) .font(FontStyle.TitleSBold.font)
.padding(.leading, 10) .padding(.leading, 10)
.foregroundColor(.white) .foregroundColor(.white)
...@@ -114,8 +114,11 @@ struct InputUserNameView: View { ...@@ -114,8 +114,11 @@ struct InputUserNameView: View {
let route = MonitoringRoute() let route = MonitoringRoute()
route.start() route.start()
// let ecaList = GetEcaList() let ecaList = GetEcaList()
// ecaList.start() ecaList.start()
let pushHistory = GetPushHistory()
pushHistory.start()
} }
timer?.fire() timer?.fire()
......
...@@ -27,7 +27,7 @@ struct MapTaskView: View { ...@@ -27,7 +27,7 @@ struct MapTaskView: View {
@State var edittingEcaArea: RegisteredEca? = nil @State var edittingEcaArea: RegisteredEca? = nil
@State var isShowSettingView : Bool = false @State var isShowSettingView : Bool = false
@ObservedObject var eca = SharingData.eca @ObservedObject var eca = SharingData.eca
var body: some View { var body: some View {
VStack{ VStack{
Capsule() Capsule()
...@@ -37,16 +37,15 @@ struct MapTaskView: View { ...@@ -37,16 +37,15 @@ struct MapTaskView: View {
//タイトルエリア //タイトルエリア
HStack{ HStack{
Button(action: { Button(action: {
viewMode = .SwitchingMenu viewMode = .SwitchingMenu
isShowSettingView = false isShowSettingView = false
if var eca = SharingData.eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{ if var eca = SharingData.eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{
eca.status = .noticePass eca.status = .noticePass
// SharingData.eca.editEcaArea(key: eca.name, value: eca) // SharingData.eca.editEcaArea(key: eca.name, value: eca)
SharingData.eca.isShowEcaAlert = true SharingData.eca.isShowEcaAlert = true
} }
}, label: { }, label: {
if viewMode != .SwitchingMenu || isShowSettingView{ if viewMode != .SwitchingMenu || isShowSettingView{
...@@ -54,34 +53,30 @@ struct MapTaskView: View { ...@@ -54,34 +53,30 @@ struct MapTaskView: View {
} }
}) })
.frame(width: 48, height: 48) .frame(width: 48, height: 48)
Spacer() Spacer()
Text(viewMode.title) Text(viewMode.title)
.font(FontStyle.TitleL.font) .font(FontStyle.TitleL.font)
.frame(height: 20) .frame(height: 20)
.padding(.vertical, 14) .padding(.vertical, 14)
Spacer() Spacer()
Button(action: { Button(action: {
}, label: { }, label: {
}) })
.frame(width: 48, height: 48) .frame(width: 48, height: 48)
} }
.padding(EdgeInsets(top: 10, leading: 8, bottom: 13, trailing: 17)) .padding(EdgeInsets(top: 10, leading: 8, bottom: 13, trailing: 17))
Divider() Divider()
.background(ColorSet.LineColor03.color) .background(ColorSet.LineColor03.color)
ScrollView(.vertical){ ScrollView(.vertical){
switch viewMode { switch viewMode {
case .SwitchingMenu: case .SwitchingMenu:
...@@ -93,42 +88,53 @@ struct MapTaskView: View { ...@@ -93,42 +88,53 @@ struct MapTaskView: View {
case .EcaList: case .EcaList:
EcaListView() EcaListView()
} }
} }
Spacer() Spacer()
.frame(height: 55) .frame(height: 55)
} }
.onAppear{ .onAppear{
EcaCoordinatesTable().setEcaData() EcaCoordinatesTable().setEcaData()
} }
.alert("", isPresented: $eca.isShowEcaAlert) { .alert("", isPresented: $eca.isShowEcaAlert) {
if var ecaArea = eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first, ecaArea.status == .finishPass{ if var ecaArea = eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{
Button("Yes"){ if SharingData.my.ecaStatus == .finishPass{
ecaArea.status = .end Button("Yes"){
} var newData = ecaArea
Button("No"){ newData.isRunning = false
ecaArea.status = .incomplete newData.status = EcaState.end
} SharingData.eca.editEcaArea(key: ecaArea.name, value: newData, type: EcaOperation.Finish)
}else{ }
Button("OK"){ Button("No"){
var newData = ecaArea
newData.isRunning = false
newData.status = EcaState.incomplete
SharingData.eca.editEcaArea(key: ecaArea.name, value: newData, type: EcaOperation.Incomplete)
}
}else{
Button("OK"){
let ecaTask = EcaTask()
ecaTask.chengeEcaStatus(eca: ecaArea)
}
} }
} }
} message: { } message: {
if let ecaArea = eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{ if let ecaArea = eca.ecaArea.map{ $0.1 }.filter{ $0.isRunning }.first{
switch ecaArea.status{ if let status = SharingData.my.ecaStatus {
case .noticePass: switch status {
Text("Arrived at advance notice point.") case .noticePass:
case .startPass: Text("Arrived at advance notice point.")
Text("Arrived at switching start point.") case .startPass:
case .finishPass: Text("Arrived at switching start point.")
Text("Have you finished \(ecaArea.name) fuel switching?") case .finishPass:
case .incomplete: Text("Have you finished \(ecaArea.name) fuel switching?")
Text("Have you finished \(ecaArea.name) fuel switching?\nIf you finish, you disable it.") case .incomplete:
default: Text("Have you finished \(ecaArea.name) fuel switching?\nIf you finish, you disable it.")
Text("") default:
Text("")
}
} }
} }
} }
......
...@@ -35,6 +35,7 @@ struct TaskSwitchingMenuView: View { ...@@ -35,6 +35,7 @@ struct TaskSwitchingMenuView: View {
if isEcaAlert == false { if isEcaAlert == false {
var newData = eca var newData = eca
newData.isRunning = true newData.isRunning = true
newData.status = EcaState.running
SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Running) SharingData.eca.editEcaArea(key: eca.name, value: newData, type: EcaOperation.Running)
} }
} label: { } label: {
......
...@@ -56,10 +56,10 @@ struct MenuView: View { ...@@ -56,10 +56,10 @@ struct MenuView: View {
HStack { HStack {
VStack(alignment: .leading, spacing: 10){ VStack(alignment: .leading, spacing: 10){
Text("Japan Radio Co.,Ltd.") Text(SharingData.my.company)
.font(FontStyle.TitleL.font) .font(FontStyle.TitleL.font)
.foregroundColor(ColorSet.Body.color) .foregroundColor(ColorSet.Body.color)
Text("会社名一般") Text("Company name general")
.font(FontStyle.EmphasisText.font) .font(FontStyle.EmphasisText.font)
.foregroundColor(ColorSet.BodyDescriptiion.color) .foregroundColor(ColorSet.BodyDescriptiion.color)
} }
......
...@@ -66,18 +66,19 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M ...@@ -66,18 +66,19 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M
return return
} }
if granted { if granted {
// MSNotificationHub.setLifecycleDelegate(self) MSNotificationHub.setLifecycleDelegate(self)
UNUserNotificationCenter.current().delegate = self UNUserNotificationCenter.current().delegate = self
// MSNotificationHub.setDelegate(self) MSNotificationHub.setDelegate(self)
MSNotificationHub.start(connectionString: HttpRequestType.ConnectionString.rawValue, hubName: HttpRequestType.HubName.rawValue)
let notification = notificationTags()
notification.addTags()
// addTags()
} }
} }
application.registerForRemoteNotifications() application.registerForRemoteNotifications()
MSNotificationHub.start(connectionString: HttpRequestType.ConnectionString.rawValue, hubName: HttpRequestType.HubName.rawValue)
let notification = notificationTags()
notification.addTags()
return true return true
} }
...@@ -88,17 +89,17 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M ...@@ -88,17 +89,17 @@ class AppDelegate: NSObject, UIApplicationDelegate ,MSNotificationHubDelegate, M
return config return config
} }
// func addTags() { func addTags() {
// if Preferences.shipId == 0 { if Preferences.shipId != 0 {
// let shipId = String(Preferences.shipId) let shipId = String(Preferences.shipId)
// let testTag = "aaa" let testTag = "aaa"
// let routeTag = "route-" + shipId let routeTag = "route-" + shipId
// let bamTag = "bam-" + shipId let bamTag = "bam-" + shipId
// let taskAlertTag = "taskalert-" + shipId let taskAlertTag = "taskalert-" + shipId
// let sailassistTag = "sailassist-" + shipId let sailassistTag = "sailassist-" + shipId
// MSNotificationHub.addTags([testTag, routeTag, bamTag, taskAlertTag, sailassistTag]) MSNotificationHub.addTags([testTag, routeTag, bamTag, taskAlertTag, sailassistTag])
// } }
// } }
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
print(debug: "called") print(debug: "called")
...@@ -144,6 +145,13 @@ extension AppDelegate: UNUserNotificationCenterDelegate { ...@@ -144,6 +145,13 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
let userInfo = response.notification.request.content.userInfo let userInfo = response.notification.request.content.userInfo
print(debug: userInfo) print(debug: userInfo)
if let custom = userInfo["key"] as? String {
print(debug: "called \(custom)")
if custom == "map" {
}
}
completionHandler() completionHandler()
} }
} }
......
...@@ -11,8 +11,8 @@ enum EcaOperation { ...@@ -11,8 +11,8 @@ enum EcaOperation {
case Insert case Insert
case Delete case Delete
case Running case Running
case Start
case Notice case Notice
case Start
case Finish case Finish
case Incomplete case Incomplete
case Change case Change
...@@ -35,7 +35,10 @@ class SharingData{ ...@@ -35,7 +35,10 @@ class SharingData{
@Published var shipName: String = "" @Published var shipName: String = ""
@Published var imo: Int = 0 @Published var imo: Int = 0
@Published var mmsi: Int = 0 @Published var mmsi: Int = 0
@Published var company: String = "JRC Co.,Ltd"
@Published var ecaStatus: EcaState?
func setLocation(){ func setLocation(){
if Preferences.LocationType == 0 { if Preferences.LocationType == 0 {
self.location = self.gps self.location = self.gps
...@@ -146,7 +149,7 @@ class SharingData{ ...@@ -146,7 +149,7 @@ class SharingData{
case EcaOperation.Delete: case EcaOperation.Delete:
let deleteEcaArea = DeleteEcaArea() let deleteEcaArea = DeleteEcaArea()
deleteEcaArea.start(ecaId: value.id) deleteEcaArea.start(ecaId: value.id)
case EcaOperation.Start: case EcaOperation.Notice:
task.areaId = value.id task.areaId = value.id
task.taskName = value.name task.taskName = value.name
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
...@@ -156,7 +159,7 @@ class SharingData{ ...@@ -156,7 +159,7 @@ class SharingData{
task.status = setEcaStatus(eca: value) task.status = setEcaStatus(eca: value)
} }
setEcaArea.start(eca: task) setEcaArea.start(eca: task)
case EcaOperation.Notice: case EcaOperation.Start:
task.areaId = value.id task.areaId = value.id
task.taskName = value.name task.taskName = value.name
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
...@@ -172,7 +175,7 @@ class SharingData{ ...@@ -172,7 +175,7 @@ class SharingData{
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
task.startRange = value.swStart task.startRange = value.swStart
task.finishRange = value.swFinish task.finishRange = value.swFinish
if value.isEnable && value.isRunning { if value.isEnable {
task.status = setEcaStatus(eca: value) task.status = setEcaStatus(eca: value)
} }
setEcaArea.start(eca: task) setEcaArea.start(eca: task)
...@@ -182,7 +185,7 @@ class SharingData{ ...@@ -182,7 +185,7 @@ class SharingData{
task.noticeRange = value.swNotice task.noticeRange = value.swNotice
task.startRange = value.swStart task.startRange = value.swStart
task.finishRange = value.swFinish task.finishRange = value.swFinish
if value.isEnable && value.isRunning { if value.isEnable {
task.status = setEcaStatus(eca: value) task.status = setEcaStatus(eca: value)
} }
setEcaArea.start(eca: task) setEcaArea.start(eca: task)
...@@ -216,13 +219,13 @@ class SharingData{ ...@@ -216,13 +219,13 @@ class SharingData{
case EcaState.running: case EcaState.running:
state = serverRunning state = serverRunning
case EcaState.noticePass: case EcaState.noticePass:
state = serverNoticePass + serverRunning state = serverNoticePass
case EcaState.startPass: case EcaState.startPass:
state = serverStartPass + serverRunning state = serverStartPass
case EcaState.finishPass: case EcaState.finishPass:
state = serverFinishPass + serverRunning state = serverFinishPass
case EcaState.end: case EcaState.end:
state = serverEnd + serverRunning state = serverEnd
case EcaState.incomplete: case EcaState.incomplete:
state = serverIncomplete state = serverIncomplete
case EcaState.cancel: case EcaState.cancel:
......
...@@ -30,6 +30,8 @@ class AlertManager { ...@@ -30,6 +30,8 @@ class AlertManager {
let content = UNMutableNotificationContent() let content = UNMutableNotificationContent()
content.title = alertrec.title content.title = alertrec.title
content.body = alertrec.body content.body = alertrec.body
content.categoryIdentifier = "alarm"
content.userInfo = ["key": "map"]
content.sound = UNNotificationSound.default content.sound = UNNotificationSound.default
// 「通知」を発生させる // 「通知」を発生させる
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment