Up and downstream loading implemented
This commit is contained in:
parent
406f681962
commit
ef111ee997
@ -2,22 +2,4 @@
|
|||||||
<Bucket
|
<Bucket
|
||||||
type = "1"
|
type = "1"
|
||||||
version = "2.0">
|
version = "2.0">
|
||||||
<Breakpoints>
|
|
||||||
<BreakpointProxy
|
|
||||||
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
|
|
||||||
<BreakpointContent
|
|
||||||
shouldBeEnabled = "Yes"
|
|
||||||
ignoreCount = "0"
|
|
||||||
continueAfterRunningActions = "No"
|
|
||||||
filePath = "FileOperations.swift"
|
|
||||||
timestampString = "519640153.333545"
|
|
||||||
startingColumnNumber = "9223372036854775807"
|
|
||||||
endingColumnNumber = "9223372036854775807"
|
|
||||||
startingLineNumber = "38"
|
|
||||||
endingLineNumber = "38"
|
|
||||||
landmarkName = "log(data:toLog:)"
|
|
||||||
landmarkType = "7">
|
|
||||||
</BreakpointContent>
|
|
||||||
</BreakpointProxy>
|
|
||||||
</Breakpoints>
|
|
||||||
</Bucket>
|
</Bucket>
|
||||||
|
|||||||
@ -39,6 +39,7 @@ class FileOperations: NSObject {
|
|||||||
let dataToWrite = encodeTimeStamp(stamp: data, threshold: "")
|
let dataToWrite = encodeTimeStamp(stamp: data, threshold: "")
|
||||||
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)
|
||||||
|
file.deallocate(bytes: 3, alignedTo: 1)
|
||||||
do {
|
do {
|
||||||
let fileData: NSMutableData = try NSMutableData(contentsOf: URL(fileURLWithPath: path))
|
let fileData: NSMutableData = try NSMutableData(contentsOf: URL(fileURLWithPath: path))
|
||||||
fileData.append(file, length: 3)
|
fileData.append(file, length: 3)
|
||||||
@ -50,16 +51,17 @@ class FileOperations: NSObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static func load(log Data: NSData) -> String? {
|
static func load(log Data: NSData) -> [String]? {
|
||||||
var returnString: String? = ""
|
var returnString: [String] = []
|
||||||
var i: Int = 0
|
var i: Int = 0
|
||||||
while i < Data.length - 3 {
|
while i < Data.length {
|
||||||
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))
|
||||||
returnString?.append("\(decodeTimestamp(stamp: data.load(as: UInt32.self)).0)\n")
|
returnString.append("\(decodeTimestamp(stamp: data.load(as: UInt32.self)).0)\n")
|
||||||
|
data.deallocate(bytes: 3, alignedTo: 1)
|
||||||
i += 3
|
i += 3
|
||||||
}
|
}
|
||||||
if returnString != "" {
|
if returnString.count > 0 {
|
||||||
return returnString
|
return returnString
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -117,4 +119,115 @@ class FileOperations: NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Frequency loading (decoding)
|
// MARK: - Frequency loading (decoding)
|
||||||
|
|
||||||
|
static func loadUpstream(log data: NSData) -> [String]? {
|
||||||
|
var variableAdjust: Int = 0
|
||||||
|
var returnString: [String] = []
|
||||||
|
|
||||||
|
while variableAdjust < data.length {
|
||||||
|
// 1 for size
|
||||||
|
// 3 for time and threshold
|
||||||
|
// 4 for Power
|
||||||
|
// var String
|
||||||
|
|
||||||
|
let decodedSize: UInt8 = data.bytes.load(fromByteOffset: variableAdjust, as: UInt8.self)
|
||||||
|
variableAdjust += 1
|
||||||
|
|
||||||
|
let retTimePtr: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 3, alignedTo: 1)
|
||||||
|
data.getBytes(retTimePtr, range: NSRange(location: variableAdjust, length: 3))
|
||||||
|
variableAdjust += 3
|
||||||
|
let encodedTime: UInt32 = retTimePtr.load(as: UInt32.self)
|
||||||
|
retTimePtr.deallocate(bytes: 3, alignedTo: 1)
|
||||||
|
|
||||||
|
let decodedTimeStamp = decodeTimestamp(stamp: encodedTime).0
|
||||||
|
let decodedThreshold = decodeTimestamp(stamp: encodedTime).1
|
||||||
|
|
||||||
|
let retPwrPtr: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 4, alignedTo: 1)
|
||||||
|
data.getBytes(retPwrPtr, range: NSRange(location: variableAdjust, length: 4))
|
||||||
|
var decodedPower: Any = retPwrPtr.load(as: Int32.self)
|
||||||
|
retPwrPtr.deallocate(bytes: 4, alignedTo: 1)
|
||||||
|
if decodedPower as! Int32 == Int32.min {
|
||||||
|
decodedPower = "-"
|
||||||
|
}
|
||||||
|
variableAdjust += 4
|
||||||
|
|
||||||
|
let retStringPtr: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: Int(decodedSize), alignedTo: 1)
|
||||||
|
data.getBytes(retStringPtr, range: NSRange(location: variableAdjust, length: Int(decodedSize)))
|
||||||
|
var retString: String = String(cString: retStringPtr.assumingMemoryBound(to: UInt8.self))
|
||||||
|
retStringPtr.deallocate(bytes: Int(decodedSize), alignedTo: 1)
|
||||||
|
retString = retString.substring(to: retString.index(retString.startIndex, offsetBy: Int(decodedSize)))
|
||||||
|
variableAdjust += Int(decodedSize)
|
||||||
|
|
||||||
|
guard decodedPower is Int32 else {
|
||||||
|
returnString.append("\(decodedTimeStamp);\(decodedPower as! String);\(decodedThreshold);\(retString)")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
returnString.append("\(decodedTimeStamp);\((Double(decodedPower as! Int32) / 100.0));\(decodedThreshold);\(retString)")
|
||||||
|
}
|
||||||
|
if returnString.count > 0 {
|
||||||
|
return returnString
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
static func loadDownstream(log data: NSData) -> [String]? {
|
||||||
|
var variableAdjust: Int = 0
|
||||||
|
var returnString: [String] = []
|
||||||
|
|
||||||
|
while variableAdjust < data.length {
|
||||||
|
// 3 for time
|
||||||
|
// 4 for Power
|
||||||
|
// 1 for SNR
|
||||||
|
|
||||||
|
let retTimePtr: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 3, alignedTo: 1)
|
||||||
|
data.getBytes(retTimePtr, range: NSRange(location: variableAdjust, length: 3))
|
||||||
|
variableAdjust += 3
|
||||||
|
let encodedTime: UInt32 = retTimePtr.load(as: UInt32.self)
|
||||||
|
|
||||||
|
let decodedTimeStamp = decodeTimestamp(stamp: encodedTime).0
|
||||||
|
|
||||||
|
let retPwrPtr: UnsafeMutableRawPointer = UnsafeMutableRawPointer.allocate(bytes: 4, alignedTo: 1)
|
||||||
|
data.getBytes(retPwrPtr, range: NSRange(location: variableAdjust, length: 4))
|
||||||
|
var decodedPower: Any = retPwrPtr.load(as: Int32.self)
|
||||||
|
retPwrPtr.deallocate(bytes: 4, alignedTo: 1)
|
||||||
|
if decodedPower as! Int32 == Int32.min {
|
||||||
|
decodedPower = "-"
|
||||||
|
}
|
||||||
|
variableAdjust += 4
|
||||||
|
|
||||||
|
var decodedSNR: Any = data.bytes.load(fromByteOffset: variableAdjust, as: UInt8.self)
|
||||||
|
if decodedSNR as! UInt8 == UInt8.max {
|
||||||
|
decodedSNR = "-"
|
||||||
|
}
|
||||||
|
variableAdjust += 1
|
||||||
|
|
||||||
|
var entry: String = ""
|
||||||
|
|
||||||
|
guard decodedPower is Int32 else {
|
||||||
|
entry.append("\(decodedTimeStamp);\(decodedPower as! String);")
|
||||||
|
guard decodedSNR is UInt8 else {
|
||||||
|
entry.append("\(decodedSNR as! String)")
|
||||||
|
returnString.append(entry)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
entry.append("\(decodedSNR as! UInt8)")
|
||||||
|
returnString.append(entry)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
entry.append("\(decodedTimeStamp);\((Double(decodedPower as! Int32) / 100.0));")
|
||||||
|
|
||||||
|
guard decodedSNR is UInt8 else {
|
||||||
|
entry.append("\(decodedSNR as! String)")
|
||||||
|
returnString.append(entry)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
entry.append("\(decodedSNR as! UInt8)")
|
||||||
|
|
||||||
|
returnString.append(entry)
|
||||||
|
}
|
||||||
|
if returnString.count > 0 {
|
||||||
|
return returnString
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||||
// Insert code here to initialize your application
|
// Insert code here to initialize your application
|
||||||
pthread_mutex_init(&((NSApp.delegate as! AppDelegate).lock), nil)
|
pthread_mutex_init(&((NSApp.delegate as! AppDelegate).lock), nil)
|
||||||
|
|
||||||
|
/* TESTBED
|
||||||
|
do {
|
||||||
|
let data: NSData = try NSData(contentsOfFile: "/Users/kili2/Desktop/2017.docsisplist2/06/20/Downstream 666000000.hex")
|
||||||
|
print(FileOperations.loadDownstream(log: data))
|
||||||
|
} catch _ {
|
||||||
|
exit(-1)
|
||||||
|
}
|
||||||
|
**/
|
||||||
}
|
}
|
||||||
|
|
||||||
func applicationWillTerminate(_ aNotification: Notification) {
|
func applicationWillTerminate(_ aNotification: Notification) {
|
||||||
|
|||||||
@ -87,7 +87,7 @@ extension CollectionViewMonth: NSCollectionViewDataSource {
|
|||||||
/*
|
/*
|
||||||
guard var logA = String(data: log.regularFileContents!, encoding: .utf8)?.components(separatedBy: "\n") else { return }
|
guard var logA = String(data: log.regularFileContents!, encoding: .utf8)?.components(separatedBy: "\n") else { return }
|
||||||
*/
|
*/
|
||||||
guard var logA = FileOperations.load(log: log.regularFileContents! as NSData)?.components(separatedBy: "\n") else { return }
|
guard var logA = FileOperations.load(log: log.regularFileContents! as NSData) else { return }
|
||||||
logA.removeLast()
|
logA.removeLast()
|
||||||
item2.distribution = logA
|
item2.distribution = logA
|
||||||
OperationQueue.main.addOperation {
|
OperationQueue.main.addOperation {
|
||||||
|
|||||||
@ -44,7 +44,7 @@
|
|||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>2.1</string>
|
<string>2.1</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>418</string>
|
<string>424</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.1
|
version 2.1
|
||||||
build 418
|
build 424
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user