IntdashDataFileManager

public class IntdashDataFileManager : Codable

IntdashData をファイルシステム上で管理するクラス。 指定したディレクトリへ IntdashData を書き出したり、読み込んだりすることができます。

書き出しには、 IntdashDataFileManager.write(units:elapsedTime:withUpdateDataSize:) を使用することができます。

書き出された IntdashData は、1秒ごとに1セットとして扱われます。 同一秒のセットのなかで、さらに同一経過時間をもつものどうしで一つにまとめられ、小さい方から順に、indexを割り振られます。

保存されている IntdashData は、 IntdashDataFileManager.read(elapsedTime:index:completion:) により、 取得対象の秒数およびindexを指定して取得することができます。

  • データを保存する親パス(ディレクトリのパス)。

    Declaration

    Swift

    public private(set) var parentPath: String
  • 格納されたデータの総データサイズ。

    Declaration

    Swift

    public var dataSize: UInt64 { get }
  • 格納したデータが紐づく1つめの基準時刻(通常、EdgeRTCより取得した基準時刻が使用されることを想定)。

    Declaration

    Swift

    public var baseTime: TimeInterval?
  • baseTime を設定します。 なお、ファイルへの保存も同時に行います。

    Declaration

    Swift

    public func setBaseTime(time: TimeInterval?) throws

    Parameters

    time

    基準時刻

  • 格納したデータが紐づく2つめの基準時刻(通常、NTP等より取得した基準時刻が使用されることを想定)。

    Declaration

    Swift

    public var baseTime2: TimeInterval?
  • baseTime2 を設定します。 なお、ファイルへの保存も同時に行います。

    Declaration

    Swift

    public func setBaseTime2(time: TimeInterval?) throws

    Parameters

    time

    基準時刻

  • 格納したデータが紐づく計測のUUID。

    Declaration

    Swift

    public var measurementId: String?
  • measurementId を設定します。なお、ファイルへの保存も同時に行います。

    Declaration

    Swift

    public func setMeasurementId(id: String) throws

    Parameters

    id

    計測のUUID

  • 格納したデータが紐づくチャンネル番号。

    Declaration

    Swift

    public var streamChannels: Int?
  • streamChannels を設定します。なお、ファイルへの保存も同時に行います。

    Declaration

    Swift

    public func setStreamChannels(channels: Int?) throws

    Parameters

    channels

    ストリーム用チャンネル番号

  • 格納したデータの期間(格納した時系列データがどのくらいの時間的長さをもつか)。 getDataDuration() と異なり、利用者により任意の値を設定することができます。

    Declaration

    Swift

    public var duration: TimeInterval?
  • duration を設定します。なお、ファイルへの保存も同時に行います。

    Declaration

    Swift

    public func setDuration(duration: TimeInterval?) throws

    Parameters

    duration

    期間

  • 格納したデータをサーバーにアップロードしたか。

    Declaration

    Swift

    public var isUploaded: Bool
  • isUploaded をセットします。なお、ファイルへの保存も同時に行います。

    Declaration

    Swift

    public func setUploadFlag(flag: Bool) throws

    Parameters

    flag

    フラグ

  • メタ情報として仕様可能な任意の文字列。

    Declaration

    Swift

    public var string: String?
  • string に文字列をセットします。なお、ファイルへの保存も同時に行います。

    Declaration

    Swift

    public func setString(str: String?) throws

    Parameters

    str

    任意の文字列

  • IntdashDataFileManagerを生成します。

    Declaration

    Swift

    public required init(from decoder: Decoder) throws

    Parameters

    from

    Decoder

  • Declaration

    Swift

    public func encode(to encoder: Encoder) throws
  • IntdashDataFileManagerを生成します。

    Declaration

    Swift

    public init(parentPath: String, isOverwrite: Bool = false) throws

    Parameters

    parentPath

    データを保存する親パス(ディレクトリのパス)

    isOverwirte

    上書きを許可するか

  • 指定したパスからデータをロードして、IntdashDataFileManagerを生成します。

    Declaration

    Swift

    public static func load(parentPath: String) throws -> IntdashDataFileManager

    Parameters

    parentPath

    データが保存されている親パス(ディレクトリのパス)

    Return Value

    IntdashDataFileManager

  • 保持しているデータを書き出します。

    Declaration

    Swift

    public func write() throws
  • 格納したデータを除去します。

    Declaration

    Swift

    public func remove() throws
  • 指定されたパスに格納したデータを除去します。

    Declaration

    Swift

    public static func remove(parentPath: String) throws

    Parameters

    parentPath

    データを削除する親パス(ディレクトリのパス)

  • 保持しているデータをクリアします。

    Declaration

    Swift

    public func clear() throws
  • タイムスタンプ(絶対時刻)を使用して、 IntdashData を書き込みます。

    Declaration

    Swift

    @discardableResult
    public func write(units: [IntdashData], timestamp: TimeInterval, withUpdateDataSize: Bool = true) throws -> Int

    Parameters

    units

    書き込む IntdashData の配列

    timestamp

    タイムスタンプ(絶対時刻)

    withUpdateDataSize

    書き込んだ総データサイズを同時に書き込むか

    Return Value

    書き込んだ総データサイズ

  • 相対時間を指定して、 IntdashData を書き込みます。

    Declaration

    Swift

    @discardableResult
    public func write(units: [IntdashData], elapsedTime: TimeInterval, withUpdateDataSize: Bool = true) throws -> Int

    Parameters

    units

    書き込む IntdashData の配列

    elapsedTime

    相対時間

    withUpdateDataSize

    書き込んだ総データサイズを同時に書き込むか

    Return Value

    書き込んだ総データサイズ

  • ある経過時間に保存された複数の IntdashData のうち、 index 番目のものを取得します。

    Declaration

    Swift

    public func read(elapsedTime: Int, index: Int, completion: @escaping (_ error: Error?, _ units: [IntdashData]?, _ timestamp: TimeInterval?) -> ())

    Parameters

    elapsedTime

    取得対象とする経過時間

    index

    取得対象とする経過時間に格納された複数の IntdashData のうち、何番目のものを取得対象とするか

    completion

    処理完了時のコールバック

    error

    エラー情報

    units

    取得した IntdashData の配列

    timestamp

    取得した IntdashData に対応するタイムスタンプ

  • 保存されているデータが持つデータの期間を算出します。 duration と異なり、保存されているデータが持つ情報から、期間を算出します。

    Declaration

    Swift

    public func getDataDuration() -> Int

    Return Value

    保存されているデータの期間(秒)

  • 指定されたパスに保存されているデータが持つデータの期間を算出します。

    Declaration

    Swift

    public static func getDataDuration(parentPath: String) -> Int

    Parameters

    parentPath

    データが配置されている親パス(ディレクトリのパス)

    Return Value

    保存されているデータの期間(秒)

  • その経過時間に対して保存されている IntdashData の数を取得します。

    Declaration

    Swift

    public func getUnitSizePerSecond(elapsedTime: Int) -> Int

    Parameters

    elapsedTime

    取得対象とする経過時間

    Return Value

    その経過時間に保存されている IntdashData の数

  • 指定されたパスから、その経過時間に対して保存されている IntdashData の数を取得します。

    Declaration

    Swift

    public static func getUnitSizePerSecond(parentPath: String, elapsedTime: Int) -> Int

    Parameters

    parentPath

    取得対象とする親パス

    elapsedTime

    取得対象とする経過時間

    Return Value

    その経過時間に保存されている IntdashData の数

  • 保存されているデータを移動します。

    Declaration

    Swift

    public func move(toParentPath: String) throws

    Parameters

    toParentPath

    移動先親パス

  • 指定されたパスからパスへ、保存されているデータを移動します。

    Declaration

    Swift

    public static func move(fromParentPath: String, toParentPath: String) throws

    Parameters

    fromParentPath

    移動前親パス

    toParentPath

    移動先親パス

  • 保存されているデータを移動します。

    Declaration

    Swift

    public func move(toParentPath: String, isOverwrite: Bool) throws

    Parameters

    toParentPath

    移動先親パス

    isOverwrite

    上書きを許可するか

  • 指定されたパスからパスへ、保存されているデータを移動します。

    Declaration

    Swift

    public static func move(fromParentPath: String, toParentPath: String, isOverwrite: Bool) throws

    Parameters

    fronParentPath

    移動前親パス

    toParentPath

    移動先親パス

    isOverwrite

    上書きを許可するか

  • 保存されているデータをコピーします。

    Declaration

    Swift

    public func copy(toParentPath: String) throws

    Parameters

    toParentPath

    コピー先親パス

  • 指定されたパスからパスへ、保存されているデータをコピーします。

    Declaration

    Swift

    public static func copy(fromParentPath: String, toParentPath: String) throws

    Parameters

    fromParentPath

    コピーする親パス

    toParentPath

    コピー先親パス

  • 保存されているデータをコピーします。

    Declaration

    Swift

    public func copy(toParentPath: String, isOverwrite: Bool) throws

    Parameters

    toParentPath

    コピー先親パス

    isOverwrite

    上書きを許可するか

  • 指定されたパスからパスへ、保存されているデータをコピーします。

    Declaration

    Swift

    public static func copy(fromParentPath: String, toParentPath: String, isOverwrite: Bool) throws

    Parameters

    fromParentPath

    コピーする親パス

    toParentPath

    コピー先親パス

    isOverwrite

    上書きを許可するか