text:
# syntax: proto2
using Compat
using ProtoBuf
import ProtoBuf.meta
import ..hadoop

struct __enum_StorageTypeProto <: ProtoEnum
    DISK::Int32
    SSD::Int32
    ARCHIVE::Int32
    RAM_DISK::Int32
    __enum_StorageTypeProto() = new(1,2,3,4)
end #struct __enum_StorageTypeProto
const StorageTypeProto = __enum_StorageTypeProto()

struct __enum_CipherSuiteProto <: ProtoEnum
    UNKNOWN::Int32
    AES_CTR_NOPADDING::Int32
    __enum_CipherSuiteProto() = new(1,2)
end #struct __enum_CipherSuiteProto
const CipherSuiteProto = __enum_CipherSuiteProto()

struct __enum_CryptoProtocolVersionProto <: ProtoEnum
    UNKNOWN_PROTOCOL_VERSION::Int32
    ENCRYPTION_ZONES::Int32
    __enum_CryptoProtocolVersionProto() = new(1,2)
end #struct __enum_CryptoProtocolVersionProto
const CryptoProtocolVersionProto = __enum_CryptoProtocolVersionProto()

struct __enum_ChecksumTypeProto <: ProtoEnum
    CHECKSUM_NULL::Int32
    CHECKSUM_CRC32::Int32
    CHECKSUM_CRC32C::Int32
    __enum_ChecksumTypeProto() = new(0,1,2)
end #struct __enum_ChecksumTypeProto
const ChecksumTypeProto = __enum_ChecksumTypeProto()

struct __enum_ReplicaStateProto <: ProtoEnum
    FINALIZED::Int32
    RBW::Int32
    RWR::Int32
    RUR::Int32
    TEMPORARY::Int32
    __enum_ReplicaStateProto() = new(0,1,2,3,4)
end #struct __enum_ReplicaStateProto
const ReplicaStateProto = __enum_ReplicaStateProto()

mutable struct ExtendedBlockProto <: ProtoType
    poolId::AbstractString
    blockId::UInt64
    generationStamp::UInt64
    numBytes::UInt64
    ExtendedBlockProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct ExtendedBlockProto
