Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
Sailassist
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
CpjJwWHV
Sailassist
Commits
734b7525
Commit
734b7525
authored
Jun 26, 2024
by
shigemi miura
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
画像送信成功
parent
95aff94d
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
105 additions
and
18 deletions
+105
-18
GetEcaList.swift
Seilassist/Sailassist/ECA/GetEcaList.swift
+3
-0
RegisteredEca.swift
Seilassist/Sailassist/ECA/RegisteredEca.swift
+3
-0
ReqNgaList.swift
Seilassist/Sailassist/Json/ReqNgaList.swift
+1
-0
ReqTaskList.swift
Seilassist/Sailassist/Json/ReqTaskList.swift
+3
-2
GetNgaList.swift
Seilassist/Sailassist/NGA/GetNgaList.swift
+2
-1
ServerSession.swift
Seilassist/Sailassist/ServerSession/ServerSession.swift
+15
-6
SessionUploadImage.swift
Seilassist/Sailassist/ServerSession/SessionUploadImage.swift
+47
-8
SharingData.swift
Seilassist/Sailassist/SharingData/SharingData.swift
+30
-0
StatusEnum.swift
Seilassist/Sailassist/SharingData/StatusEnum.swift
+1
-1
No files found.
Seilassist/Sailassist/ECA/GetEcaList.swift
View file @
734b7525
...
...
@@ -32,10 +32,13 @@ class GetEcaList {
}
for
ecaList
in
res
{
if
var
value
=
ecaAreas
[
ecaList
.
areaId
]{
value
.
id
=
ecaList
.
id
value
.
userName
=
ecaList
.
userName
value
.
isEnable
=
true
value
.
swNotice
=
ecaList
.
noticeRange
value
.
swStart
=
ecaList
.
startRange
value
.
swFinish
=
ecaList
.
finishRange
value
.
lastUpdateTime
=
ecaList
.
lastUpdateTime
if
ecaList
.
status
&
serverRunning
==
serverRunning
{
value
.
isRunning
=
true
value
.
status
=
setEcaServer
(
status
:
ecaList
.
status
)
...
...
Seilassist/Sailassist/ECA/RegisteredEca.swift
View file @
734b7525
...
...
@@ -29,7 +29,9 @@ let serverIncomplete = 0x00000200 //ECAタスク未完了 (燃料切替未実
let
serverCancel
=
0x00000400
//ECAタスクキャンセル (タスク終了・タスク未完了前にキャンセル)
struct
RegisteredEca
{
var
id
:
String
=
""
var
areaId
:
Int
=
0
var
userName
:
String
=
""
var
isEnable
:
Bool
=
false
//ECA有効
var
isRunning
:
Bool
=
false
//ECA実行中
var
name
:
String
=
""
//ECA名称
...
...
@@ -40,6 +42,7 @@ struct RegisteredEca {
var
datetime
:
String
=
""
//時刻(UTC ISO8601準拠)
var
color
:
String
=
""
//ライン色(ARGB)
var
width
:
Int
=
1
//ライン幅
var
lastUpdateTime
:
String
=
""
var
centerPosition
:
CLLocationCoordinate2D
=
CLLocationCoordinate2D
(
latitude
:
0.0
,
longitude
:
0.0
)
var
zoomLevel
:
CGFloat
=
11.0
var
points
:
[
CLLocationCoordinate2D
]
=
[]
...
...
Seilassist/Sailassist/Json/ReqNgaList.swift
View file @
734b7525
...
...
@@ -9,6 +9,7 @@ import Foundation
struct
ReqNgaList
:
Codable
{
var
id
:
String
=
""
var
name
:
String
=
""
var
lock
:
Bool
=
false
var
enabled
:
Bool
=
false
var
geometry
:
[
points
]
=
[]
...
...
Seilassist/Sailassist/Json/ReqTaskList.swift
View file @
734b7525
...
...
@@ -8,14 +8,15 @@
import
Foundation
struct
ReqTaskList
:
Codable
{
//
var id: String = ""
var
id
:
String
=
""
var
areaId
:
Int
=
0
var
taskName
:
String
=
""
// var n
ame: String = ""
var
userN
ame
:
String
=
""
var
noticeRange
:
Float
=
0.0
var
startRange
:
Float
=
0.0
var
finishRange
:
Float
=
0.0
var
status
:
Int
=
0
var
lastUpdateTime
:
String
=
""
init
(
Id
:
Int
)
{
self
.
areaId
=
Id
...
...
Seilassist/Sailassist/NGA/GetNgaList.swift
View file @
734b7525
...
...
@@ -31,7 +31,7 @@ class GetNgaList {
if
let
id
=
NSUUID
(
uuidString
:
ngaList
.
id
)
{
if
var
nga
=
ngaAreas
[
id
as
UUID
]
{
print
(
debug
:
"Test: 1
\(
nga
)
"
)
//
nga.name = ngaList.name
nga
.
name
=
ngaList
.
name
nga
.
isLock
=
ngaList
.
lock
nga
.
points
.
removeAll
()
for
pos
in
ngaList
.
geometry
{
...
...
@@ -43,6 +43,7 @@ class GetNgaList {
}
else
{
if
var
nga
=
RegisteredNga
(
areaName
:
"test dammy"
)
{
//TODO: 名称はダミー
nga
.
areaId
=
id
as
UUID
nga
.
name
=
ngaList
.
name
nga
.
isLock
=
ngaList
.
lock
nga
.
isRunning
=
ngaList
.
enabled
if
!
ngaList
.
enabled
{
...
...
Seilassist/Sailassist/ServerSession/ServerSession.swift
View file @
734b7525
...
...
@@ -85,13 +85,20 @@ class ServerSession{
req
.
setValue
(
"multipart/form-data; boundary=
\(
boundary
)
"
,
forHTTPHeaderField
:
"Content-Type"
)
req
.
setValue
(
"
\(
postdata
.
count
)
"
,
forHTTPHeaderField
:
"Content-Length"
)
req
.
httpBody
=
postdata
req
.
timeoutInterval
=
20
// タイムアウト3秒 → Amedasでタイムアウトエラー20秒に変更
//
req.timeoutInterval = 20 // タイムアウト3秒 → Amedasでタイムアウトエラー20秒に変更
// サーバー送信
let
session
=
URLSession
(
configuration
:
.
default
,
delegate
:
nil
,
delegateQueue
:
OperationQueue
.
main
)
// let session = URLSession(configuration: .default, delegate: nil, delegateQueue: OperationQueue.main)
URLSession
.
shared
.
dataTask
(
with
:
req
)
{(
data
,
response
,
error
)
in
session
.
dataTask
(
with
:
req
,
completionHandler
:
{(
data
,
response
,
error
)
in
session
.
finishTasksAndInvalidate
()
// var req = URLRequest(url: req_url)
// req.httpMethod = "POST"
// let headers = ["Content-Type":"multipart/form-data; boundary=\(boundary)"]
// let urlConfig = URLSessionConfiguration.default
// urlConfig.httpAdditionalHeaders = headers
//
// // サーバー送信
// let session = URLSession(configuration: urlConfig)
// session.uploadTask(with: req, from: postdata, completionHandler: {(data, response, error) in
do
{
if
error
!=
nil
{
...
...
@@ -101,6 +108,8 @@ class ServerSession{
throw
APIError
.
responseError
}
if
inresponse
.
statusCode
!=
200
{
let
statusCode
=
inresponse
.
statusCode
print
(
debug
:
"serverError:
\(
statusCode
)
"
)
throw
APIError
.
serverError
}
//Cookieを保存
...
...
@@ -120,7 +129,7 @@ class ServerSession{
completion
(
.
failure
(
.
unknown
))
}
}
}
)
.
resume
()
}
.
resume
()
}
func
getJson
(
_
req_url
:
URL
,
completion
:
@escaping
(
SessionResponse
)
->
Void
){
...
...
Seilassist/Sailassist/ServerSession/SessionUploadImage.swift
View file @
734b7525
...
...
@@ -33,13 +33,52 @@ class SessionUploadImage : ObservableObject {
return
}
let
boundary
=
"----------"
+
uploadImage
.
messageId
if
let
postdata
=
serverSession
.
httpBody
(
boundary
:
boundary
,
uploadImage
)
{
serverSession
.
postForm
(
boundary
:
boundary
,
req_url
,
postdata
,
completion
:
completion
)
}
else
{
Calling
=
false
return
}
let
imageFileName
=
"itemp.jpg"
let
boundary
=
"----------
\(
UUID
()
.
uuidString
)
"
var
httpBody1
=
"--
\(
boundary
)\r\n
"
httpBody1
+=
"Content-Disposition: form-data; name=
\"
ShipId
\"\r\n
"
httpBody1
+=
"
\r\n
"
httpBody1
+=
"
\(
uploadImage
.
shipId
)\r\n
"
httpBody1
+=
"--
\(
boundary
)\r\n
"
httpBody1
+=
"Content-Disposition: form-data; name=
\"
MessageId
\"\r\n
"
httpBody1
+=
"
\r\n
"
httpBody1
+=
"
\(
uploadImage
.
messageId
)\r\n
"
httpBody1
+=
"--
\(
boundary
)\r\n
"
httpBody1
+=
"Content-Disposition: form-data; name=
\"
Location
\"\r\n
"
httpBody1
+=
"
\r\n
"
httpBody1
+=
"
\(
String
(
uploadImage
.
location
)
)\r\n
"
httpBody1
+=
"--
\(
boundary
)\r\n
"
httpBody1
+=
"Content-Disposition: form-data; name=
\"
From
\"\r\n
"
httpBody1
+=
"
\r\n
"
httpBody1
+=
"
\(
uploadImage
.
from
)\r\n
"
httpBody1
+=
"--
\(
boundary
)\r\n
"
httpBody1
+=
"Content-Disposition: form-data; name=
\"
FromId
\"\r\n
"
httpBody1
+=
"
\r\n
"
httpBody1
+=
"
\(
uploadImage
.
fromId
)\r\n
"
httpBody1
+=
"--
\(
boundary
)\r\n
"
httpBody1
+=
"Content-Disposition: form-data; name=
\"
files
\"
; filename=
\"\(
imageFileName
)\"\r\n
"
httpBody1
+=
"Content-Type: image/jpeg
\r\n
"
httpBody1
+=
"
\r\n
"
var
httpBody
=
Data
()
httpBody
.
append
(
httpBody1
.
data
(
using
:
.
utf8
)
!
)
httpBody
.
append
(
uploadImage
.
files
)
var
httpBody2
=
"
\r\n
"
httpBody2
+=
"--
\(
boundary
)
--
\r\n
"
httpBody
.
append
(
httpBody2
.
data
(
using
:
.
utf8
)
!
)
// let str: String = String(decoding: httpBody, as: UTF8.self)
serverSession
.
postForm
(
boundary
:
boundary
,
req_url
,
httpBody
,
completion
:
completion
)
// if let postdata = serverSession.httpBody(boundary: boundary, uploadImage) {
// serverSession.postForm(boundary: boundary, req_url, postdata, completion: completion)
// }
// else {
// Calling = false
// return
// }
}
}
Seilassist/Sailassist/SharingData/SharingData.swift
View file @
734b7525
...
...
@@ -134,26 +134,34 @@ class SharingData{
switch
type
{
case
EcaOperation
.
Running
:
task
.
id
=
UUID
()
.
uuidString
task
.
areaId
=
value
.
areaId
task
.
userName
=
Preferences
.
UserName
task
.
taskName
=
value
.
name
task
.
noticeRange
=
value
.
swNotice
task
.
startRange
=
value
.
swStart
task
.
finishRange
=
value
.
swFinish
task
.
status
=
serverRunning
task
.
lastUpdateTime
=
DateTextLib
.
Date2BCDText
(
Date
())
setEcaArea
.
start
(
eca
:
task
)
case
EcaOperation
.
Insert
:
task
.
id
=
UUID
()
.
uuidString
task
.
areaId
=
value
.
areaId
task
.
userName
=
Preferences
.
UserName
task
.
taskName
=
value
.
name
task
.
noticeRange
=
value
.
swNotice
task
.
startRange
=
value
.
swStart
task
.
finishRange
=
value
.
swFinish
task
.
status
=
serverRegister
task
.
lastUpdateTime
=
DateTextLib
.
Date2BCDText
(
Date
())
setEcaArea
.
start
(
eca
:
task
)
case
EcaOperation
.
Delete
:
let
deleteEcaArea
=
DeleteEcaArea
()
deleteEcaArea
.
start
(
ecaId
:
value
.
areaId
)
case
EcaOperation
.
Notice
:
task
.
id
=
value
.
id
task
.
areaId
=
value
.
areaId
task
.
userName
=
value
.
userName
task
.
taskName
=
value
.
name
task
.
noticeRange
=
value
.
swNotice
task
.
startRange
=
value
.
swStart
...
...
@@ -161,9 +169,12 @@ class SharingData{
if
value
.
isEnable
&&
value
.
isRunning
{
task
.
status
=
setEcaStatus
(
eca
:
value
)
}
task
.
lastUpdateTime
=
DateTextLib
.
Date2BCDText
(
Date
())
setEcaArea
.
start
(
eca
:
task
)
case
EcaOperation
.
Start
:
task
.
id
=
value
.
id
task
.
areaId
=
value
.
areaId
task
.
userName
=
value
.
userName
task
.
taskName
=
value
.
name
task
.
noticeRange
=
value
.
swNotice
task
.
startRange
=
value
.
swStart
...
...
@@ -171,9 +182,12 @@ class SharingData{
if
value
.
isEnable
&&
value
.
isRunning
{
task
.
status
=
setEcaStatus
(
eca
:
value
)
}
task
.
lastUpdateTime
=
DateTextLib
.
Date2BCDText
(
Date
())
setEcaArea
.
start
(
eca
:
task
)
case
EcaOperation
.
Finish
:
task
.
id
=
value
.
id
task
.
areaId
=
value
.
areaId
task
.
userName
=
value
.
userName
task
.
taskName
=
value
.
name
task
.
noticeRange
=
value
.
swNotice
task
.
startRange
=
value
.
swStart
...
...
@@ -181,9 +195,12 @@ class SharingData{
if
value
.
isEnable
{
task
.
status
=
setEcaStatus
(
eca
:
value
)
}
task
.
lastUpdateTime
=
DateTextLib
.
Date2BCDText
(
Date
())
setEcaArea
.
start
(
eca
:
task
)
case
EcaOperation
.
End
:
task
.
id
=
value
.
id
task
.
areaId
=
value
.
areaId
task
.
userName
=
value
.
userName
task
.
taskName
=
value
.
name
task
.
noticeRange
=
value
.
swNotice
task
.
startRange
=
value
.
swStart
...
...
@@ -191,9 +208,12 @@ class SharingData{
if
value
.
isEnable
{
task
.
status
=
setEcaStatus
(
eca
:
value
)
}
task
.
lastUpdateTime
=
DateTextLib
.
Date2BCDText
(
Date
())
setEcaArea
.
start
(
eca
:
task
)
case
EcaOperation
.
Incomplete
:
task
.
id
=
value
.
id
task
.
areaId
=
value
.
areaId
task
.
userName
=
value
.
userName
task
.
taskName
=
value
.
name
task
.
noticeRange
=
value
.
swNotice
task
.
startRange
=
value
.
swStart
...
...
@@ -201,9 +221,12 @@ class SharingData{
if
value
.
isEnable
{
task
.
status
=
setEcaStatus
(
eca
:
value
)
}
task
.
lastUpdateTime
=
DateTextLib
.
Date2BCDText
(
Date
())
setEcaArea
.
start
(
eca
:
task
)
case
EcaOperation
.
Cancel
:
task
.
id
=
value
.
id
task
.
areaId
=
value
.
areaId
task
.
userName
=
value
.
userName
task
.
taskName
=
value
.
name
task
.
noticeRange
=
value
.
swNotice
task
.
startRange
=
value
.
swStart
...
...
@@ -211,9 +234,12 @@ class SharingData{
if
value
.
isEnable
{
task
.
status
=
setEcaStatus
(
eca
:
value
)
}
task
.
lastUpdateTime
=
DateTextLib
.
Date2BCDText
(
Date
())
setEcaArea
.
start
(
eca
:
task
)
case
EcaOperation
.
Change
:
task
.
id
=
value
.
id
task
.
areaId
=
value
.
areaId
task
.
userName
=
value
.
userName
task
.
taskName
=
value
.
name
task
.
noticeRange
=
value
.
swNotice
task
.
startRange
=
value
.
swStart
...
...
@@ -221,6 +247,7 @@ class SharingData{
if
value
.
isEnable
&&
value
.
isRunning
{
task
.
status
=
setEcaStatus
(
eca
:
value
)
}
task
.
lastUpdateTime
=
DateTextLib
.
Date2BCDText
(
Date
())
setEcaArea
.
start
(
eca
:
task
)
}
ecaArea
.
updateValue
(
value
,
forKey
:
key
)
...
...
@@ -276,6 +303,7 @@ class SharingData{
switch
type
{
case
NgaOperation
.
Change
:
task
.
id
=
value
.
areaId
.
uuidString
task
.
name
=
value
.
name
task
.
enabled
=
value
.
isRunning
task
.
lock
=
value
.
isLock
for
point
in
value
.
points
{
...
...
@@ -292,6 +320,7 @@ class SharingData{
break
case
NgaOperation
.
Running
:
task
.
id
=
value
.
areaId
.
uuidString
task
.
name
=
value
.
name
task
.
enabled
=
value
.
isRunning
task
.
lock
=
value
.
isLock
for
point
in
value
.
points
{
...
...
@@ -306,6 +335,7 @@ class SharingData{
break
case
NgaOperation
.
Cancel
:
task
.
id
=
value
.
areaId
.
uuidString
task
.
name
=
value
.
name
task
.
enabled
=
value
.
isRunning
task
.
lock
=
value
.
isLock
for
point
in
value
.
points
{
...
...
Seilassist/Sailassist/SharingData/StatusEnum.swift
View file @
734b7525
...
...
@@ -10,7 +10,7 @@ import Foundation
enum
EcaOperation
{
case
Insert
case
Delete
case
Running
case
Running
//ECA開始
case
Notice
case
Start
case
Finish
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment