Logger now fully binary
This commit is contained in:
parent
16ea155d0d
commit
b42787cc1b
@ -2,4 +2,166 @@
|
|||||||
<Bucket
|
<Bucket
|
||||||
type = "1"
|
type = "1"
|
||||||
version = "2.0">
|
version = "2.0">
|
||||||
|
<Breakpoints>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "FileOperations.swift"
|
||||||
|
timestampString = "519600026.138018"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "25"
|
||||||
|
endingLineNumber = "25"
|
||||||
|
landmarkName = "FileOperations"
|
||||||
|
landmarkType = "3">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "FileOperations.swift"
|
||||||
|
timestampString = "519600026.138018"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "31"
|
||||||
|
endingLineNumber = "31"
|
||||||
|
landmarkName = "decodeTimestamp(stamp:)"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "FileOperations.swift"
|
||||||
|
timestampString = "519600026.138018"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "70"
|
||||||
|
endingLineNumber = "70"
|
||||||
|
landmarkName = "logUpstream(data:toFrequencyLog:)"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Logger4/FrequencyOperation.swift"
|
||||||
|
timestampString = "519600026.138018"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "241"
|
||||||
|
endingLineNumber = "241"
|
||||||
|
landmarkName = "logDummie(dir:element:date:)"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Logger4/FrequencyOperation.swift"
|
||||||
|
timestampString = "519592197.249339"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "71"
|
||||||
|
endingLineNumber = "71"
|
||||||
|
landmarkName = "handleData(date:)"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Logger4/FrequencyOperation.swift"
|
||||||
|
timestampString = "519600026.138018"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "223"
|
||||||
|
endingLineNumber = "223"
|
||||||
|
landmarkName = "handleData(date:)"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Logger4/FrequencyOperation.swift"
|
||||||
|
timestampString = "519600026.138018"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "243"
|
||||||
|
endingLineNumber = "243"
|
||||||
|
landmarkName = "logDummie(dir:element:date:)"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "Logger4/FrequencyOperation.swift"
|
||||||
|
timestampString = "519600026.138018"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "242"
|
||||||
|
endingLineNumber = "242"
|
||||||
|
landmarkName = "logDummie(dir:element:date:)"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "FileOperations.swift"
|
||||||
|
timestampString = "519600026.138018"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "26"
|
||||||
|
endingLineNumber = "26"
|
||||||
|
landmarkName = "decodeTimestamp(stamp:)"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
<BreakpointProxy
|
||||||
|
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
||||||
|
<BreakpointContent
|
||||||
|
shouldBeEnabled = "No"
|
||||||
|
ignoreCount = "0"
|
||||||
|
continueAfterRunningActions = "No"
|
||||||
|
filePath = "FileOperations.swift"
|
||||||
|
timestampString = "519600088.321308"
|
||||||
|
startingColumnNumber = "9223372036854775807"
|
||||||
|
endingColumnNumber = "9223372036854775807"
|
||||||
|
startingLineNumber = "95"
|
||||||
|
endingLineNumber = "95"
|
||||||
|
landmarkName = "logDownstream(data:toFrequencyLog:)"
|
||||||
|
landmarkType = "7">
|
||||||
|
</BreakpointContent>
|
||||||
|
</BreakpointProxy>
|
||||||
|
</Breakpoints>
|
||||||
</Bucket>
|
</Bucket>
|
||||||
|
|||||||
@ -10,13 +10,33 @@ import Cocoa
|
|||||||
|
|
||||||
class FileOperations: NSObject {
|
class FileOperations: NSObject {
|
||||||
|
|
||||||
|
// MARK: - Timestamp related
|
||||||
|
// 15 in threshold indicates some error
|
||||||
|
|
||||||
|
static func encodeTimeStamp(stamp: String, threshold: String) -> UInt32 {
|
||||||
|
let mappingEncode: Dictionary<String, UInt32> = ["-" : 0, "62.81": 1, "58.21": 2, "57": 3, "59.81": 4, "55.21": 5, "54": 6, "56.81": 7, "52.21": 8, "51": 9]
|
||||||
|
let separated: Array<String> = stamp.components(separatedBy: ":")
|
||||||
|
let hours: UInt32 = UInt32(separated[0])! << 16
|
||||||
|
let minutes: UInt32 = UInt32(separated[1])! << 10
|
||||||
|
let seconds: UInt32 = UInt32(separated[2])! << 4
|
||||||
|
let thresholdI: UInt32 = mappingEncode[threshold] ?? 15
|
||||||
|
return hours | seconds | minutes | thresholdI
|
||||||
|
}
|
||||||
|
|
||||||
|
static func decodeTimestamp(stamp: UInt32) -> (String, String) {
|
||||||
|
let mappingDecode: Dictionary<UInt32, String> = [0: "-", 1: "62.81", 2: "58.21", 3: "57", 4: "59.81", 5: "55.21", 6: "54", 7: "56.81", 8: "52.21", 9: "51"]
|
||||||
|
let threshold: UInt32 = stamp & 0b1111
|
||||||
|
let seconds: UInt32 = (stamp >> 4) & 0b111111
|
||||||
|
let minutes: UInt32 = (stamp >> 10) & 0b111111
|
||||||
|
let hours: UInt32 = (stamp >> 16) & 0b11111
|
||||||
|
return ("\(hours):\(minutes):\(seconds)", mappingDecode[threshold] ?? "\(15)")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Loss log related
|
||||||
|
|
||||||
static func log(data: String, toLog path: String) {
|
static func log(data: String, toLog path: String) {
|
||||||
let seperated: Array<String> = data.components(separatedBy: ":")
|
let dataToWrite = encodeTimeStamp(stamp: data, threshold: "")
|
||||||
let hours: UInt32 = UInt32(seperated[0])!
|
|
||||||
let minutes: UInt32 = UInt32(seperated[1])!
|
|
||||||
let seconds: UInt32 = UInt32(seperated[2])!
|
|
||||||
var dataToWrite: UInt32 = 0
|
|
||||||
dataToWrite = ((((dataToWrite | hours) << 6) | minutes) << 8) | seconds
|
|
||||||
let file: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 3, alignedTo: 1)
|
let file: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 3, alignedTo: 1)
|
||||||
file.storeBytes(of: dataToWrite, as: UInt32.self)
|
file.storeBytes(of: dataToWrite, as: UInt32.self)
|
||||||
do {
|
do {
|
||||||
@ -36,11 +56,7 @@ class FileOperations: NSObject {
|
|||||||
while i < Data.length - 3 {
|
while i < Data.length - 3 {
|
||||||
let data: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 3, alignedTo: 1)
|
let data: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 3, alignedTo: 1)
|
||||||
Data.getBytes(data, range: NSRange(location: i, length: 3))
|
Data.getBytes(data, range: NSRange(location: i, length: 3))
|
||||||
let compound: UInt32 = data.load(as: UInt32.self)
|
returnString?.append("\(decodeTimestamp(stamp: data.load(as: UInt32.self)).0)\n")
|
||||||
let seconds: UInt32 = (compound) & 0b111111
|
|
||||||
let minutes: UInt32 = (compound >> 8) & 0b111111
|
|
||||||
let hours: UInt32 = (compound >> 14) & 0b11111
|
|
||||||
returnString?.append("\(hours):\(minutes):\(seconds)\n")
|
|
||||||
i += 3
|
i += 3
|
||||||
}
|
}
|
||||||
if returnString != "" {
|
if returnString != "" {
|
||||||
@ -48,4 +64,57 @@ class FileOperations: NSObject {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Frequency logging (encoding)
|
||||||
|
|
||||||
|
static func logUpstream(data: String, toFrequencyLog path: String) {
|
||||||
|
let separated: Array<String> = data.components(separatedBy: ";")
|
||||||
|
var encodedTime: UInt32 = encodeTimeStamp(stamp: separated[0], threshold: separated[2])
|
||||||
|
// NaN Used for -
|
||||||
|
var encodedPower: Int32 = Int32.min
|
||||||
|
if (Double(separated[1]) != nil) {
|
||||||
|
encodedPower = Int32(Double(Double(separated[1])! * 100.0))
|
||||||
|
}
|
||||||
|
var stringSize: UInt8 = UInt8(separated[3].lengthOfBytes(using: .ascii))
|
||||||
|
|
||||||
|
let fileContent: NSMutableData = NSMutableData()
|
||||||
|
fileContent.append(&stringSize, length: 1)
|
||||||
|
fileContent.append(&encodedTime, length: 3)
|
||||||
|
fileContent.append(&encodedPower, length: 4)
|
||||||
|
fileContent.append(separated[3].data(using: .ascii)!)
|
||||||
|
|
||||||
|
do {
|
||||||
|
let fileData: NSMutableData = try NSMutableData(contentsOf: URL(fileURLWithPath: path))
|
||||||
|
fileData.append(fileContent as Data)
|
||||||
|
fileData.write(to: URL(fileURLWithPath: path), atomically: true)
|
||||||
|
} catch _ {
|
||||||
|
fileContent.write(to: URL(fileURLWithPath: path), atomically: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func logDownstream(data: String, toFrequencyLog path: String) {
|
||||||
|
let separated: Array<String> = data.components(separatedBy: ";")
|
||||||
|
var encodedTime: UInt32 = encodeTimeStamp(stamp: separated[0], threshold: "")
|
||||||
|
// NaN Used for -
|
||||||
|
var encodedPower: Int32 = Int32.min
|
||||||
|
if (Double(separated[1]) != nil) {
|
||||||
|
encodedPower = Int32(Double(Double(separated[1])! * 100.0))
|
||||||
|
}
|
||||||
|
var encodedSNR = UInt8(separated[2]) ?? UInt8.max
|
||||||
|
|
||||||
|
let fileContent: NSMutableData = NSMutableData()
|
||||||
|
fileContent.append(&encodedTime, length: 3)
|
||||||
|
fileContent.append(&encodedPower, length: 4)
|
||||||
|
fileContent.append(&encodedSNR, length: 1)
|
||||||
|
|
||||||
|
do {
|
||||||
|
let fileData: NSMutableData = try NSMutableData(contentsOf: URL(fileURLWithPath: path))
|
||||||
|
fileData.append(fileContent as Data)
|
||||||
|
fileData.write(to: URL(fileURLWithPath: path), atomically: true)
|
||||||
|
} catch _ {
|
||||||
|
fileContent.write(to: URL(fileURLWithPath: path), atomically: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Frequency loading (decoding)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,9 +42,9 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>2.0</string>
|
<string>2.1</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>417</string>
|
<string>418</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.utilities</string>
|
<string>public.app-category.utilities</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
version 2.0
|
version 2.1
|
||||||
build 417
|
build 418
|
||||||
|
|||||||
@ -125,18 +125,18 @@ class FrequencyOperation: Operation {
|
|||||||
entry += "NaN"
|
entry += "NaN"
|
||||||
}
|
}
|
||||||
// Add ranging status
|
// Add ranging status
|
||||||
entry += ";\(channel["ranging_status"] as! String)\n"
|
entry += ";\(channel["ranging_status"] as! String)"
|
||||||
// Add file name to path
|
// Add file name to path
|
||||||
file = dir.appending("Upstream \(channel["frequency"]!).csv") as NSString
|
file = dir.appending("Upstream \(channel["frequency"]!).hex") as NSString
|
||||||
// Track modification
|
// Track modification
|
||||||
filesModified.append("Upstream \(channel["frequency"]!).csv")
|
filesModified.append("Upstream \(channel["frequency"]!).hex")
|
||||||
// Write to file
|
// Write to file
|
||||||
logFreq(header: ";Power Level;Threshold;Ranging Status\n", file: file, entry: entry)
|
FileOperations.logUpstream(data: entry, toFrequencyLog: file.expandingTildeInPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We have a single channel
|
// We have a single channel
|
||||||
else if channels is Dictionary<String,AnyObject> {
|
else if channels is Dictionary<String,AnyObject> {
|
||||||
// Grab channel
|
// Grab channel
|
||||||
let channel: Dictionary<String,AnyObject> = channels as! Dictionary<String,AnyObject>
|
let channel: Dictionary<String,AnyObject> = channels as! Dictionary<String,AnyObject>
|
||||||
@ -157,13 +157,13 @@ class FrequencyOperation: Operation {
|
|||||||
}
|
}
|
||||||
let adjustInt: Double = Double(adjust)!
|
let adjustInt: Double = Double(adjust)!
|
||||||
// Add data to entry
|
// Add data to entry
|
||||||
entry = "\((NSApp.delegate as! AppDelegate).justTime.string(from: date));\(String(powerInt! + adjustInt));\(upstreamOne[modulationAdjust.allKeys(for: adjust)[0] as! String]!);\(channel["ranging_status"] as! String)\n"
|
entry = "\((NSApp.delegate as! AppDelegate).justTime.string(from: date));\(String(powerInt! + adjustInt));\(upstreamOne[modulationAdjust.allKeys(for: adjust)[0] as! String]!);\(channel["ranging_status"] as! String)"
|
||||||
// Add file name to path
|
// Add file name to path
|
||||||
file = dir.appending("Upstream \(channel["frequency"]!).csv") as NSString
|
file = dir.appending("Upstream \(channel["frequency"]!).hex") as NSString
|
||||||
// Track modifiction
|
// Track modifiction
|
||||||
filesModified.append("Upstream \(channel["frequency"]!).csv")
|
filesModified.append("Upstream \(channel["frequency"]!).hex")
|
||||||
// Write to file
|
// Write to file
|
||||||
logFreq(header: ";Power Level;Threshold;Ranging Status\n", file: file, entry: entry)
|
FileOperations.logUpstream(data: entry, toFrequencyLog: file.expandingTildeInPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,17 +185,17 @@ class FrequencyOperation: Operation {
|
|||||||
// We do not have an error
|
// We do not have an error
|
||||||
if channel["frequency"] as! String != "status_error" {
|
if channel["frequency"] as! String != "status_error" {
|
||||||
// Add data to entry
|
// Add data to entry
|
||||||
entry = "\((NSApp.delegate as! AppDelegate).justTime.string(from: date));\(channel["power_level"]!);\(channel["snr"]!)\n"
|
entry = "\((NSApp.delegate as! AppDelegate).justTime.string(from: date));\(channel["power_level"]!);\(channel["snr"]!)"
|
||||||
// Add file name to path
|
// Add file name to path
|
||||||
file = dir.appending("Downstream \(channel["frequency"]!).csv") as NSString
|
file = dir.appending("Downstream \(channel["frequency"]!).hex") as NSString
|
||||||
// Tracking modification
|
// Tracking modification
|
||||||
filesModified.append("Downstream \(channel["frequency"]!).csv")
|
filesModified.append("Downstream \(channel["frequency"]!).hex")
|
||||||
// Write to file
|
// Write to file
|
||||||
logFreq(header: ";Power;SNR\n", file: file, entry: entry)
|
FileOperations.logDownstream(data: entry, toFrequencyLog: file.expandingTildeInPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We have a single channel
|
// We have a single channel
|
||||||
else if channels is Dictionary<String,AnyObject> {
|
else if channels is Dictionary<String,AnyObject> {
|
||||||
// Grab channel
|
// Grab channel
|
||||||
let channel: Dictionary<String,AnyObject> = channels as! Dictionary<String,AnyObject>
|
let channel: Dictionary<String,AnyObject> = channels as! Dictionary<String,AnyObject>
|
||||||
@ -204,72 +204,46 @@ class FrequencyOperation: Operation {
|
|||||||
// Add data to entry
|
// Add data to entry
|
||||||
entry = "\((NSApp.delegate as! AppDelegate).justTime.string(from: date));\(channel["power_level"]!);\(channel["snr"]!)\n"
|
entry = "\((NSApp.delegate as! AppDelegate).justTime.string(from: date));\(channel["power_level"]!);\(channel["snr"]!)\n"
|
||||||
// Add file name to path
|
// Add file name to path
|
||||||
file = dir.appending("Downstream \(channel["frequency"]!).csv") as NSString
|
file = dir.appending("Downstream \(channel["frequency"]!).hex") as NSString
|
||||||
// Tracking modification
|
// Tracking modification
|
||||||
filesModified.append("Downstream \(channel["frequency"]!).csv")
|
filesModified.append("Downstream \(channel["frequency"]!).hex")
|
||||||
// Write to file
|
// Write to file
|
||||||
logFreq(header: ";Power;SNR\n", file: file, entry: entry)
|
FileOperations.logDownstream(data: entry, toFrequencyLog: file.expandingTildeInPath)
|
||||||
}
|
|
||||||
}
|
|
||||||
// Update if not modified
|
|
||||||
let fileManager = FileManager.default
|
|
||||||
// Get all filenames in directory
|
|
||||||
let enumerator:FileManager.DirectoryEnumerator = fileManager.enumerator(atPath: dir.expandingTildeInPath)!
|
|
||||||
// Step through files
|
|
||||||
for element in enumerator {
|
|
||||||
// Check if modified
|
|
||||||
if !filesModified.contains(element as! String) && (element as! String).contains(".csv") {
|
|
||||||
logDummie(dir: dir, element: element as! String, date: date)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Update if both nil (no connection to modem possible)
|
// Update if not modified
|
||||||
else if (upstreamBool && downstreamBool) {
|
let fileManager = FileManager.default
|
||||||
upstreamBool = false
|
// Get all filenames in directory
|
||||||
downstreamBool = false
|
let enumerator:FileManager.DirectoryEnumerator = fileManager.enumerator(atPath: dir.expandingTildeInPath)!
|
||||||
let fileManager = FileManager.default
|
// Step through files
|
||||||
// Get all filenames in directory
|
for element in enumerator {
|
||||||
let enumerator:FileManager.DirectoryEnumerator = fileManager.enumerator(atPath: dir.expandingTildeInPath)!
|
// Check if modified
|
||||||
// Step through files
|
if !filesModified.contains(element as! String) && (element as! String).contains(".hex") {
|
||||||
for element in enumerator {
|
|
||||||
logDummie(dir: dir, element: element as! String, date: date)
|
logDummie(dir: dir, element: element as! String, date: date)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// Update if both nil (no connection to modem possible)
|
||||||
|
else if (upstreamBool && downstreamBool) {
|
||||||
func logFreq(header: String, file: NSString, entry: String) {
|
upstreamBool = false
|
||||||
let fileManager = FileManager.default
|
downstreamBool = false
|
||||||
if !fileManager.fileExists(atPath: file.expandingTildeInPath) {
|
let fileManager = FileManager.default
|
||||||
do {
|
// Get all filenames in directory
|
||||||
try header.write(toFile: file.expandingTildeInPath, atomically: true, encoding: .utf8)
|
let enumerator:FileManager.DirectoryEnumerator = fileManager.enumerator(atPath: dir.expandingTildeInPath)!
|
||||||
}
|
// Step through files
|
||||||
catch {
|
for element in enumerator {
|
||||||
NSLog("WRITE TO FILE \(file.expandingTildeInPath) FAILED\n");
|
logDummie(dir: dir, element: element as! String, date: date)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let fileH: FileHandle? = FileHandle(forUpdatingAtPath: file.expandingTildeInPath)
|
|
||||||
fileH?.seekToEndOfFile()
|
|
||||||
let data: Data = (entry as NSString).data(using: String.Encoding.utf8.rawValue)!
|
|
||||||
fileH?.write(data)
|
|
||||||
fileH?.closeFile()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func logDummie(dir: NSString, element: String, date: Date) {
|
func logDummie(dir: NSString, element: String, date: Date) {
|
||||||
// Get file
|
if element.contains("Upstream") {
|
||||||
let file: FileHandle? = FileHandle(forUpdatingAtPath: dir.expandingTildeInPath.appending(element))
|
FileOperations.logUpstream(data: "\((NSApp.delegate as! AppDelegate).justTime.string(from: date));-;-;-", toFrequencyLog: (dir.appending(element) as NSString).expandingTildeInPath)
|
||||||
if file != nil {
|
} else {
|
||||||
// Write appropriate null entry to file
|
FileOperations.logDownstream(data: "\((NSApp.delegate as! AppDelegate).justTime.string(from: date));-;-",
|
||||||
file?.seekToEndOfFile();
|
toFrequencyLog: (dir.appending(element) as NSString).expandingTildeInPath)
|
||||||
var data: Data?;
|
|
||||||
if element.contains("Upstream") {
|
|
||||||
data = ("\((NSApp.delegate as! AppDelegate).justTime.string(from: date));-;-;-\n" as NSString).data(using: String.Encoding.utf8.rawValue)
|
|
||||||
} else {
|
|
||||||
data = ("\((NSApp.delegate as! AppDelegate).justTime.string(from: date));-;-\n" as NSString).data(using: String.Encoding.utf8.rawValue)
|
|
||||||
}
|
|
||||||
file?.write(data!)
|
|
||||||
file?.closeFile()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,9 +15,9 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>4.0</string>
|
<string>4.1</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>39</string>
|
<string>47</string>
|
||||||
<key>LSApplicationCategoryType</key>
|
<key>LSApplicationCategoryType</key>
|
||||||
<string>public.app-category.utilities</string>
|
<string>public.app-category.utilities</string>
|
||||||
<key>LSMinimumSystemVersion</key>
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
|||||||
@ -1,2 +1,2 @@
|
|||||||
version 4.0
|
version 4.1
|
||||||
build 39
|
build 47
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user