Commit 5bbab3e4 authored by sugita mamoru's avatar sugita mamoru

Merge commit 'a16032d9' into develop

parents a1b2f7b3 a16032d9
......@@ -86,6 +86,9 @@
D52D21412AEDE18F00324D58 /* EcaCoordinatesTable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D52D21402AEDE18F00324D58 /* EcaCoordinatesTable.swift */; };
D545FC742B09C74300F206D0 /* AlertManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = D545FC732B09C74300F206D0 /* AlertManager.swift */; };
D545FC762B09C81300F206D0 /* PushNotificationTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = D545FC752B09C81300F206D0 /* PushNotificationTypes.swift */; };
D58E1F502B142A260092D8FE /* EcaArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = D58E1F4F2B142A260092D8FE /* EcaArea.swift */; };
D58E1F522B142A3F0092D8FE /* ResEcaArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = D58E1F512B142A3F0092D8FE /* ResEcaArea.swift */; };
D58E1F542B142A510092D8FE /* SessionEcaArea.swift in Sources */ = {isa = PBXBuildFile; fileRef = D58E1F532B142A510092D8FE /* SessionEcaArea.swift */; };
D592D5232B0F14FE00B91A1C /* SessionUploadImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D592D5222B0F14FE00B91A1C /* SessionUploadImage.swift */; };
D592D5252B0F16CA00B91A1C /* ReqMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D592D5242B0F16CA00B91A1C /* ReqMessage.swift */; };
D592D5272B0F182C00B91A1C /* ReqAckMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = D592D5262B0F182C00B91A1C /* ReqAckMessage.swift */; };
......@@ -223,6 +226,9 @@
D53ACA752B0AECF8008DCB18 /* Sailassist.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = Sailassist.entitlements; path = Sailassist/Sailassist.entitlements; sourceTree = "<group>"; };
D545FC732B09C74300F206D0 /* AlertManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AlertManager.swift; path = Sailassist/VoiceManager/AlertManager.swift; sourceTree = SOURCE_ROOT; };
D545FC752B09C81300F206D0 /* PushNotificationTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PushNotificationTypes.swift; path = Sailassist/DataSource/PushNotificationTypes.swift; sourceTree = SOURCE_ROOT; };
D58E1F4F2B142A260092D8FE /* EcaArea.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EcaArea.swift; path = Sailassist/ECA/EcaArea.swift; sourceTree = SOURCE_ROOT; };
D58E1F512B142A3F0092D8FE /* ResEcaArea.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ResEcaArea.swift; path = Sailassist/Json/ResEcaArea.swift; sourceTree = SOURCE_ROOT; };
D58E1F532B142A510092D8FE /* SessionEcaArea.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SessionEcaArea.swift; path = Sailassist/ServerSession/SessionEcaArea.swift; sourceTree = SOURCE_ROOT; };
D592D5222B0F14FE00B91A1C /* SessionUploadImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SessionUploadImage.swift; path = Sailassist/ServerSession/SessionUploadImage.swift; sourceTree = SOURCE_ROOT; };
D592D5242B0F16CA00B91A1C /* ReqMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ReqMessage.swift; path = Sailassist/Json/ReqMessage.swift; sourceTree = SOURCE_ROOT; };
D592D5262B0F182C00B91A1C /* ReqAckMessage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ReqAckMessage.swift; path = Sailassist/Json/ReqAckMessage.swift; sourceTree = SOURCE_ROOT; };
......@@ -498,6 +504,7 @@
022789122AE602D800A87787 /* ServerSession */ = {
isa = PBXGroup;
children = (
D58E1F532B142A510092D8FE /* SessionEcaArea.swift */,
D5AE351C2AEBA6FC00059889 /* SessionLogin.swift */,
02CD06922AE88970005F8D8F /* ServerSession.swift */,
02CD06942AE895F5005F8D8F /* APIError.swift */,
......@@ -630,6 +637,7 @@
D52D213B2AEBB78E00324D58 /* ECA */ = {
isa = PBXGroup;
children = (
D58E1F4F2B142A260092D8FE /* EcaArea.swift */,
D52D213E2AEBB7D700324D58 /* RegisteredEca.swift */,
D52D21402AEDE18F00324D58 /* EcaCoordinatesTable.swift */,
D5CB6FA02B023F7F00EC2010 /* EcaTask.swift */,
......@@ -648,6 +656,7 @@
D5AE35172AEBA64800059889 /* Json */ = {
isa = PBXGroup;
children = (
D58E1F512B142A3F0092D8FE /* ResEcaArea.swift */,
D5AE35182AEBA66A00059889 /* ReqLogin.swift */,
D5AE35192AEBA66A00059889 /* ResLogin.swift */,
D5CB6F982B02088C00EC2010 /* ResShipStatus.swift */,
......@@ -879,6 +888,7 @@
D5258CA72B03988600365276 /* ReqTaskList.swift in Sources */,
D5CB6F9B2B021C4F00EC2010 /* LocationViewModel.swift in Sources */,
02CE4DC82ADF97E8002E79BC /* View+Extensions.swift in Sources */,
D58E1F542B142A510092D8FE /* SessionEcaArea.swift in Sources */,
025C28002B034A1900BADC49 /* PDFViewer.swift in Sources */,
02C3E6092AFDF30000AF7837 /* ChatMemberView.swift in Sources */,
020B98412AD8C3810029DE4C /* LoginView.swift in Sources */,
......@@ -911,8 +921,10 @@
020B98692ADD221E0029DE4C /* Preferences.swift in Sources */,
02CD06932AE88970005F8D8F /* ServerSession.swift in Sources */,
02A1DE312AFB61D8005BCF55 /* MyChatContentView.swift in Sources */,
D58E1F522B142A3F0092D8FE /* ResEcaArea.swift in Sources */,
025C27FE2B0206D700BADC49 /* PDFDownloadManager.swift in Sources */,
025C27FC2AFE191A00BADC49 /* MenuManualView.swift in Sources */,
D58E1F502B142A260092D8FE /* EcaArea.swift in Sources */,
020B98592AD92A4C0029DE4C /* MainTabView.swift in Sources */,
020B984F2AD9182D0029DE4C /* InputUserNameView.swift in Sources */,
D5AE351A2AEBA66A00059889 /* ReqLogin.swift in Sources */,
......
//
// EcaArea.swift
// Sailassist
//
// Created by 三浦薫巳 on 2023/11/26.
//
import Foundation
import CoreLocation
class EcaArea {
var sessionEcaArea = SessionEcaArea()
func start() {
print(debug: "called")
sessionEcaArea.RequestEcaArea(responseEcaArea)
}
private func responseEcaArea(result: Result<Data, APIError>) {
print(debug: "called")
switch result {
case .success(let resultData):
let serverSession = ServerSession()
let resjson = serverSession.fromJSON(resultData: resultData, resltType: [ResEcaArea].self)
if let res = resjson {
var area = res
}
case .failure(let errorCode):
print(debug: errorCode)
break
}
}
}
......@@ -4313,19 +4313,19 @@ class EcaCoordinatesTable : NSObject {
}
var ecaDataTable:[ecaData] = [
// ecaData(id: 1, name: "North American Atlantic Coasts", table: northAmericanAtlanticCoasts),
// ecaData(id: 2, name: "North American Hawai", table: northAmericanHawai),
// ecaData(id: 3, name: "Unites States Caribbean", table: unitesStatesCaribbean),
// ecaData(id: 4, name: "North Sea 1", table: northSea1),
// ecaData(id: 5, name: "North Sea 2", table: northSea2),
// ecaData(id: 6, name: "Iceland", table: iceland),
// ecaData(id: 11, name: "North American Atlantic Coasts", table: northAmericanAtlanticCoasts),
// ecaData(id: 12, name: "North American Hawai", table: northAmericanHawai),
// ecaData(id: 31, name: "Unites States Caribbean", table: unitesStatesCaribbean),
// ecaData(id: 21, name: "North Sea 1", table: northSea1), //err
// ecaData(id: 22, name: "North Sea 2", table: northSea2),
// ecaData(id: 1, name: "Iceland", table: iceland),
// ecaData(id: 7, name: "China Shore", table: chinaShore),
// ecaData(id: 8, name: "China Hainan", table: chinaHainan),
// ecaData(id: 9, name: "China Yangtzi Shuifu,Yunnan", table: chinaYangtziShuifuYunnan),
// ecaData(id: 9, name: "China Yangtzi Shuifu,Yunnan", table: chinaYangtziShuifuYunnan), //err
// ecaData(id: 10, name: "China Yangtzi Liuhekou,Jiangsu1", table: chinaYangtziLiuhekouJiangsu1),
// ecaData(id: 11, name: "China Yangtzi Liuhekou,Jiangsu2", table: chinaYangtziLiuhekouJiangsu2),
// ecaData(id: 12, name: "China Xijiang Nanning,Guangxi", table: chinaXijiangNanningGuangxi),
// ecaData(id: 13, name: "China Xijiang Zhaoqing,Guangdong", table: chinaXijiangNanningGuangdong),
// ecaData(id: 12, name: "China Xijiang Nanning,Guangxi", table: chinaXijiangNanningGuangxi), //err
// ecaData(id: 13, name: "China Xijiang Zhaoqing,Guangdong", table: chinaXijiangNanningGuangdong), //err
// ecaData(id: 14, name: "Korea Incheon, PyeongtaekDangjin Port", table: incheonPyeongtaekDanjinPort),
// ecaData(id: 15, name: "Korea Yeosu, Gwangyang Port", table: yeosuGwangyangPort),
// ecaData(id: 16, name: "Korea Busan Port", table: koreaBusanPort),
......@@ -4338,7 +4338,7 @@ class EcaCoordinatesTable : NSObject {
func setEcaData() {
for data in ecaDataTable {
if !SharingData.eca.ecaArea.keys.contains(data.name) {
var reg = RegisteredEca(ecaName: data.name)!
var reg = RegisteredEca(id: data.id, ecaName: data.name)!
reg.color = "0xFF0000" //ライン色(ARGB)
reg.points = data.table
SharingData.eca.ecaArea.updateValue(reg, forKey: data.name)
......
......@@ -19,7 +19,7 @@ enum EcaState {
}
struct RegisteredEca {
var id: UInt32 = 0
var id: Int = 0
var isEnable: Bool = false //ECA有効
var isRunning: Bool = false //ECA実行中
var name: String = "" //ECA名称
......@@ -29,10 +29,11 @@ struct RegisteredEca {
var status: EcaState = EcaState.start //ECA状態
var datetime: String = "" //時刻(UTC ISO8601準拠)
var color: String = "" //ライン色(ARGB)
var width: UInt32 = 1 //ライン幅
var width: Int = 1 //ライン幅
var points: [CLLocationCoordinate2D] = []
init?( ecaName: String ) {
init?(id: Int, ecaName: String ) {
self.id = id
self.name = ecaName
}
}
......@@ -16,7 +16,7 @@ enum HttpRequestType : String {
case CookiePolicy = "https://ssv-canary-web.azurewebsites.net/cookiepolicy"
case PrivacyPolicy = "https://ssv-canary-web.azurewebsites.net/inapp?" //+バージョン番号
case TaskList = "https://ssv-canary-web.azurewebsites.net/api/sailassist/tasklist/XXXXX"
case EcaArea = "https://ssv-canary-web.azurewebsites.net/api/sailassist/ecaarea"
case EcaArea = "https://ssv-canary-web.azurewebsites.net/api/sailassist/ecaarea/XXXXX"
case ShipStatus = "https://ssv-canary-web.azurewebsites.net/api/sailassist/shipstatus/XXXXX"
case ShipMonitoringRoute = "https://ssv-canary-web.azurewebsites.net/api/sailassist/shipmonitoringroute/XXXXX"
case GetMessage = "https://ssv-canary-web.azurewebsites.net/api/chatdata/getmessages?shipId=XXXXX"
......
//
// ResEcaArea.swift
// Sailassist
//
// Created by 三浦薫巳 on 2023/11/26.
//
import Foundation
struct ResEcaArea: Codable {
var areaId: Int
var areaName: String
var geometry: [points]?
}
......@@ -12,6 +12,7 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
@Published var lastSeenLocation: CLLocation?
private let locationManager: CLLocationManager
let ecaTask = EcaTask()
override init() {
locationManager = CLLocationManager()
......@@ -38,17 +39,16 @@ class LocationViewModel: NSObject, ObservableObject, CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let newLocation = locations.last {
let isLocation = filterLocation(newLocation)
if isLocation {
// let isLocation = filterLocation(newLocation)
// if isLocation {
lastSeenLocation = locations.first
let targetCoordinate : CLLocationCoordinate2D = lastSeenLocation!.coordinate
SharingData.my.gps = targetCoordinate
if Preferences.LocationType == 0 {
SharingData.my.location = SharingData.my.gps
let ecaTask = EcaTask()
ecaTask.checkEca()
}
}
// }
}
}
......
......@@ -211,5 +211,5 @@ struct EcaSettingView: View {
}
#Preview {
EcaSettingView(isShowSettingEca: .constant(true), edittingEca: RegisteredEca(ecaName: "eca")!)
EcaSettingView(isShowSettingEca: .constant(true), edittingEca: RegisteredEca(id: 0, ecaName: "eca")!)
}
......@@ -7,28 +7,35 @@
import SwiftUI
enum EcaAlertType: String {
case ecaDelete
case ecaRunningStop
}
struct TaskSwitchingMenuView: View {
@Binding var viewMode: TaskViewMode
@Binding var edittingEcaArea: RegisteredEca?
@Binding var isShowSettingEca : Bool
@ObservedObject var ecaData = SharingData.eca
@State var isDeleteAlert : Bool = false
@State var isEcaAlert : Bool = false
@State var ecaAlertType: EcaAlertType = .ecaDelete
var body: some View {
VStack{
ForEach(ecaData.ecaArea.map{ $0.1 }.filter{ $0.isEnable }, id: \.name){ eca in
VStack {
HStack {
Button {
for runningEca in ecaData.ecaArea.map{ $0.1 }.filter{ $0.isRunning }{
var newData = runningEca
newData.isRunning = false
ecaData.editEcaArea(key: runningEca.name, value: newData)
edittingEcaArea = runningEca
isEcaAlert = true
ecaAlertType = .ecaRunningStop
}
if isEcaAlert == false {
var newData = eca
newData.isRunning = true
ecaData.editEcaArea(key: eca.name, value: newData)
}
var newData = eca
newData.isRunning = true
ecaData.editEcaArea(key: eca.name, value: newData)
} label: {
HStack {
Circle()
......@@ -36,13 +43,15 @@ struct TaskSwitchingMenuView: View {
.foregroundColor(eca.isRunning ? ColorSet.PrimaryActiveIcon.color : ColorSet.TaskStateIcon.color)
Spacer()
.frame(width: 10)
Text(eca.name)
.font(FontStyle.DefaultText.font)
.foregroundColor(ColorSet.Body.color)
}
}
Text(eca.name)
.font(FontStyle.DefaultText.font)
.foregroundColor(ColorSet.Body.color)
.onTapGesture {
ecaData.foucusEca = eca.name
}
Spacer()
......@@ -58,36 +67,46 @@ struct TaskSwitchingMenuView: View {
Button{
edittingEcaArea = eca
isDeleteAlert = true
isEcaAlert = true
ecaAlertType = .ecaDelete
} label: {
Text("Delete ECA Task")
}
} label: {
Image(systemName: "ellipsis")
.frame(width: 22, height: 22)
.foregroundColor(ColorSet.Slidebar.color)
.foregroundColor(eca.isRunning ? ColorSet.Splash.color : ColorSet.Slidebar.color)
}
.disabled(eca.isRunning)
.alert("delete", isPresented: $isDeleteAlert) {
Button(role: .destructive) {
if let ecaArea = edittingEcaArea{
var newData = ecaArea
newData.isEnable = false
ecaData.editEcaArea(key: ecaArea.name, value: newData)
}
edittingEcaArea = nil
} label: {
Text("delete")
}
Button(role: .cancel) {
} label: {
Text("cancel")
.alert(isPresented: $isEcaAlert) {
switch ecaAlertType {
case .ecaDelete:
return Alert(title: Text("delete"),
message: Text("eca delete"),
primaryButton: .default(Text("cancel")),
secondaryButton: .cancel(Text("delete"), action: {
if let ecaArea = edittingEcaArea {
var newData = ecaArea
newData.isEnable = false
ecaData.editEcaArea(key: ecaArea.name, value: newData)
}
edittingEcaArea = nil
}))
case .ecaRunningStop:
return Alert(title: Text("stop"),
message: Text("eca running stop"),
primaryButton: .default(Text("cancel")),
secondaryButton: .cancel(Text("stop"), action: {
if let ecaArea = edittingEcaArea {
var newData = ecaArea
newData.isRunning = false
newData.status = EcaState.cancel
ecaData.editEcaArea(key: ecaArea.name, value: newData)
//サーバーにECAキャンセルを通知
}
edittingEcaArea = nil
}))
}
} message: {
Text("eca delete")
}
}
.frame(height: 60)
......
//
// SessionEcaArea.swift
// Sailassist
//
// Created by 三浦薫巳 on 2023/11/26.
//
import Foundation
import SwiftUI
class SessionEcaArea : ObservableObject {
@Published var status = false
// シングルトン宣言
static let OnlyOne = SessionEcaArea()
private var serverSession = ServerSession()
private var Calling : Bool = false // 通信中
/**
* Monitoring Route
*/
func RequestEcaArea(_ completion: @escaping ((Result<Data, APIError>)) -> Void) {
print(debug: "calld")
if Calling {
return
}
Calling = true
// リクエストURLの組み立て
let id = SharingData.my.shipId
if id != 0 {
var url_string : String = HttpRequestType.EcaArea.rawValue
url_string = url_string.replacingOccurrences(of: "XXXXX", with: String(id))
guard let req_url = URL(string : url_string) else {
Calling = false
return
}
serverSession.getJson(req_url, completion: completion)
}
}
}
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