const __req_ExtendedBlockProto = Symbol[:poolId,:blockId,:generationStamp]
const __val_ExtendedBlockProto = Dict(:numBytes => 0)
meta(t::Type{ExtendedBlockProto}) = meta(t, __req_ExtendedBlockProto, ProtoBuf.DEF_FNUM, __val_ExtendedBlockProto, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct DatanodeIDProto <: ProtoType
    ipAddr::AbstractString
    hostName::AbstractString
    datanodeUuid::AbstractString
    xferPort::UInt32
    infoPort::UInt32
    ipcPort::UInt32
    infoSecurePort::UInt32
    DatanodeIDProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct DatanodeIDProto
const __req_DatanodeIDProto = Symbol[:ipAddr,:hostName,:datanodeUuid,:xferPort,:infoPort,:ipcPort]
const __val_DatanodeIDProto = Dict(:infoSecurePort => 0)
meta(t::Type{DatanodeIDProto}) = meta(t, __req_DatanodeIDProto, ProtoBuf.DEF_FNUM, __val_DatanodeIDProto, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct DatanodeLocalInfoProto <: ProtoType
    softwareVersion::AbstractString
    configVersion::AbstractString
    uptime::UInt64
    DatanodeLocalInfoProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct DatanodeLocalInfoProto
const __req_DatanodeLocalInfoProto = Symbol[:softwareVersion,:configVersion,:uptime]
meta(t::Type{DatanodeLocalInfoProto}) = meta(t, __req_DatanodeLocalInfoProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

struct __enum_DatanodeInfoProto_AdminState <: ProtoEnum
    NORMAL::Int32
    DECOMMISSION_INPROGRESS::Int32
    DECOMMISSIONED::Int32
    __enum_DatanodeInfoProto_AdminState() = new(0,1,2)
end #struct __enum_DatanodeInfoProto_AdminState
const DatanodeInfoProto_AdminState = __enum_DatanodeInfoProto_AdminState()

mutable struct DatanodeInfoProto <: ProtoType
    id::DatanodeIDProto
    capacity::UInt64
    dfsUsed::UInt64
    remaining::UInt64
    blockPoolUsed::UInt64
    lastUpdate::UInt64
    xceiverCount::UInt32
    location::AbstractString
    adminState::Int32
    cacheCapacity::UInt64
    cacheUsed::UInt64
    lastUpdateMonotonic::UInt64
    DatanodeInfoProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct DatanodeInfoProto
const __req_DatanodeInfoProto = Symbol[:id]
const __val_DatanodeInfoProto = Dict(:capacity => 0, :dfsUsed => 0, :remaining => 0, :blockPoolUsed => 0, :lastUpdate => 0, :xceiverCount => 0, :adminState => DatanodeInfoProto_AdminState.NORMAL, :cacheCapacity => 0, :cacheUsed => 0, :lastUpdateMonotonic => 0)
const __fnum_DatanodeInfoProto = Int[1,2,3,4,5,6,7,8,10,11,12,13]
meta(t::Type{DatanodeInfoProto}) = meta(t, __req_DatanodeInfoProto, __fnum_DatanodeInfoProto, __val_DatanodeInfoProto, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct DatanodeInfosProto <: ProtoType
    datanodes::Base.Vector{DatanodeInfoProto}
    DatanodeInfosProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct DatanodeInfosProto

struct __enum_DatanodeStorageProto_StorageState <: ProtoEnum
    NORMAL::Int32
    READ_ONLY_SHARED::Int32
    __enum_DatanodeStorageProto_StorageState() = new(0,1)
end #struct __enum_DatanodeStorageProto_StorageState
const DatanodeStorageProto_StorageState = __enum_DatanodeStorageProto_StorageState()

mutable struct DatanodeStorageProto <: ProtoType
    storageUuid::AbstractString
    state::Int32
    storageType::Int32
    DatanodeStorageProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct DatanodeStorageProto
const __req_DatanodeStorageProto = Symbol[:storageUuid]
const __val_DatanodeStorageProto = Dict(:state => DatanodeStorageProto_StorageState.NORMAL, :storageType => StorageTypeProto.DISK)
meta(t::Type{DatanodeStorageProto}) = meta(t, __req_DatanodeStorageProto, ProtoBuf.DEF_FNUM, __val_DatanodeStorageProto, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct StorageReportProto <: ProtoType
    storageUuid::AbstractString
    failed::Bool
    capacity::UInt64
    dfsUsed::UInt64
    remaining::UInt64
    blockPoolUsed::UInt64
    storage::DatanodeStorageProto
    StorageReportProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct StorageReportProto
const __req_StorageReportProto = Symbol[:storageUuid]
const __val_StorageReportProto = Dict(:failed => false, :capacity => 0, :dfsUsed => 0, :remaining => 0, :blockPoolUsed => 0)
meta(t::Type{StorageReportProto}) = meta(t, __req_StorageReportProto, ProtoBuf.DEF_FNUM, __val_StorageReportProto, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct StorageTypeQuotaInfoProto <: ProtoType
    _type::Int32
    quota::UInt64
    consumed::UInt64
    StorageTypeQuotaInfoProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct StorageTypeQuotaInfoProto
const __req_StorageTypeQuotaInfoProto = Symbol[:_type,:quota,:consumed]
meta(t::Type{StorageTypeQuotaInfoProto}) = meta(t, __req_StorageTypeQuotaInfoProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct StorageTypeQuotaInfosProto <: ProtoType
    typeQuotaInfo::Base.Vector{StorageTypeQuotaInfoProto}
    StorageTypeQuotaInfosProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct StorageTypeQuotaInfosProto

mutable struct ContentSummaryProto <: ProtoType
    length::UInt64
    fileCount::UInt64
    directoryCount::UInt64
    quota::UInt64
    spaceConsumed::UInt64
    spaceQuota::UInt64
    typeQuotaInfos::StorageTypeQuotaInfosProto
    ContentSummaryProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct ContentSummaryProto
const __req_ContentSummaryProto = Symbol[:length,:fileCount,:directoryCount,:quota,:spaceConsumed,:spaceQuota]
meta(t::Type{ContentSummaryProto}) = meta(t, __req_ContentSummaryProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct CorruptFileBlocksProto <: ProtoType
    files::Base.Vector{AbstractString}
    cookie::AbstractString
    CorruptFileBlocksProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct CorruptFileBlocksProto
const __req_CorruptFileBlocksProto = Symbol[:cookie]
meta(t::Type{CorruptFileBlocksProto}) = meta(t, __req_CorruptFileBlocksProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct FsPermissionProto <: ProtoType
    perm::UInt32
    FsPermissionProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct FsPermissionProto
const __req_FsPermissionProto = Symbol[:perm]
meta(t::Type{FsPermissionProto}) = meta(t, __req_FsPermissionProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct StorageTypesProto <: ProtoType
    storageTypes::Base.Vector{Int32}
    StorageTypesProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct StorageTypesProto

mutable struct BlockStoragePolicyProto <: ProtoType
    policyId::UInt32
    name::AbstractString
    creationPolicy::StorageTypesProto
    creationFallbackPolicy::StorageTypesProto
    replicationFallbackPolicy::StorageTypesProto
    BlockStoragePolicyProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct BlockStoragePolicyProto
const __req_BlockStoragePolicyProto = Symbol[:policyId,:name,:creationPolicy]
meta(t::Type{BlockStoragePolicyProto}) = meta(t, __req_BlockStoragePolicyProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct StorageUuidsProto <: ProtoType
    storageUuids::Base.Vector{AbstractString}
    StorageUuidsProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct StorageUuidsProto

mutable struct LocatedBlockProto <: ProtoType
    b::ExtendedBlockProto
    offset::UInt64
    locs::Base.Vector{DatanodeInfoProto}
    corrupt::Bool
    blockToken::hadoop.common.TokenProto
    isCached::Base.Vector{Bool}
    storageTypes::Base.Vector{Int32}
    storageIDs::Base.Vector{AbstractString}
    LocatedBlockProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct LocatedBlockProto
const __req_LocatedBlockProto = Symbol[:b,:offset,:corrupt,:blockToken]
const __pack_LocatedBlockProto = Symbol[:isCached]
meta(t::Type{LocatedBlockProto}) = meta(t, __req_LocatedBlockProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, __pack_LocatedBlockProto, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct DataEncryptionKeyProto <: ProtoType
    keyId::UInt32
    blockPoolId::AbstractString
    nonce::Array{UInt8,1}
    encryptionKey::Array{UInt8,1}
    expiryDate::UInt64
    encryptionAlgorithm::AbstractString
    DataEncryptionKeyProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct DataEncryptionKeyProto
const __req_DataEncryptionKeyProto = Symbol[:keyId,:blockPoolId,:nonce,:encryptionKey,:expiryDate]
meta(t::Type{DataEncryptionKeyProto}) = meta(t, __req_DataEncryptionKeyProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct FileEncryptionInfoProto <: ProtoType
    suite::Int32
    cryptoProtocolVersion::Int32
    key::Array{UInt8,1}
    iv::Array{UInt8,1}
    keyName::AbstractString
    ezKeyVersionName::AbstractString
    FileEncryptionInfoProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct FileEncryptionInfoProto
const __req_FileEncryptionInfoProto = Symbol[:suite,:cryptoProtocolVersion,:key,:iv,:keyName,:ezKeyVersionName]
meta(t::Type{FileEncryptionInfoProto}) = meta(t, __req_FileEncryptionInfoProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct PerFileEncryptionInfoProto <: ProtoType
    key::Array{UInt8,1}
    iv::Array{UInt8,1}
    ezKeyVersionName::AbstractString
    PerFileEncryptionInfoProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct PerFileEncryptionInfoProto
const __req_PerFileEncryptionInfoProto = Symbol[:key,:iv,:ezKeyVersionName]
meta(t::Type{PerFileEncryptionInfoProto}) = meta(t, __req_PerFileEncryptionInfoProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct ZoneEncryptionInfoProto <: ProtoType
    suite::Int32
    cryptoProtocolVersion::Int32
    keyName::AbstractString
    ZoneEncryptionInfoProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct ZoneEncryptionInfoProto
const __req_ZoneEncryptionInfoProto = Symbol[:suite,:cryptoProtocolVersion,:keyName]
meta(t::Type{ZoneEncryptionInfoProto}) = meta(t, __req_ZoneEncryptionInfoProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct CipherOptionProto <: ProtoType
    suite::Int32
    inKey::Array{UInt8,1}
    inIv::Array{UInt8,1}
    outKey::Array{UInt8,1}
    outIv::Array{UInt8,1}
    CipherOptionProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct CipherOptionProto
const __req_CipherOptionProto = Symbol[:suite]
meta(t::Type{CipherOptionProto}) = meta(t, __req_CipherOptionProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct LocatedBlocksProto <: ProtoType
    fileLength::UInt64
    blocks::Base.Vector{LocatedBlockProto}
    underConstruction::Bool
    lastBlock::LocatedBlockProto
    isLastBlockComplete::Bool
    fileEncryptionInfo::FileEncryptionInfoProto
    LocatedBlocksProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct LocatedBlocksProto
const __req_LocatedBlocksProto = Symbol[:fileLength,:underConstruction,:isLastBlockComplete]
meta(t::Type{LocatedBlocksProto}) = meta(t, __req_LocatedBlocksProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

struct __enum_HdfsFileStatusProto_FileType <: ProtoEnum
    IS_DIR::Int32
    IS_FILE::Int32
    IS_SYMLINK::Int32
    __enum_HdfsFileStatusProto_FileType() = new(1,2,3)
end #struct __enum_HdfsFileStatusProto_FileType
const HdfsFileStatusProto_FileType = __enum_HdfsFileStatusProto_FileType()

mutable struct HdfsFileStatusProto <: ProtoType
    fileType::Int32
    path::Array{UInt8,1}
    length::UInt64
    permission::FsPermissionProto
    owner::AbstractString
    group::AbstractString
    modification_time::UInt64
    access_time::UInt64
    symlink::Array{UInt8,1}
    block_replication::UInt32
    blocksize::UInt64
    locations::LocatedBlocksProto
    fileId::UInt64
    childrenNum::Int32
    fileEncryptionInfo::FileEncryptionInfoProto
    storagePolicy::UInt32
    HdfsFileStatusProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct HdfsFileStatusProto
const __req_HdfsFileStatusProto = Symbol[:fileType,:path,:length,:permission,:owner,:group,:modification_time,:access_time]
const __val_HdfsFileStatusProto = Dict(:block_replication => 0, :blocksize => 0, :fileId => 0, :childrenNum => -1, :storagePolicy => 0)
meta(t::Type{HdfsFileStatusProto}) = meta(t, __req_HdfsFileStatusProto, ProtoBuf.DEF_FNUM, __val_HdfsFileStatusProto, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct FsServerDefaultsProto <: ProtoType
    blockSize::UInt64
    bytesPerChecksum::UInt32
    writePacketSize::UInt32
    replication::UInt32
    fileBufferSize::UInt32
    encryptDataTransfer::Bool
    trashInterval::UInt64
    checksumType::Int32
    FsServerDefaultsProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct FsServerDefaultsProto
const __req_FsServerDefaultsProto = Symbol[:blockSize,:bytesPerChecksum,:writePacketSize,:replication,:fileBufferSize]
const __val_FsServerDefaultsProto = Dict(:encryptDataTransfer => false, :trashInterval => 0, :checksumType => ChecksumTypeProto.CHECKSUM_CRC32)
meta(t::Type{FsServerDefaultsProto}) = meta(t, __req_FsServerDefaultsProto, ProtoBuf.DEF_FNUM, __val_FsServerDefaultsProto, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct DirectoryListingProto <: ProtoType
    partialListing::Base.Vector{HdfsFileStatusProto}
    remainingEntries::UInt32
    DirectoryListingProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct DirectoryListingProto
const __req_DirectoryListingProto = Symbol[:remainingEntries]
meta(t::Type{DirectoryListingProto}) = meta(t, __req_DirectoryListingProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct SnapshottableDirectoryStatusProto <: ProtoType
    dirStatus::HdfsFileStatusProto
    snapshot_quota::UInt32
    snapshot_number::UInt32
    parent_fullpath::Array{UInt8,1}
    SnapshottableDirectoryStatusProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct SnapshottableDirectoryStatusProto
const __req_SnapshottableDirectoryStatusProto = Symbol[:dirStatus,:snapshot_quota,:snapshot_number,:parent_fullpath]
meta(t::Type{SnapshottableDirectoryStatusProto}) = meta(t, __req_SnapshottableDirectoryStatusProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct SnapshottableDirectoryListingProto <: ProtoType
    snapshottableDirListing::Base.Vector{SnapshottableDirectoryStatusProto}
    SnapshottableDirectoryListingProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct SnapshottableDirectoryListingProto

mutable struct SnapshotDiffReportEntryProto <: ProtoType
    fullpath::Array{UInt8,1}
    modificationLabel::AbstractString
    targetPath::Array{UInt8,1}
    SnapshotDiffReportEntryProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct SnapshotDiffReportEntryProto
const __req_SnapshotDiffReportEntryProto = Symbol[:fullpath,:modificationLabel]
meta(t::Type{SnapshotDiffReportEntryProto}) = meta(t, __req_SnapshotDiffReportEntryProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct SnapshotDiffReportProto <: ProtoType
    snapshotRoot::AbstractString
    fromSnapshot::AbstractString
    toSnapshot::AbstractString
    diffReportEntries::Base.Vector{SnapshotDiffReportEntryProto}
    SnapshotDiffReportProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct SnapshotDiffReportProto
const __req_SnapshotDiffReportProto = Symbol[:snapshotRoot,:fromSnapshot,:toSnapshot]
meta(t::Type{SnapshotDiffReportProto}) = meta(t, __req_SnapshotDiffReportProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct StorageInfoProto <: ProtoType
    layoutVersion::UInt32
    namespceID::UInt32
    clusterID::AbstractString
    cTime::UInt64
    StorageInfoProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct StorageInfoProto
const __req_StorageInfoProto = Symbol[:layoutVersion,:namespceID,:clusterID,:cTime]
meta(t::Type{StorageInfoProto}) = meta(t, __req_StorageInfoProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

struct __enum_NamenodeRegistrationProto_NamenodeRoleProto <: ProtoEnum
    NAMENODE::Int32
    BACKUP::Int32
    CHECKPOINT::Int32
    __enum_NamenodeRegistrationProto_NamenodeRoleProto() = new(1,2,3)
end #struct __enum_NamenodeRegistrationProto_NamenodeRoleProto
const NamenodeRegistrationProto_NamenodeRoleProto = __enum_NamenodeRegistrationProto_NamenodeRoleProto()

mutable struct NamenodeRegistrationProto <: ProtoType
    rpcAddress::AbstractString
    httpAddress::AbstractString
    storageInfo::StorageInfoProto
    role::Int32
    NamenodeRegistrationProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct NamenodeRegistrationProto
const __req_NamenodeRegistrationProto = Symbol[:rpcAddress,:httpAddress,:storageInfo]
const __val_NamenodeRegistrationProto = Dict(:role => NamenodeRegistrationProto_NamenodeRoleProto.NAMENODE)
meta(t::Type{NamenodeRegistrationProto}) = meta(t, __req_NamenodeRegistrationProto, ProtoBuf.DEF_FNUM, __val_NamenodeRegistrationProto, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct CheckpointSignatureProto <: ProtoType
    blockPoolId::AbstractString
    mostRecentCheckpointTxId::UInt64
    curSegmentTxId::UInt64
    storageInfo::StorageInfoProto
    CheckpointSignatureProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct CheckpointSignatureProto
const __req_CheckpointSignatureProto = Symbol[:blockPoolId,:mostRecentCheckpointTxId,:curSegmentTxId,:storageInfo]
meta(t::Type{CheckpointSignatureProto}) = meta(t, __req_CheckpointSignatureProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct CheckpointCommandProto <: ProtoType
    signature::CheckpointSignatureProto
    needToReturnImage::Bool
    CheckpointCommandProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct CheckpointCommandProto
const __req_CheckpointCommandProto = Symbol[:signature,:needToReturnImage]
meta(t::Type{CheckpointCommandProto}) = meta(t, __req_CheckpointCommandProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

struct __enum_NamenodeCommandProto_Type <: ProtoEnum
    NamenodeCommand::Int32
    CheckPointCommand::Int32
    __enum_NamenodeCommandProto_Type() = new(0,1)
end #struct __enum_NamenodeCommandProto_Type
const NamenodeCommandProto_Type = __enum_NamenodeCommandProto_Type()

mutable struct NamenodeCommandProto <: ProtoType
    action::UInt32
    _type::Int32
    checkpointCmd::CheckpointCommandProto
    NamenodeCommandProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct NamenodeCommandProto
const __req_NamenodeCommandProto = Symbol[:action,:_type]
meta(t::Type{NamenodeCommandProto}) = meta(t, __req_NamenodeCommandProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct BlockProto <: ProtoType
    blockId::UInt64
    genStamp::UInt64
    numBytes::UInt64
    BlockProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct BlockProto
const __req_BlockProto = Symbol[:blockId,:genStamp]
const __val_BlockProto = Dict(:numBytes => 0)
meta(t::Type{BlockProto}) = meta(t, __req_BlockProto, ProtoBuf.DEF_FNUM, __val_BlockProto, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct BlockWithLocationsProto <: ProtoType
    block::BlockProto
    datanodeUuids::Base.Vector{AbstractString}
    storageUuids::Base.Vector{AbstractString}
    storageTypes::Base.Vector{Int32}
    BlockWithLocationsProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct BlockWithLocationsProto
const __req_BlockWithLocationsProto = Symbol[:block]
meta(t::Type{BlockWithLocationsProto}) = meta(t, __req_BlockWithLocationsProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct BlocksWithLocationsProto <: ProtoType
    blocks::Base.Vector{BlockWithLocationsProto}
    BlocksWithLocationsProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct BlocksWithLocationsProto

mutable struct RemoteEditLogProto <: ProtoType
    startTxId::UInt64
    endTxId::UInt64
    isInProgress::Bool
    RemoteEditLogProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct RemoteEditLogProto
const __req_RemoteEditLogProto = Symbol[:startTxId,:endTxId]
const __val_RemoteEditLogProto = Dict(:isInProgress => false)
meta(t::Type{RemoteEditLogProto}) = meta(t, __req_RemoteEditLogProto, ProtoBuf.DEF_FNUM, __val_RemoteEditLogProto, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct RemoteEditLogManifestProto <: ProtoType
    logs::Base.Vector{RemoteEditLogProto}
    RemoteEditLogManifestProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct RemoteEditLogManifestProto

mutable struct NamespaceInfoProto <: ProtoType
    buildVersion::AbstractString
    unused::UInt32
    blockPoolID::AbstractString
    storageInfo::StorageInfoProto
    softwareVersion::AbstractString
    capabilities::UInt64
    NamespaceInfoProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct NamespaceInfoProto
const __req_NamespaceInfoProto = Symbol[:buildVersion,:unused,:blockPoolID,:storageInfo,:softwareVersion]
const __val_NamespaceInfoProto = Dict(:capabilities => 0)
meta(t::Type{NamespaceInfoProto}) = meta(t, __req_NamespaceInfoProto, ProtoBuf.DEF_FNUM, __val_NamespaceInfoProto, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct BlockKeyProto <: ProtoType
    keyId::UInt32
    expiryDate::UInt64
    keyBytes::Array{UInt8,1}
    BlockKeyProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct BlockKeyProto
const __req_BlockKeyProto = Symbol[:keyId,:expiryDate]
meta(t::Type{BlockKeyProto}) = meta(t, __req_BlockKeyProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct ExportedBlockKeysProto <: ProtoType
    isBlockTokenEnabled::Bool
    keyUpdateInterval::UInt64
    tokenLifeTime::UInt64
    currentKey::BlockKeyProto
    allKeys::Base.Vector{BlockKeyProto}
    ExportedBlockKeysProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct ExportedBlockKeysProto
const __req_ExportedBlockKeysProto = Symbol[:isBlockTokenEnabled,:keyUpdateInterval,:tokenLifeTime,:currentKey]
meta(t::Type{ExportedBlockKeysProto}) = meta(t, __req_ExportedBlockKeysProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct RecoveringBlockProto <: ProtoType
    newGenStamp::UInt64
    block::LocatedBlockProto
    truncateBlock::BlockProto
    RecoveringBlockProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct RecoveringBlockProto
const __req_RecoveringBlockProto = Symbol[:newGenStamp,:block]
meta(t::Type{RecoveringBlockProto}) = meta(t, __req_RecoveringBlockProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct VersionRequestProto <: ProtoType
    VersionRequestProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct VersionRequestProto

mutable struct VersionResponseProto <: ProtoType
    info::NamespaceInfoProto
    VersionResponseProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct VersionResponseProto
const __req_VersionResponseProto = Symbol[:info]
meta(t::Type{VersionResponseProto}) = meta(t, __req_VersionResponseProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct SnapshotInfoProto <: ProtoType
    snapshotName::AbstractString
    snapshotRoot::AbstractString
    permission::FsPermissionProto
    owner::AbstractString
    group::AbstractString
    createTime::AbstractString
    SnapshotInfoProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct SnapshotInfoProto
const __req_SnapshotInfoProto = Symbol[:snapshotName,:snapshotRoot,:permission,:owner,:group,:createTime]
meta(t::Type{SnapshotInfoProto}) = meta(t, __req_SnapshotInfoProto, ProtoBuf.DEF_FNUM, ProtoBuf.DEF_VAL, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

mutable struct RollingUpgradeStatusProto <: ProtoType
    blockPoolId::AbstractString
    finalized::Bool
    RollingUpgradeStatusProto(; kwargs...) = (o=new(); fillunset(o); isempty(kwargs) || ProtoBuf._protobuild(o, kwargs); o)
end #mutable struct RollingUpgradeStatusProto
const __req_RollingUpgradeStatusProto = Symbol[:blockPoolId]
const __val_RollingUpgradeStatusProto = Dict(:finalized => false)
meta(t::Type{RollingUpgradeStatusProto}) = meta(t, __req_RollingUpgradeStatusProto, ProtoBuf.DEF_FNUM, __val_RollingUpgradeStatusProto, true, ProtoBuf.DEF_PACK, ProtoBuf.DEF_WTYPES, ProtoBuf.DEF_ONEOFS, ProtoBuf.DEF_ONEOF_NAMES, ProtoBuf.DEF_FIELD_TYPES)

export StorageTypeProto, CipherSuiteProto, CryptoProtocolVersionProto, ChecksumTypeProto, ReplicaStateProto, ExtendedBlockProto, DatanodeIDProto, DatanodeLocalInfoProto, DatanodeInfosProto, DatanodeInfoProto_AdminState, DatanodeInfoProto, DatanodeStorageProto_StorageState, DatanodeStorageProto, StorageReportProto, ContentSummaryProto, StorageTypeQuotaInfosProto, StorageTypeQuotaInfoProto, CorruptFileBlocksProto, FsPermissionProto, StorageTypesProto, BlockStoragePolicyProto, StorageUuidsProto, LocatedBlockProto, DataEncryptionKeyProto, FileEncryptionInfoProto, PerFileEncryptionInfoProto, ZoneEncryptionInfoProto, CipherOptionProto, LocatedBlocksProto, HdfsFileStatusProto_FileType, HdfsFileStatusProto, FsServerDefaultsProto, DirectoryListingProto, SnapshottableDirectoryStatusProto, SnapshottableDirectoryListingProto, SnapshotDiffReportEntryProto, SnapshotDiffReportProto, StorageInfoProto, NamenodeRegistrationProto_NamenodeRoleProto, NamenodeRegistrationProto, CheckpointSignatureProto, NamenodeCommandProto_Type, NamenodeCommandProto, CheckpointCommandProto, BlockProto, BlockWithLocationsProto, BlocksWithLocationsProto, RemoteEditLogProto, RemoteEditLogManifestProto, NamespaceInfoProto, BlockKeyProto, ExportedBlockKeysProto, RecoveringBlockProto, VersionRequestProto, VersionResponseProto, SnapshotInfoProto, RollingUpgradeStatusProto


text:
using Random: randstring

@testset "G" begin
    @testset "gcpool" begin
        try
            data = [randstring() for i in 1:10]
            pcpool("pcpool_test", data)
            cvals = gcpool("pcpool_test")
            @test data == cvals
            @test gcpool("norbert") === nothing
        finally
            kclear()
        end
    end
    @testset "gdpool" begin
        try
            exp = collect(1.0:10.0)
            pdpool("array", exp)
            act = gdpool("array")
            @test exp == act
            act = gdpool("array", start = 8)
            @test [8.0, 9.0, 10.0] == act
            act = gdpool("array", room = 8)
            @test collect(1.0:8.0) == act
            @test gdpool("norbert") === nothing
        finally
            kclear()
        end
    end
    @testset "georec" begin
        try
            furnsh(path(CORE, :pck))
            radii = bodvrd("EARTH", "RADII", 3)
            flat = (radii[1] - radii[3]) / radii[1]
            lon = deg2rad(118.0)
            lat = deg2rad(32.0)
            alt = 0.0
            output = georec(lon, lat, alt, radii[1], flat)
            expected = [-2541.74621567, 4780.329376, 3360.4312092]
            @test expected ≈ output
            @test_throws SpiceError georec(lon, lat, alt, -1.0, flat)
            @test_throws SpiceError georec(lon, lat, alt, radii[1], 2.0)
        finally
            kclear()
        end
    end
    @testset "getelm" begin
        try
            tle = ["1 18123U 87 53  A 87324.61041692 -.00000023  00000-0 -75103-5 0 00675",
                   "2 18123  98.8296 152.0074 0014950 168.7820 191.3688 14.12912554 21686"]
            furnsh(path(CORE, :lsk))
            epoch, elems = getelm(1950, tle)
            expected_elems = [-6.969196665949579e-13, 0.0, -7.510300000000001e-06,
                              1.724901918428988, 2.653029617396028, 0.001495,
                              2.9458016181010693, 3.3400156455905243, 0.06164994027515544,
                              -382310404.79526937]
            expected_epoch = -382310404.79526937
            @test expected_elems ≈ elems
            @test epoch ≈ expected_epoch
        finally
            kclear()
        end
    end
    @testset "getfat" begin
    arch, outtype = getfat(path(CORE, :lsk))
        @test arch == "KPL"
        @test outtype == "LSK"
    end
    @testset "getfov" begin
        try
            kernel = tempname()
            open(kernel, "w") do kernel_file
                write(kernel_file, "\\begindata\n")
                write(kernel_file, "INS-999004_FOV_SHAPE            = 'POLYGON'\n")
                write(kernel_file, "INS-999004_FOV_FRAME            = 'SC999_INST004'\n")
                write(kernel_file, "INS-999004_BORESIGHT            = (  0.0,  1.0,  0.0 )\n")
                write(kernel_file, "INS-999004_FOV_BOUNDARY_CORNERS = (  0.0,  0.8,  0.5,\n")
                write(kernel_file, "                                     0.4,  0.8, -0.2,\n")
                write(kernel_file, "                                    -0.4,  0.8, -0.2,\n")
                write(kernel_file, "\\begintext\n")
            end
            furnsh(kernel)
            shape, frame, bsight, bounds = getfov(-999004, 4, 32, 32)
            @test shape == "POLYGON"
            @test frame == "SC999_INST004"
            @test bsight ≈ [0.0, 1.0, 0.0]
            @test length(bounds) == 3
    expected = [[0.0, 0.8, 0.5], [0.4, 0.8, -0.2], [-0.4, 0.8, -0.2]]
            @test expected ≈ bounds
        finally
            kclear()
        end
    end
    @testset "gfbail" begin
        @test !Bool(SPICE.gfbail())
    end
    @testset "gfclrh" begin
        SPICE.gfclrh()
        @test !Bool(SPICE.gfbail())
    end
    @testset "gfdist" begin
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            et0 = str2et("2007 JAN 01 00:00:00 TDB")
            et1 = str2et("2007 APR 01 00:00:00 TDB")
            cnfine = SpiceDoubleCell(2)
            wninsd!(cnfine, et0, et1)
            result = gfdist("moon", "none", "earth", ">", 400000, 0.0, spd(), 1000, cnfine)
            count = wncard(result)
            @test count == 4
            results = String[]
            for i in 1:count
                left, right = wnfetd(result, i)
                timstr_left = timout(left, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41)
                timstr_right = timout(right, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41)
                push!(results, timstr_left)
                push!(results, timstr_right)
            end
            expected = ["2007-JAN-08 00:11:07.661897 (TDB)", "2007-JAN-13 06:37:47.937762 (TDB)",
                        "2007-FEB-04 07:02:35.320555 (TDB)", "2007-FEB-10 09:31:01.829206 (TDB)",
                        "2007-MAR-03 00:20:25.228066 (TDB)", "2007-MAR-10 14:04:38.482902 (TDB)",
                        "2007-MAR-29 22:53:58.186230 (TDB)", "2007-APR-01 00:00:00.000000 (TDB)"]
            @test results == expected
        finally
            kclear()
        end
    end
    @testset "gfevnt" begin
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            et_start = str2et("2001 JAN 01 00:00:00.000")
            et_end   = str2et("2001 DEC 31 00:00:00.000")
            cnfine   = SpiceDoubleCell(2)
            wninsd!(cnfine, et_start, et_end)
            result   = SpiceDoubleCell(1000)
            qpnams   = ["TARGET", "OBSERVER", "ABCORR"]
            qcpars   = ["MOON  ", "EARTH   ", "LT+S  "]
            # Set the step size to 1/1000 day and convert to seconds
            gfsstp(0.001 * spd())
            qdpars = zeros(3)
            qipars = zeros(Int, 3)
            qlpars = falses(3)
            result = gfevnt(gfstep, gfrefn, "DISTANCE", qpnams, qcpars,
                            qdpars, qipars, qlpars, "LOCMAX", 0, 1.e-6, 0,
                            true, gfrepi, gfrepu, gfrepf, 10000, cnfine)
            @test length(result) == 26
            s_timout = "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND"
            @test startswith(timout(result[1], s_timout), "2001-JAN-24 19:22:01.41871")
            @test startswith(timout(result[2], s_timout), "2001-JAN-24 19:22:01.41871")
            @test startswith(timout(result[3], s_timout), "2001-FEB-20 21:52:07.90087")
            @test startswith(timout(result[4], s_timout), "2001-FEB-20 21:52:07.90087")
        finally
            gfsstp(0.5)
            kclear()
        end
    end
    @testset "gffove" begin
        try
            furnsh(path(CORE, :lsk),
                   path(CORE, :pck),
                   path(CORE, :spk),
                   path(CASSINI, :ck),
                   path(CASSINI, :fk),
                   path(CASSINI, :ik),
                   path(CASSINI, :pck),
                   path(CASSINI, :sclk),
                   path(CASSINI, :tour_spk),
                   path(CASSINI, :sat_spk))
            et_start = str2et("2013-FEB-25 10:00:00.000")
            et_end   = str2et("2013-FEB-25 11:45:00.000")
            cnfine   = SpiceDoubleCell(2)
            wninsd!(cnfine, et_start, et_end)
            result = SpiceDoubleCell(1000)
            gfsstp(1.0)
            gffove!("CASSINI_ISS_NAC", "ELLIPSOID", [0.0, 0.0, 0.0], "ENCELADUS",
                    "IAU_ENCELADUS", "LT+S", "CASSINI", 1.e-6, gfstep, gfrefn, true, gfrepi,
                    gfrepu, gfrepf, cnfine, result)
            # Verify the expected results
            @test length(result) == 2
            s_timout = "YYYY-MON-DD HR:MN:SC UTC ::RND"
            @test timout(result[1], s_timout) == "2013-FEB-25 10:42:33 UTC"
            @test timout(result[2], s_timout) == "2013-FEB-25 11:45:00 UTC"
        finally
            gfsstp(0.5)
            kclear()
        end
    end
    @testset "gfilum" begin
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk),
                   path(EXTRA, :mars_spk))
            pos = [3376.17890941875839416753, -325.55203839445334779157, -121.47422900638389364758]
            start_et = str2et("1971 OCT 02 00:00:00 UTC")
            end_et = str2et("1971 NOV 30 12:00:00 UTC")
            cnfine = SpiceDoubleCell(2000)
            wninsd!(cnfine, start_et, end_et)
            wnsolr = gfilum("ELLIPSOID", "INCIDENCE", "MARS", "SUN",
                            "IAU_MARS", "CN+S", "PHOBOS", pos,
                            "<", deg2rad(60.0), 0.0, 21600.0,
                            1000, cnfine)
            result = gfilum("Ellipsoid", "EMISSION", "MARS", "SUN",
                            "IAU_MARS", "CN+S", "PHOBOS", pos,
                            "<", deg2rad(20.0), 0.0, 900.0,
                            1000, wnsolr)
            @test wncard(result) > 0
            start_epoch = timout(result[1],  "YYYY MON DD HR:MN:SC.###### UTC")
            end_epoch   = timout(result[end], "YYYY MON DD HR:MN:SC.###### UTC")
            @test startswith(start_epoch, "1971 OCT 02")
            @test startswith(end_epoch, "1971 NOV 29")
        finally
            kclear()
        end
    end
    @testset "gfocce" begin
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            et0 = str2et("2001 DEC 01 00:00:00 TDB")
            et1 = str2et("2002 JAN 01 00:00:00 TDB")
            cnfine = SpiceDoubleCell(2)
            wninsd!(cnfine, et0, et1)
            result = SpiceDoubleCell(1000)
            gfsstp(20.0)
            gfocce!("Any", "moon", "ellipsoid", "iau_moon", "sun",
                    "ellipsoid", "iau_sun", "lt", "earth", 1.e-6,
                    gfstep, gfrefn, true, gfrepi, gfrepu, gfrepf,
                    cnfine, result)
            @test wncard(result) == 1
        finally
            gfsstp(0.5)
            kclear()
        end
    end
    @testset "gfoclt" begin
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            et0 = str2et("2001 DEC 01 00:00:00 TDB")
            et1 = str2et("2002 JAN 01 00:00:00 TDB")
            cnfine = SpiceDoubleCell(2)
            wninsd!(cnfine, et0, et1)
            result = gfoclt("ANY", "MOON", "ELLIPSOID", "IAU_MOON", "SUN",
                            "ELLIPSOID", "IAU_SUN", "LT", "EARTH", 15 * 60.0, cnfine)
            count = wncard(result)
            @test count == 1
            start, stop = wnfetd(result, 1)
            start_time = timout(start, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41)
            end_time = timout(stop, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41)
            @test start_time == "2001-DEC-14 20:10:14.203347 (TDB)"
            @test end_time == "2001-DEC-14 21:35:50.328804 (TDB)"
        finally
            kclear()
        end
    end
    @testset "gfpa" begin
        relate = ["=", "<", ">", "LOCMIN", "ABSMIN", "LOCMAX", "ABSMAX"]
        expected = Dict("=" => [
                                "2006-DEC-02 13:31:34.425",
                                "2006-DEC-02 13:31:34.425",
                                "2006-DEC-07 14:07:55.480",
                                "2006-DEC-07 14:07:55.480",
                                "2007-JAN-01 00:00:00.007",
                                "2007-JAN-01 00:00:00.007",
                                "2007-JAN-06 08:16:25.522",
                                "2007-JAN-06 08:16:25.522",
                                "2007-JAN-30 11:41:32.568",
                                "2007-JAN-30 11:41:32.568",
                               ],
                        "<" => [
                                "2006-DEC-02 13:31:34.425",
                                "2006-DEC-07 14:07:55.480",
                                "2007-JAN-01 00:00:00.007",
                                "2007-JAN-06 08:16:25.522",
                                "2007-JAN-30 11:41:32.568",
                                "2007-JAN-31 00:00:00.000",
                               ],
                        ">" => [
                                "2006-DEC-01 00:00:00.000",
                                "2006-DEC-02 13:31:34.425",
                                "2006-DEC-07 14:07:55.480",
                                "2007-JAN-01 00:00:00.007",
                                "2007-JAN-06 08:16:25.522",
                                "2007-JAN-30 11:41:32.568",
                               ],
                        "LOCMIN" => [
                                     "2006-DEC-05 00:16:50.327",
                                     "2006-DEC-05 00:16:50.327",
                                     "2007-JAN-03 14:18:31.987",
                                     "2007-JAN-03 14:18:31.987",
                                    ],
                        "ABSMIN" => [
                                     "2007-JAN-03 14:18:31.987",
                                     "2007-JAN-03 14:18:31.987",
                                    ],
                        "LOCMAX" => [
                                     "2006-DEC-20 14:09:10.402",
                                     "2006-DEC-20 14:09:10.402",
                                     "2007-JAN-19 04:27:54.610",
                                     "2007-JAN-19 04:27:54.610",
                                    ],
                        "ABSMAX" => [
                                     "2007-JAN-19 04:27:54.610",
                                     "2007-JAN-19 04:27:54.610",
                                    ])
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            et0 = str2et("2006 DEC 01")
            et1 = str2et("2007 JAN 31")
            cnfine = SpiceDoubleCell(2)
            wninsd!(cnfine, et0, et1)
            result = SpiceDoubleCell(2000)
            for relation in relate
                result = gfpa("Moon", "Sun", "LT+S", "Earth", relation, 0.57598845,
                              0.0, spd(), 5000, cnfine)
                count = wncard(result)
                @test count > 0
                if count > 0
                    temp_results = String[]
                    for i in 1:count
                        left, right = wnfetd(result, i)
                        timstr_left = timout(left, "YYYY-MON-DD HR:MN:SC.###")
                        timstr_right = timout(right, "YYYY-MON-DD HR:MN:SC.###")
                        push!(temp_results, timstr_left)
                        push!(temp_results, timstr_right)
                    end
                    @test temp_results == expected[relation]
                end
            end
        finally
            kclear()
        end
    end
    @testset "gfposc" begin
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            et0 = str2et("2007 JAN 01")
            et1 = str2et("2008 JAN 01")
            cnfine = SpiceDoubleCell(2)
            wninsd!(cnfine, et0, et1)
            result = gfposc("sun", "iau_earth", "none", "earth", "latitudinal", "latitude",
                            "absmax", 0.0, 0.0, 90.0 * spd(), 1000, cnfine)
            count = wncard(result)
            @test count == 1
            start, stop = wnfetd(result, 1)
            start_time = timout(start, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41)
            end_time = timout(stop, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41)
            @test start_time == end_time
            @test start_time == "2007-JUN-21 17:54:13.201561 (TDB)"
        finally
            kclear()
        end
    end
    @testset "gfrefn" begin
        s1 = [true, false]
        s2 = [true, false]
        for i in 1:2
            for j in 1:2
                scale = 10.0 * i + j
                t1 = 5.0 * scale
                t2 = 7.0 * scale
                t  = gfrefn(t1, t2, s1[i], s2[j])
                @test t ≈ scale * 6.0
            end
        end
        for i in 1:2
            for j in 1:2
                scale = 10.0 * i + j
                t1 = 15.0 * scale
                t2 = 7.0 * scale
                t  = gfrefn(t1, t2, s1[i], s2[j])
                @test t ≈ scale * 11.0
            end
        end
        for i in 1:2
            for j in 1:2
                scale = 10.0 * i + j
                t1 = -scale
                t2 = -scale
                t  = gfrefn(t1, t2, s1[i], s2[j])
                @test t ≈ -scale
            end
        end
    end
    @testset "gfrepi" begin
        window = SpiceDoubleCell(4)
        wninsd!(window, 0., 100.)
        gfrepi(window, "x", "y")
        # BEGMSS or ENDMSS empty, too long, or containing non-printing characters
        @test_throws SpiceError gfrepi(window, "", "y")
        @test_throws SpiceError gfrepi(window, "x", "")
        @test_throws SpiceError gfrepi(window, "x"^1000, "y")
        @test_throws SpiceError gfrepi(window, "x", "y"^1000)
        @test_throws SpiceError gfrepi(window, "y\n", "y")
        @test_throws SpiceError gfrepi(window, "x", "y\n")
        gfrepf()
    end
    @testset "gfrepu" begin
        window = SpiceDoubleCell(4)
        wninsd!(window, 0., 100.)
        gfrepi(window, "x", "y")
        gfrepu(0., 100., 50.)
        gfrepu(0., 100., 100.)
        @test_throws SpiceError gfrepu(100., 0., 100.)
        @test_throws SpiceError gfrepu(0., 100., -1.)
        @test_throws SpiceError gfrepu(0., 100., 1011.)
        gfrepu(0., 100., 100.)
        gfrepf()
    end
    @testset "gfrfov" begin
        try
            furnsh(path(CORE, :lsk),
                   path(CORE, :pck),
                   path(CORE, :spk),
                   path(CASSINI, :ck),
                   path(CASSINI, :fk),
                   path(CASSINI, :ik),
                   path(CASSINI, :pck),
                   path(CASSINI, :sclk),
                   path(CASSINI, :tour_spk),
                   path(CASSINI, :sat_spk))
            inst = "CASSINI_ISS_WAC"
            et_start1 = str2et("2013-FEB-25 07:20:00.000")
            et_end1 = str2et("2013-FEB-25 11:45:00.000")
            et_start2 = str2et("2013-FEB-25 11:55:00.000")
            et_end2 = str2et("2013-FEB-26 14:25:00.000")
            cnfine = SpiceDoubleCell(4)
            wninsd!(cnfine, et_start1, et_end1)
            wninsd!(cnfine, et_start2, et_end2)
            et_nom = str2et("2013-FEB-25 11:50:00.000")
            raydir, lt = spkpos("Enceladus", et_nom, "J2000", "NONE", "Cassini")
            result = gfrfov(inst, raydir, "J2000", "NONE", "Cassini", 10.0, cnfine)
            @test length(result) == 4
            s_timout = "YYYY-MON-DD HR:MN:SC UTC ::RND"
            @test timout(result[1], s_timout) == "2013-FEB-25 11:26:46 UTC"
            @test timout(result[2], s_timout) == "2013-FEB-25 11:45:00 UTC"
            @test timout(result[3], s_timout) == "2013-FEB-25 11:55:00 UTC"
            @test timout(result[4], s_timout) == "2013-FEB-25 12:05:33 UTC"
        finally
            kclear()
        end
    end
    @testset "gfrr" begin
        relate = ["=", "<", ">", "LOCMIN", "ABSMIN", "LOCMAX", "ABSMAX"]
        expected = Dict("=" => ["2007-JAN-02 00:35:19.583",
                                "2007-JAN-02 00:35:19.583",
                                "2007-JAN-19 22:04:54.905",
                                "2007-JAN-19 22:04:54.905",
                                "2007-FEB-01 23:30:13.439",
                                "2007-FEB-01 23:30:13.439",
                                "2007-FEB-17 11:10:46.547",
                                "2007-FEB-17 11:10:46.547",
                                "2007-MAR-04 15:50:19.940",
                                "2007-MAR-04 15:50:19.940",
                                "2007-MAR-18 09:59:05.966",
                                "2007-MAR-18 09:59:05.966"],
                        "<" => ["2007-JAN-02 00:35:19.583",
                                "2007-JAN-19 22:04:54.905",
                                "2007-FEB-01 23:30:13.439",
                                "2007-FEB-17 11:10:46.547",
                                "2007-MAR-04 15:50:19.940",
                                "2007-MAR-18 09:59:05.966"],
                        ">" => ["2007-JAN-01 00:00:00.000",
                                "2007-JAN-02 00:35:19.583",
                                "2007-JAN-19 22:04:54.905",
                                "2007-FEB-01 23:30:13.439",
                                "2007-FEB-17 11:10:46.547",
                                "2007-MAR-04 15:50:19.940",
                                "2007-MAR-18 09:59:05.966",
                                "2007-APR-01 00:00:00.000"],
                        "LOCMIN" => ["2007-JAN-11 07:03:59.001",
                                     "2007-JAN-11 07:03:59.001",
                                     "2007-FEB-10 06:26:15.451",
                                     "2007-FEB-10 06:26:15.451",
                                     "2007-MAR-12 03:28:36.414",
                                     "2007-MAR-12 03:28:36.414"],
                        "ABSMIN" => ["2007-JAN-11 07:03:59.001",
                                     "2007-JAN-11 07:03:59.001"],
                        "LOCMAX" => ["2007-JAN-26 02:27:33.772",
                                     "2007-JAN-26 02:27:33.772",
                                     "2007-FEB-24 09:35:07.822",
                                     "2007-FEB-24 09:35:07.822",
                                     "2007-MAR-25 17:26:56.158",
                                     "2007-MAR-25 17:26:56.158"],
                        "ABSMAX" => ["2007-MAR-25 17:26:56.158",
                                     "2007-MAR-25 17:26:56.158"])
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            et0 = str2et("2007 JAN 01")
            et1 = str2et("2007 APR 01")
            cnfine = SpiceDoubleCell(2)
            wninsd!(cnfine, et0, et1)
            for relation in relate
                result = gfrr("MOON", "NONE", "SUN", relation, 0.3365, 0.0, spd(), 2000, cnfine)
                count = wncard(result)
                if count > 0
                    results = String[]
                    for i in 1:count
                        left, right = wnfetd(result, i)
                        timstr_left = timout(left, "YYYY-MON-DD HR:MN:SC.###", 41)
                        timstr_right = timout(right, "YYYY-MON-DD HR:MN:SC.###", 41)
                        push!(results, timstr_left)
                        push!(results, timstr_right)
                    end
                    @test results == expected[relation]
                end
            end
        finally
            kclear()
        end
    end
    @testset "gfsep" begin
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            expected = ["2007-JAN-03 14:20:24.628017 (TDB)",
                        "2007-FEB-02 06:16:24.111794 (TDB)",
                        "2007-MAR-03 23:22:42.005064 (TDB)",
                        "2007-APR-02 16:49:16.145506 (TDB)",
                        "2007-MAY-02 09:41:43.840096 (TDB)",
                        "2007-JUN-01 01:03:44.537483 (TDB)",
                        "2007-JUN-30 14:15:26.586223 (TDB)",
                        "2007-JUL-30 01:14:49.010797 (TDB)",
                        "2007-AUG-28 10:39:01.398087 (TDB)",
                        "2007-SEP-26 19:25:51.519413 (TDB)",
                        "2007-OCT-26 04:30:56.635336 (TDB)",
                        "2007-NOV-24 14:31:04.341632 (TDB)",
                        "2007-DEC-24 01:40:12.245932 (TDB)"]
            et0 = str2et("2007 JAN 01")
            et1 = str2et("2008 JAN 01")
            cnfine = SpiceDoubleCell(2)
            wninsd!(cnfine, et0, et1)
            result = gfsep("MOON", "SPHERE", "NULL", "SUN", "SPHERE", "NULL", "NONE", "EARTH",
                           "LOCMAX", 0.0, 0.0, 6.0 * spd(), 1000, cnfine)
            count = wncard(result)
            @test count == 13
            results = []
        for i in 1:count
                start, stop = wnfetd(result, i)
                @test start == stop
                push!(results, timout(start, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41))
            end
            @test results == expected
        finally
            kclear()
        end
    end
    @testset "gfsntc" begin
        kclear()
        kernel = tempname()
        open(kernel, "w") do kernel_file
            write(kernel_file, "\\begindata\n")
            write(kernel_file, "FRAME_SEM                     =  10100000\n")
            write(kernel_file, "FRAME_10100000_NAME           = 'SEM'\n")
            write(kernel_file, "FRAME_10100000_CLASS          =  5\n")
            write(kernel_file, "FRAME_10100000_CLASS_ID       =  10100000\n")
            write(kernel_file, "FRAME_10100000_CENTER         =  10\n")
            write(kernel_file, "FRAME_10100000_RELATIVE       = 'J2000'\n")
            write(kernel_file, "FRAME_10100000_DEF_STYLE      = 'PARAMETERIZED'\n")
            write(kernel_file, "FRAME_10100000_FAMILY         = 'TWO-VECTOR'\n")
            write(kernel_file, "FRAME_10100000_PRI_AXIS       = 'X'\n")
            write(kernel_file, "FRAME_10100000_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION'\n")
            write(kernel_file, "FRAME_10100000_PRI_OBSERVER   = 'SUN'\n")
            write(kernel_file, "FRAME_10100000_PRI_TARGET     = 'EARTH'\n")
            write(kernel_file, "FRAME_10100000_PRI_ABCORR     = 'NONE'\n")
            write(kernel_file, "FRAME_10100000_SEC_AXIS       = 'Y'\n")
            write(kernel_file, "FRAME_10100000_SEC_VECTOR_DEF = 'OBSERVER_TARGET_VELOCITY'\n")
            write(kernel_file, "FRAME_10100000_SEC_OBSERVER   = 'SUN'\n")
            write(kernel_file, "FRAME_10100000_SEC_TARGET     = 'EARTH'\n")
            write(kernel_file, "FRAME_10100000_SEC_ABCORR     = 'NONE'\n")
            write(kernel_file, "FRAME_10100000_SEC_FRAME      = 'J2000'\n")
        end
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            furnsh(kernel)
            et0 = str2et("2007 JAN 01")
            et1 = str2et("2008 JAN 01")
            cnfine = SpiceDoubleCell(2)
            wninsd!(cnfine, et0, et1)
            result = gfsntc("EARTH", "IAU_EARTH", "Ellipsoid", "NONE", "SUN", "SEM", [1.0, 0.0, 0.0],
                            "LATITUDINAL", "LATITUDE", "=", 0.0, 0.0, 90.0 * spd(), 1000, cnfine)
            count = wncard(result)
            @test count > 0
            beg, stop = wnfetd(result, 1)
            begstr = timout(beg, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 80)
            endstr = timout(stop, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 80)
            @test begstr == "2007-MAR-21 00:01:25.527303 (TDB)"
            @test endstr == "2007-MAR-21 00:01:25.527303 (TDB)"
            beg, stop = wnfetd(result, 2)
            begstr = timout(beg, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 80)
            endstr = timout(stop, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 80)
            @test startswith(begstr, "2007-SEP-23 09:46:39.60698")
            @test startswith(endstr, "2007-SEP-23 09:46:39.60698")
        finally
            kclear()
        end
    end
    @testset "gfstep/gfsstp" begin
        gfsstp(0.5)
        @test gfstep(0.5) == 0.5
    end
    @testset "gfsubc" begin
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            et0 = str2et("2007 JAN 01")
            et1 = str2et("2008 JAN 01")
            cnfine = SpiceDoubleCell(2)
            wninsd!(cnfine, et0, et1)
            result = gfsubc("earth", "iau_earth", "Near point: ellipsoid", "none", "sun",
                            "geodetic", "latitude", ">", deg2rad(16.0), 0.0, spd() * 90.0, 1000,
                            cnfine)
            count = wncard(result)
            @test count > 0
            start, stop = wnfetd(result, 1)
            start_time = timout(start, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41)
            end_time = timout(stop, "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND", 41)
            @test start_time == "2007-MAY-04 17:08:56.724320 (TDB)"
            @test end_time == "2007-AUG-09 01:51:29.307830 (TDB)"
        finally
            kclear()
        end
    end
    @testset "gftfov" begin
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk),
                   path(CASSINI, :ck),
                   path(CASSINI, :fk),
                   path(CASSINI, :ik),
                   path(CASSINI, :pck),
                   path(CASSINI, :sclk),
                   path(CASSINI, :tour_spk),
                   path(CASSINI, :sat_spk))
            et_start1 = str2et("2013-FEB-25 07:20:00.000")
            et_end1 = str2et("2013-FEB-25 11:45:00.000")
            et_start2 = str2et("2013-FEB-25 11:55:00.000")
            et_end2 = str2et("2013-FEB-26 14:25:00.000")
            cnfine = SpiceDoubleCell(4)
            wninsd!(cnfine, et_start1, et_end1)
            wninsd!(cnfine, et_start2, et_end2)
            result = gftfov("CASSINI_ISS_NAC", "ENCELADUS", "ELLIPSOID", "IAU_ENCELADUS", "LT", "CASSINI", 10.0, 5000, cnfine)
            @test card(result) == 4
            s_timout = "YYYY-MON-DD HR:MN:SC UTC ::RND"
            @test timout(result[1], s_timout) == "2013-FEB-25 10:42:33 UTC"
            @test timout(result[2], s_timout) == "2013-FEB-25 11:45:00 UTC"
            @test timout(result[3], s_timout) == "2013-FEB-25 11:55:00 UTC"
            @test timout(result[4], s_timout) == "2013-FEB-25 12:04:30 UTC"
        finally
            kclear()
        end
    end
    @testset "gfudb" begin
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            et_start = str2et("Jan 1 2001")
            et_end = str2et("Jan 1 2002")
            result = SpiceDoubleCell(40000)
            cnfine = SpiceDoubleCell(2)
            wninsd!(cnfine, et_start, et_end)
            step = 5.0 * spd()

            function gfq(_, et)
                state, lt = spkez(301, et, "IAU_EARTH", "NONE", 399)
                state[3] >= 0.0 && state[6] > 0.0
            end

            gfudb!(_ -> 0.0, gfq, step, cnfine, result)
            @test length(result) > 20 # true value is 28
        finally
            kclear()
        end
    end
    @testset "gfudb2" begin
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            et_start = str2et("Jan 1 2001")
            et_end = str2et("Jan 1 2002")
            result = SpiceDoubleCell(40000)
            cnfine = SpiceDoubleCell(2)
            wninsd!(cnfine, et_start, et_end)
            step = 60.0 * 60.0

            function gfq(et)
                pos, _ = spkezp(301, et, "IAU_EARTH", "NONE", 399)
                pos[3]
            end

            function gfb(udfuns, et)
                value = udfuns(et)
                -1000.0 <= value <= 1000.0
            end

            gfudb!(gfq, gfb, step, cnfine, result)
            @test length(result) > 50  # true value is 56
        finally
            kclear()
        end
    end
    @testset "gfuds" begin
        try
            furnsh(path(CORE, :lsk), path(CORE, :pck), path(CORE, :spk))
            relations = ["=", "<", ">", "LOCMIN", "ABSMIN", "LOCMAX", "ABSMAX"]
            et_start = str2et("Jan 1 2007")
            et_end = str2et("Apr 1 2007")
            step = spd()
            adjust = 0.0
            refval  = 0.3365

            function gfq(et)
                state, _ = spkez(301, et, "J2000", "NONE", 10)
                dvnorm(state)
            end

            function gfdecrx(udfuns, et)
                h = 1.0
                dx = uddf(udfuns, et, h)
                dx < 0.0
            end

            @testset for r in relations
                result = SpiceDoubleCell(40000)
                cnfine = SpiceDoubleCell(2)
                wninsd!(cnfine, et_start, et_end)
                result = gfuds!(gfq, gfdecrx, r, refval, adjust, step, 20000, cnfine, result)
                @test length(result) > 0
            end
        finally
            kclear()
        end
    end
    @testset "gipool" begin
        try
            data = collect(1:10)
            pipool("pipool_array", data)
            ivals = gipool("pipool_array")
            @test data == ivals
        finally
            kclear()
        end
    end
    @testset "gnpool" begin
        try
            furnsh(path(CORE, :pck))
            var = "BODY599*"
            index = 1
            room = 10
            expected = ["BODY599_POLE_DEC", "BODY599_LONG_AXIS", "BODY599_PM", "BODY599_RADII",
                        "BODY599_POLE_RA", "BODY599_NUT_PREC_PM", "BODY599_NUT_PREC_DEC",
                        "BODY599_NUT_PREC_RA"]
            kervar = gnpool(var, index, room)
            @test Set(expected) == Set(kervar)
            @test gnpool("BLOB", index, room) === nothing
        finally
            kclear()
        end
    end
end

ext: jl


text:
# Test FFD function that make parallel MPI calls

# MPI Declarations
comm = MPI.COMM_WORLD
comm_world = MPI.MPI_COMM_WORLD
comm_self = MPI.COMM_SELF
my_rank = MPI.Comm_rank(comm)
comm_size = MPI.Comm_size(comm)

# opts = PdePumiInterface.get_defaults()
# 2D mesh
opts = Dict{ASCIIString, Any}()
opts["order"] = 1
opts["dimensions"] = 2
opts["use_DG"] = true
opts["operator_type"] = "SBPOmega"
opts["dmg_name"] = ".null"
opts["smb_name"] = "../src/mesh_files/gvortex1np2.smb"
opts["Tsbp"] = Float64
opts["Tmsh"] = Complex128

# For 2D Isentropic Vortex
opts["numBC"] = 4
opts["BC1"] = [0]
opts["BC1_name"] = "FreeStreamBC"
opts["BC2"] = [1]
opts["BC2_name"] = "FreeStreamBC"
opts["BC3"] = [2]
opts["BC3_name"] = "FreeStreamBC"
opts["BC4"] = [3]
opts["BC4_name"] = "noPenetrationBC"

opts["coloring_distance"] = 2 # 0 For CG Mesh 2 for DG Mesh
opts["jac_type"] = 1
opts["run_type"] = 1
opts["jac_method"] = 2
opts["use_jac_precond"] = true

# Create PumiMesh and SBP objects
Tsbp = opts["Tsbp"]
Tmsh = opts["Tmsh"]
sbp = getTriSBPOmega(degree=opts["order"], Tsbp=Tsbp)
shape_type = 2
ref_verts = [-1. 1 -1; -1 -1 1]
sbpface = TriFace{Tsbp}(opts["order"], sbp.cub, ref_verts.')
topo = 0
mesh = PumiMeshDG2{Tmsh}(opts["dmg_name"], opts["smb_name"], opts["order"],
                         sbp, opts, sbpface; dofpernode=1,
                         coloring_distance=opts["coloring_distance"],
                         shape_type=shape_type)
# sbp, mesh, pmesh, Tsol, Tres, Tmsh, mesh_time = createMeshAndOperator(opts, 1)

orig_vert_coords = deepcopy(mesh.vert_coords)

@testset "--- Checking control point manipulation for 2D parallel mesh" begin

  @testset "Check for the entire mesh" begin
    ndim = mesh.dim
    order = [4,4,2]  # Order of B-splines in the 3 directions
    nControlPts = [4,4,2]
    offset = [0., 0., 0.5] # No offset in the X & Y direction

    # Create a mapping object using nonlinear mapping
    map, box = initializeFFD(mesh, sbp, order, nControlPts, offset, true)

    # Control Point Manipulation
    #  - Rigid body rotation
    theta = -90*pi/180  # Rotate wall coordinates by 90 degrees
    rotMat = [cos(theta) -sin(theta) 0
              sin(theta) cos(theta)  0
              0          0           1] # Rotation matrix
    # - Rotate the control points
    for k = 1:map.nctl[3]
      for j = 1:map.nctl[2]
        for i = 1:map.nctl[1]
          map.cp_xyz[:,i,j,k] = rotMat*map.cp_xyz[:,i,j,k]
        end
      end
    end

    # - Rigid body translation
    map.cp_xyz[1,:,:,:] += 0.2
    map.cp_xyz[2,:,:,:] += 0.3

    vertices = evalVolume(map, mesh)
    commitToPumi(map, mesh, sbp, vertices, opts)

    filename = string("translation_plus_rotation_DG_parallel_fullmesh_", mesh.myrank, ".dat")
    # f = open(string("./testvalues/", filename), "w")
    # for i = 1:length(vertices)
    #   println(f, vertices[i])
    # end
    # close(f)

    test_vtx_coords = readdlm(string("./testvalues/", filename))
    for i = 1:length(test_vtx_coords)
      err = abs.(test_vtx_coords[i] - mesh.vert_coords[i])
      @test  err  < 1e-14
    end

    # writeVisFiles(mesh, "translation_plus_rotation_DG_parallel_fullmesh")

  end # End context("Check for the entire mesh")

  # Reset the coordinates and mesh to the original value
  for i = 1:mesh.numEl
    update_coords(mesh, i, real(orig_vert_coords[:,:,i]))
  end
  commit_coords(mesh, sbp, opts)

  @testset "Check for a geometric surface" begin

    # Free Form deformation parameters
    ndim = mesh.dim
    order = [4,4,2]  # Order of B-splines in the 3 directions
    nControlPts = [4,4,2]
    offset = [0., 0., 0.5] # No offset in the X & Y direction
    Tmsh = Float64
    geom_faces = opts["BC4"]

    # Create a mapping object using nonlinear mapping
    map, box = initializeFFD(mesh, sbp, order, nControlPts, offset, false, geom_faces)

    # Control Point Manipulation
    #  - Rigid body rotation
    theta = -5*pi/180  # Rotate wall coordinates by 5 degrees
    rotMat = [cos(theta) -sin(theta) 0
              sin(theta) cos(theta)  0
              0          0           1] # Rotation matrix
    # - Rotate the control points
    for k = 1:map.nctl[3]
      for j = 1:map.nctl[2]
        for i = 1:map.nctl[1]
          map.cp_xyz[:,i,j,k] = rotMat*map.cp_xyz[:,i,j,k]
        end
      end
    end

    # - Rigid body translation
    map.cp_xyz[1,:,:,:] += 0.05

    vertices = evalSurface(map, mesh)
    commitToPumi(map, mesh, sbp, vertices, opts)

    filename = string("translation_plus_rotation_DG_parallel_surfaceBC4_", mesh.myrank, ".dat")
    # f = open(string("./testvalues/", filename), "w")
    # for i = 1:length(mesh.vert_coords)
    #  println(f, mesh.vert_coords[i])
    # end
    # close(f)

    test_vtx_coords = readdlm(string("./testvalues/", filename))
    for i = 1:length(test_vtx_coords)
      err = abs.(test_vtx_coords[i] - mesh.vert_coords[i])
      @test  err  < 1e-14
    end

    writeVisFiles(mesh, "translation_plus_rotation_DG_parallel_surface")

  end # End context("Check for a geometric surface")

end # End facts("--- Checking control point manipulation for 2D parallel mesh")

# Reset the coordinates and mesh to the original value
for i = 1:mesh.numEl
  update_coords(mesh, i, real(orig_vert_coords[:,:,i]))
end
commit_coords(mesh, sbp, opts)
MPI.Barrier(comm)

@testset "--- Checking evaldXdControlPointProduct for 2D DG Mesh ---" begin

  # Free Form deformation parameters
  ndim = mesh.dim
  order = [4,4,2]  # Order of B-splines in the 3 directions
  nControlPts = [4,4,2]
  offset = [0., 0., 0.5] # No offset in the X & Y direction
  Tmsh = Float64
  geom_faces = opts["BC4"]

  # Create a mapping object using nonlinear mapping
  map, box = initializeFFD(mesh, sbp, order, nControlPts, offset, false, geom_faces)

  fill!(map.work, 0.0)

  # Create seed vector
  # - Get original wall coordinates
  orig_wallCoords = FFD.getGlobalUniqueWallCorrdsArray(mesh, geom_faces)
  Xs_bar = ones(3, size(orig_wallCoords,2))
  Xs_bar[3,:] = 0.0 # To accurately simulate a 2D mesh
  cp_xyz_bar = zeros(map.cp_xyz)
  evaldXdControlPointProduct(map, mesh, vec(Xs_bar))

  filename = "./testvalues/evaldXdControlPointProduct.dat"
  test_values = readdlm(filename)
  for i = 1:length(test_values)
    err = test_values[i] - map.work[i]
    @test  err  < 1e-14
  end

end # End


text:
path = @get_scratch!("cartpole")

nq = cartpole_friction.nq
nu = cartpole_friction.nu
nc = cartpole_friction.nc
nz = nq + 4 * nc
nθ = nq + nq + nu + 2 + 1
nz_nf = nq
nθ_nf = nq + nq + nu + 1

# Declare variables
@variables z[1:nz]
@variables θ[1:nθ]
@variables κ[1:1]
@variables z_nf[1:nz_nf]
@variables θ_nf[1:nθ_nf]
@variables κ_nf[1:1]

# Residual
r_friction= residual(cartpole_friction, z, θ, κ)
r_friction = Symbolics.simplify.(r_friction)
rz_friction = Symbolics.jacobian(r_friction, z, simplify=true)
rθ_friction = Symbolics.jacobian(r_friction, θ, simplify=true)

# Build function
r_cartpole_friction_func = build_function(r_friction, z, θ, κ)[2]
rz_cartpole_friction_func = build_function(rz_friction, z, θ)[2]
rθ_cartpole_friction_func = build_function(rθ_friction, z, θ)[2]

rz_cartpole_friction_array = similar(rz_friction, Float64)
rθ_cartpole_friction_array = similar(rθ_friction, Float64)

@save joinpath(path, "friction.jld2") r_cartpole_friction_func rz_cartpole_friction_func rθ_cartpole_friction_func rz_cartpole_friction_array rθ_cartpole_friction_array
@load joinpath(path, "friction.jld2") r_cartpole_friction_func rz_cartpole_friction_func rθ_cartpole_friction_func rz_cartpole_friction_array rθ_cartpole_friction_array

# Residual
r_frictionless = residual(cartpole_frictionless, z_nf, θ_nf, κ_nf)
r_frictionless = Symbolics.simplify.(r_frictionless)
rz_frictionless = Symbolics.jacobian(r_frictionless, z_nf, simplify=true)
rθ_frictionless = Symbolics.jacobian(r_frictionless, θ_nf, simplify=true)

# Build function
r_cartpole_frictionless_func = build_function(r_frictionless, z_nf, θ_nf, κ_nf)[2]
rz_cartpole_frictionless_func = build_function(rz_frictionless, z_nf, θ_nf)[2]
rθ_cartpole_frictionless_func = build_function(rθ_frictionless, z_nf, θ_nf)[2]

rz_cartpole_frictionless_array = similar(rz_frictionless, Float64)
rθ_cartpole_frictionless_array = similar(rθ_frictionless, Float64)

@save joinpath(path, "frictionless.jld2") r_cartpole_frictionless_func rz_cartpole_frictionless_func rθ_cartpole_frictionless_func rz_cartpole_frictionless_array rθ_cartpole_frictionless_array
@load joinpath(path, "frictionless.jld2") r_cartpole_frictionless_func rz_cartpole_frictionless_func rθ_cartpole_frictionless_func rz_cartpole_frictionless_array rθ_cartpole_frictionless_array


text:
using LasIO
using LazIO
using FileIO
using StaticArrays
using Plots
using JSON

## ------------FUNCTIONS-------------- ##
"Group points of pulse, dictinary index --> tag,intensity,z value, return number"
function grouping(points,header)
    prev_point = points[1]
    group_pulse = Dict{Int,Tuple{String,UInt16,Float64,UInt8}}() #dictionary with indexes and tags
    n = 0
    for (i,p) in enumerate(points)
        inten = intensity(p)
        z = zcoord(p,header)
        rn = return_number(p)
        nr = number_of_returns(p)
        dt = gps_time(p) - gps_time(prev_point)
        if (rn == n ) && (nr > 1) #for every pulse
            if rn == 1
                group_pulse[i] = ("firstpoint",inten,z,rn)
            elseif rn < nr && dt < 1e-7
                group_pulse[i] = ("nextpoint",inten,z,rn)
            elseif rn == nr && dt < 1e-7
                group_pulse[i] = ("lastpoint",inten,z,rn)
            end
            if nr == rn
                n = 0
            end
        elseif nr == 1 && rn == 1 #cases that I have JUST one point!
            group_pulse[i] = ("firstpoint",inten,z,rn)
            n = 0
        elseif nr > 1 && rn == 1 #cases that I have JUST one point!
            group_pulse[i] = ("firstpoint",inten,z,rn)
            n = 0
        elseif nr == rn && nr!=1 #cases that I have remaining points like rn=3, nr=3 from other pulse!
            group_pulse[i] = ("lastpoint",inten,z,rn)
            n = 0
        else
            group_pulse[i] = ("unclassified",inten,z,rn)
            n = 0
        end
        n+=1
        prev_point = p
    end
    group_pulse
end

"Write LAS file"
function write_output(writefiles, ds, points)
    LazIO.write(writefiles, ds.header) do io
        for (i,p) in enumerate(ds)
            if i in points
                p.classification = UInt(5)
                LazIO.writepoint(io,p)
            end
        end
    end
end

## ---------------MAIN-----------------##
"read - import dataset from a json file"
workdir = dirname(@__FILE__)
open(joinpath(workdir,"pulse.json"), "r") do f
    global mydict = Dict(JSON.parse(read(f,String)))  # parse and transform data
end

#get the filename
filenn_NL1 = joinpath(workdir,mydict["dataname"] * ".laz")
filenn_NL1_las = File{format"LAZ_"}(filenn_NL1)

#read specific LAS file
header, points = LazIO.load(filenn_NL1_las) #point cloud as LAS points format
n = length(points) #number of points

#read dataset
ds = LazIO.open(filenn_NL1) #dataset

#export plots
# path = "C:/Users/alexandr/OneDrive - Stichting Deltares/Desktop/Thesis/P3_processing/with_greenstowa/Working_to/Plots_378_NL3"
# println("Export path: Ok")
# name = "141_NL3"

#Grouping_points per pulse into 3 and 2 points
group_pulses = grouping(points,header) #point id --> tag, intensity, z_val, return number (rn)
allkeys = collect(keys(group_pulses)) #keys
p3_pulse = Vector{Vector{Float64}}[] ; p2_pulse = Vector{Vector{Float64}}[] #store triplets  and doubles of pulses
bottom_points_3 = Int64[]; bottom_points_2 = Int64[]
all_bottoms = Int64[]
for (i,key) in enumerate(allkeys)
    lex = group_pulses[key]
    if lex[1] == "nextpoint"
        if group_pulses[allkeys[i-1]][1] == "firstpoint" && group_pulses[allkeys[i+1]][1] == "lastpoint" && group_pulses[allkeys[i+1]][4] != group_pulses[allkeys[i]][4] #check the return number of last and second point

            #intensities
            sec_int = group_pulses[allkeys[i]][2]
            fir_int = group_pulses[allkeys[i-1]][2]
            last_int = group_pulses[allkeys[i+1]][2]

            #Check if LAST point's intensity >= MIDDLE point's intensity
            if (last_int/sec_int) >= 1
                push!(bottom_points_3,key)
                push!(all_bottoms,key)
            end

            #z_values
            sec_z = group_pulses[allkeys[i]][3]
            fir_z = group_pulses[allkeys[i-1]][3]
            last_z = group_pulses[allkeys[i+1]][3]

            #return number (rn)
            sec_rn = group_pulses[allkeys[i]][4]
            fir_rn = group_pulses[allkeys[i-1]][4]
            last_rn = group_pulses[allkeys[i+1]][4]

            push!(p3_pulse,[[fir_int,fir_z,fir_rn], [sec_int,sec_z,sec_rn], [last_int,last_z,last_rn]])
        end
    elseif lex[1] == "lastpoint"
        if group_pulses[allkeys[i-1]][1] == "firstpoint"

            #intensities
            fir_int = group_pulses[allkeys[i-1]][2]
            sec_int = group_pulses[allkeys[i]][2]

            #z_values
            fir_z = group_pulses[allkeys[i-1]][3]
            sec_z = group_pulses[allkeys[i]][3]

            #return number (rn)
            fir_rn = group_pulses[allkeys[i-1]][4]
            sec_rn = group_pulses[allkeys[i]][4]

            push!(p2_pulse,[[fir_int,fir_z,fir_rn], [sec_int,sec_z,sec_rn]])
            push!(bottom_points_2,key)
            push!(all_bottoms,key)
        end
    end
end

println("length of p3 pulses: ",length(p3_pulse))
println("length of p2 pulses: ",length(p2_pulse))

#write output files
writefiles = joinpath(workdir, mydict["dataname"] * mydict["outputname"] * ".laz")
write_output(writefiles, ds, all_bottoms)


text:
# This file was generated by the Julia Swagger Code Generator
# Do not modify this file directly. Modify the swagger specification instead.

@doc raw"""IngressBackend describes all endpoints for a given service and port.

    IoK8sApiNetworkingV1beta1IngressBackend(;
        serviceName=nothing,
        servicePort=nothing,
    )

    - serviceName::String : Specifies the name of the referenced service.
    - servicePort::IoK8sApimachineryPkgUtilIntstrIntOrString : Specifies the port of the referenced service.
"""
mutable struct IoK8sApiNetworkingV1beta1IngressBackend <: SwaggerModel
    serviceName::Any # spec type: Union{ Nothing, String } # spec name: serviceName
    servicePort::Any # spec type: Union{ Nothing, IoK8sApimachineryPkgUtilIntstrIntOrString } # spec name: servicePort

    function IoK8sApiNetworkingV1beta1IngressBackend(;serviceName=nothing, servicePort=nothing)
        o = new()
        validate_property(IoK8sApiNetworkingV1beta1IngressBackend, Symbol("serviceName"), serviceName)
        setfield!(o, Symbol("serviceName"), serviceName)
        validate_property(IoK8sApiNetworkingV1beta1IngressBackend, Symbol("servicePort"), servicePort)
        setfield!(o, Symbol("servicePort"), servicePort)
        o
    end
end # type IoK8sApiNetworkingV1beta1IngressBackend

const _property_map_IoK8sApiNetworkingV1beta1IngressBackend = Dict{Symbol,Symbol}(Symbol("serviceName")=>Symbol("serviceName"), Symbol("servicePort")=>Symbol("servicePort"))
const _property_types_IoK8sApiNetworkingV1beta1IngressBackend = Dict{Symbol,String}(Symbol("serviceName")=>"String", Symbol("servicePort")=>"IoK8sApimachineryPkgUtilIntstrIntOrString")
Base.propertynames(::Type{ IoK8sApiNetworkingV1beta1IngressBackend }) = collect(keys(_property_map_IoK8sApiNetworkingV1beta1IngressBackend))
Swagger.property_type(::Type{ IoK8sApiNetworkingV1beta1IngressBackend }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_IoK8sApiNetworkingV1beta1IngressBackend[name]))}
Swagger.field_name(::Type{ IoK8sApiNetworkingV1beta1IngressBackend }, property_name::Symbol) =  _property_map_IoK8sApiNetworkingV1beta1IngressBackend[property_name]

function check_required(o::IoK8sApiNetworkingV1beta1IngressBackend)
    (getproperty(o, Symbol("serviceName")) === nothing) && (return false)
    (getproperty(o, Symbol("servicePort")) === nothing) && (return false)
    true
end

function validate_property(::Type{ IoK8sApiNetworkingV1beta1IngressBackend }, name::Symbol, val)
end


text:
using Test, AsymmetricRisk

@test true == true


text:
using DifferentialEquations, LinearAlgebra, SparseArrays

const N = 32
const xyd_brusselator = range(0,stop=1,length=N)
brusselator_f(x, y, t) = (((x-0.3)^2 + (y-0.6)^2) <= 0.1^2) * (t >= 1.1) * 5.
limit(a, N) = a == N+1 ? 1 : a == 0 ? N : a
function brusselator_2d_loop(du, u, p, t)
  A, B, alpha, dx = p
  alpha = alpha/dx^2
  @inbounds for I in CartesianIndices((N, N))
    i, j = Tuple(I)
    x, y = xyd_brusselator[I[1]], xyd_brusselator[I[2]]
    ip1, im1, jp1, jm1 = limit(i+1, N), limit(i-1, N), limit(j+1, N), limit(j-1, N)
    du[i,j,1] = alpha*(u[im1,j,1] + u[ip1,j,1] + u[i,jp1,1] + u[i,jm1,1] - 4u[i,j,1]) +
                B + u[i,j,1]^2*u[i,j,2] - (A + 1)*u[i,j,1] + brusselator_f(x, y, t)
    du[i,j,2] = alpha*(u[im1,j,2] + u[ip1,j,2] + u[i,jp1,2] + u[i,jm1,2] - 4u[i,j,2]) +
                A*u[i,j,1] - u[i,j,1]^2*u[i,j,2]
    end
end
p = (3.4, 1., 10., step(xyd_brusselator))

function init_brusselator_2d(xyd)
  N = length(xyd)
  u = zeros(N, N, 2)
  for I in CartesianIndices((N, N))
    x = xyd[I[1]]
    y = xyd[I[2]]
    u[I,1] = 22*(y*(1-y))^(3/2)
    u[I,2] = 27*(x*(1-x))^(3/2)
  end
  u
end
u0 = init_brusselator_2d(xyd_brusselator)
prob_ode_brusselator_2d = ODEProblem(brusselator_2d_loop,u0,(0.,11.5),p)

using SparseArrays
#f = ODEFunction(f, jac_prototype=sparsematrix)

using Symbolics
du0 = copy(u0)
jac_sparsity = Symbolics.jacobian_sparsity((du,u)->brusselator_2d_loop(du,u,p,0.0),du0,u0)

f = ODEFunction(brusselator_2d_loop;jac_prototype=float.(jac_sparsity))
prob_ode_brusselator_2d_sparse = ODEProblem(f,u0,(0.,11.5),p)

using BenchmarkTools: @btime
@btime solve(prob_ode_brusselator_2d,TRBDF2(),save_everystep=false)
@btime solve(prob_ode_brusselator_2d_sparse,TRBDF2(),save_everystep=false)
@btime solve(prob_ode_brusselator_2d,KenCarp47(linsolve=KrylovJL_GMRES()),save_everystep=false)

using IncompleteLU
function incompletelu(W,du,u,p,t,newW,Plprev,Prprev,solverdata)
  if newW === nothing || newW
    Pl = ilu(convert(AbstractMatrix,W), τ = 50.0)
  else
    Pl = Plprev
  end
  Pl,nothing
end
Base.eltype(::IncompleteLU.ILUFactorization{Tv,Ti}) where {Tv,Ti} = Tv

@time solve(prob_ode_brusselator_2d_sparse,KenCarp47(linsolve=KrylovJL_GMRES(),precs=incompletelu,concrete_jac=true),save_everystep=false);

using AlgebraicMultigrid
function algebraicmultigrid(W,du,u,p,t,newW,Plprev,Prprev,solverdata)
  if newW === nothing || newW
    Pl = aspreconditioner(ruge_stuben(convert(AbstractMatrix,W)))
  else
    Pl = Plprev
  end
  Pl,nothing
end
Base.eltype(::AlgebraicMultigrid.Preconditioner) = Float64

@btime solve(prob_ode_brusselator_2d_sparse,KenCarp47(linsolve=KrylovJL_GMRES(),precs=algebraicmultigrid,concrete_jac=true),save_everystep=false);

function algebraicmultigrid2(W,du,u,p,t,newW,Plprev,Prprev,solverdata)
  if newW === nothing || newW
    A = convert(AbstractMatrix,W)
    Pl = AlgebraicMultigrid.aspreconditioner(AlgebraicMultigrid.ruge_stuben(A, presmoother = AlgebraicMultigrid.Jacobi(rand(size(A,1))), postsmoother = AlgebraicMultigrid.Jacobi(rand(size(A,1)))))
  else
    Pl = Plprev
  end
  Pl,nothing
end

@btime solve(prob_ode_brusselator_2d_sparse,KenCarp47(linsolve=KrylovJL_GMRES(),precs=algebraicmultigrid2,concrete_jac=true),save_everystep=false);

#=
using Sundials
@btime solve(prob_ode_brusselator_2d,CVODE_BDF(),save_everystep=false)
@btime solve(prob_ode_brusselator_2d,CVODE_BDF(linear_solver=:LapackDense),save_everystep=false)
@btime solve(prob_ode_brusselator_2d,CVODE_BDF(linear_solver=:GMRES),save_everystep=false)

using ModelingToolkit
prob_ode_brusselator_2d_mtk = ODEProblem(modelingtoolkitize(prob_ode_brusselator_2d_sparse),[],(0.0,11.5),jac=true,sparse=true);
@btime solve(prob_ode_brusselator_2d_mtk,CVODE_BDF(linear_solver=:KLU),save_everystep=false)

using LinearAlgebra
u0 = prob_ode_brusselator_2d_mtk.u0
p  = prob_ode_brusselator_2d_mtk.p
const jaccache = prob_ode_brusselator_2d_mtk.f.jac(u0,p,0.0)
const W = I - 1.0*jaccache

prectmp = ilu(W, τ = 50.0)
const preccache = Ref(prectmp)

function psetupilu(p, t, u, du, jok, jcurPtr, gamma)
  if jok
    prob_ode_brusselator_2d_mtk.f.jac(jaccache,u,p,t)
    jcurPtr[] = true

    # W = I - gamma*J
    @. W = -gamma*jaccache
    idxs = diagind(W)
    @. @view(W[idxs]) = @view(W[idxs]) + 1

    # Build preconditioner on W
    preccache[] = ilu(W, τ = 5.0)
  end
end

function precilu(z,r,p,t,y,fy,gamma,delta,lr)
  ldiv!(z,preccache[],r)
end
@btime solve(prob_ode_brusselator_2d_sparse,CVODE_BDF(linear_solver=:GMRES,prec=precilu,psetup=psetupilu,prec_side=1),save_everystep=false);

prectmp2 = aspreconditioner(ruge_stuben(W, presmoother = AlgebraicMultigrid.Jacobi(rand(size(W,1))), postsmoother = AlgebraicMultigrid.Jacobi(rand(size(W,1)))))
const preccache2 = Ref(prectmp2)
function psetupamg(p, t, u, du, jok, jcurPtr, gamma)
  if jok
    prob_ode_brusselator_2d_mtk.f.jac(jaccache,u,p,t)
    jcurPtr[] = true

    # W = I - gamma*J
    @. W = -gamma*jaccache
    idxs = diagind(W)
    @. @view(W[idxs]) = @view(W[idxs]) + 1

    # Build preconditioner on W
    preccache2[] = aspreconditioner(ruge_stuben(W, presmoother = AlgebraicMultigrid.Jacobi(rand(size(W,1))), postsmoother = AlgebraicMultigrid.Jacobi(rand(size(W,1)))))
  end
end

function precamg(z,r,p,t,y,fy,gamma,delta,lr)
  ldiv!(z,preccache2[],r)
end

@btime solve(prob_ode_brusselator_2d_sparse,CVODE_BDF(linear_solver=:GMRES,prec=precamg,psetup=psetupamg,prec_side=1),save_everystep=false);

=#


text:
using SymPy

x, y, t = @vars x y t
T = x * (1-x) * y * (1-y)
K = 1 + x^2 + x / (1+y^2)
# K = 1.0
u = x * (1-x)* y * (1-y)
v = x * (1-x) * y * (1-y)
p = x * (1-x) * y * (1-y)
Tx = diff(T, x)
Ty = diff(T, y)
k_laplace_T = diff(K * Tx, x) + diff(K * Ty, y)
adv = u * Tx + v * Ty
Q = adv - k_laplace_T
s = sympy.julia_code(simplify(Q))
s = replace(replace(replace(s, ".*"=>"*"), ".^"=>"^"), "./"=>"/")

ffunc = u * diff(u, x) + v * diff(u, y) + diff(p, x) - 0.01 * (diff(diff(u, x), x) + diff(diff(u, y), y))
gfunc = u * diff(v, x) + v * diff(v, y) + diff(p, y) - 0.01 * (diff(diff(v, x), x) + diff(diff(v, y), y))
f = replace(replace(replace(sympy.julia_code(ffunc), ".*"=>"*"), ".^"=>"^"), "./"=>"/")
g = replace(replace(replace(sympy.julia_code(gfunc), ".*"=>"*"), ".^"=>"^"), "./"=>"/")

div_term = diff(u, x) + diff(v, y)
div_term = replace(replace(replace(sympy.julia_code(div_term), ".*"=>"*"), ".^"=>"^"), "./"=>"/")


text:
export getAnalytic3DeikonalSolution,selfMultiplyWithAnalyticSolution3D,analyticLocal3D,T03D,getAnalytic3DeikonalSolutionAll

function getAnalytic3DeikonalSolution(n::Array{Int64,1},h::Array{Float64,1},src::Array{Int64,1})
T = zeros(n[1],n[2],n[3]);

for k = 1:n[3]
	for j = 1:n[2]
		for i = 1:n[1]
			T[i,j,k] = T03D(n,h,src,i,j,k);
		end
	end
end
return T,0.0;
end

function selfMultiplyWithAnalyticSolution3D(n::Array{Int64,1},h::Array{Float64,1},src::Array{Int64,1},T::Union{Array{Float32,3},Array{Float64,3}})
for k = 1:n[3]
	for j = 1:n[2]
		for i = 1:n[1]
			T[i,j,k] *= T03D(n,h,src,i,j,k);
		end
	end
end
return;
end

function selfMultiplyWithAnalyticSolution3D(n::Array{Int64,1},h::Array{Float64,1},src::Array{Int64,1},T::Union{Array{Float32,1},Array{Float64,1}})
loc = zeros(Int64,3);
for k=1:length(T)
	cs2loc3D(loc,k,n);
	T[k] *= T03D(n,h,src,loc[1],loc[2],loc[3]);
end
return;
end

function T03D(n::Array{Int64,1},h::Array{Float64,1},src::Array{Int64,1},loc1::Int64,loc2::Int64,loc3::Int64)
return sqrt(((loc1 - src[1])*h[1])^2 + ((loc2 - src[2])*h[2])^2 + ((loc3 - src[3])*h[3])^2);
end

function analyticLocal3D(h::Array{Float64,1},src::Array{Int64,1},loc1::Int64,loc2::Int64,loc3::Int64)
G01loc = (loc1 - src[1])*h[1];
G02loc = (loc2 - src[2])*h[2];
G03loc = (loc3 - src[3])*h[3];

T0loc = sqrt(G01loc*G01loc + G02loc*G02loc + G03loc*G03loc);
invt0 = 1/T0loc;
G01loc *= invt0;
G02loc *= invt0;
G03loc *= invt0;
return T0loc,G01loc,G02loc,G03loc
end

function analyticLocal3D(h::Array{Float64,1},src::Array{Int64,1},loc1::Int64,loc2::Int64,loc3::Int64,GradAns::Array{Float64,1})
G01loc = (loc1 - src[1])*h[1];
G02loc = (loc2 - src[2])*h[2];
G03loc = (loc3 - src[3])*h[3];

T0loc = sqrt(G01loc*G01loc + G02loc*G02loc + G03loc*G03loc);
invt0 = 1/T0loc;
G01loc *= invt0;
G02loc *= invt0;
G03loc *= invt0;
GradAns[1] = G01loc;
GradAns[2] = G02loc;
GradAns[3] = G03loc;
return T0loc
end

function getAnalytic3DeikonalSolutionAll(n::Array{Int64,1},h::Array{Float64,1},src::Array{Int64,1})

source1 = (src[1]-1)*h[1];
source2 = (src[2]-1)*h[2];
source3 = (src[3]-1)*h[3];

X1,X2,X3 = ndgrid((0:(n[1]-1))*h[1] - source1,(0:(n[2]-1))*h[2] - source2,(0:(n[3]-1))*h[3] - source3);

r = sqrt.(X1.^2 + X2.^2 + X3.^2);
T = r;
L = 1./r;
G2 = X2.*L;
G2[src[1],src[2],src[3]] = 1/sqrt(3);

G1 = X1.*L;
G1[src[1],src[2],src[3]] = 1/sqrt(3);

G3 = X3.*L;
G3[src[1],src[2],src[3]] = 1/sqrt(3);

L[src[1],src[2],src[3]] = getL0AtSrc3D(h);

return T,G1,G2,G3,L;
end

function getL0AtSrc3D(h)
# finite_vol_integral_for_inverse_r_over_cube
# Solving the 3D integral for the source of the laplacian:

# L(src) = (1/vol)*int_{-h1/2<x1<h1/2,-h2/2<x2<h2/2,-h3/2<x3<h3/2}{1/sqrt(x^2 + y^2 + z^2)}
# vol = h1*h2*h3;
# Now we reduce one dimension from the integration and use 2D numerical mid-point integration.
# from quickmath: int_{-h/2<x<h/2}(1/sqrt(x^2 + y^2)) = 2*asinh(h/(2*abs(y)));

# Therefore: we reduce the first coordinate since we expect the third one to be the smallest

###########################################################################
# tic()
# n_num = 100;
# x1_num = -h[1]/2+h[1]/(2*n_num):h[1]/n_num:h[1]/2-h[1]/(2*n_num);
# x2_num = -h[2]/2+h[2]/(2*n_num):h[2]/n_num:h[2]/2-h[2]/(2*n_num);
# x3_num = -h[3]/2+h[3]/(2*n_num):h[3]/n_num:h[3]/2-h[3]/(2*n_num);

# X1sq,X2sq,X3sq = ndgrid(x1_num.^2,x2_num.^2,x3_num.^2);
# F = 0.0;
# for ii = 1:n_num
	# for jj = 1:n_num
		# for kk = 1:n_num
			# F += 1/sqrt(X1sq[ii,jj,kk]+X2sq[ii,jj,kk]+X3sq[ii,jj,kk]);
		# end
	# end
# end
# size_numerical_box = (h[1]*h[2]*h[3])/(n_num*n_num*n_num)
# F *= size_numerical_box;

# F *= (1/prod(h)); # finite volume definition for the cell.
# println(F)
# toc()
###################################################################
# n_num = 200;
# x2_num = -h[2]/2+h[2]/(2*n_num):h[2]/n_num:h[2]/2-h[2]/(2*n_num);
# x3_num = -h[3]/2+h[3]/(2*n_num):h[3]/n_num:h[3]/2-h[3]/(2*n_num);

# X2sq,X3sq = ndgrid(x2_num.^2,x3_num.^2);
# F = 0.0;
# for ii = 1:n_num
	# for jj = 1:n_num
		# F += 2*asinh((h[1])./(2*sqrt(X2sq[ii,jj] + X3sq[ii,jj])));
	# end
# end
# size_numerical_box = (h[2]*h[3])/(n_num*n_num)
# F *= size_numerical_box;
# F *= (1/prod(h)); # finite volume definition for the cell.
# println(F);

n_num = 200;
x2_num = -h[2]/2+h[2]/(2*n_num):h[2]/n_num:h[2]/2-h[2]/(2*n_num);
x3_num = -h[3]/2+h[3]/(2*n_num):h[3]/n_num:h[3]/2-h[3]/(2*n_num);

X2sq,X3sq = ndgrid(x2_num.^2,x3_num.^2);
F = 2.0*sum(asinh.((0.5*h[1])./sqrt.(X2sq+X3sq)));
# F = 0.0;
# for ii = 1:n_num
	# for jj = 1:n_num
		# F += 2*asinh((h[1])./(2*sqrt(X2sq[ii,jj] + X3sq[ii,jj])));
	# end
# end
size_numerical_box = (h[2]*h[3])/(n_num*n_num)
F *= size_numerical_box;
F *= 3*(1/prod(h)); # finite volume definition for the cell.
# println(F)

# F =  (2*h[1]*h[2] + 2*h[2]*h[3] + 2*h[1]*h[3])/(h[1]*h[2]*h[3]);
return F;

end


text:
using ThreeBodyDecay

tbs = let m1 = 0.938, m2 = 0.49367, m3 = 0.13957, m0 = 2.46867
    ThreeBodySystem(m1,m2,m3, m0=m0)
end

using Plots

let
    σ1v = LinRange(tbs.mthsq[1], tbs.sthsq[1],300)
    σ3m = [σ3of1(-1.0,σ,tbs.msq) for σ in σ1v]
    σ3p = [σ3of1( 1.0,σ,tbs.msq) for σ in σ1v]
    plot(σ1v, [σ3m σ3p], lab="")
end

let
    σ3v, σ1v = flatDalitzPlotSample31(tbs; Nev=1000000)
    histogram2d(σ1v, σ3v, lab="", bins=100)
end

max_stars_repo_name: mmikhasenko/ThreeBodyDecay

max_issues_repo_name: mmikhasenko/ThreeBodyDecay

max_forks_repo_name: mmikhasenko/ThreeBodyDecay