Fixed critical bug in loss logging functions (pointer realloced to early)
Implemented Converter tool -> needs refactoring toward non document based
This commit is contained in:
@@ -92,7 +92,7 @@ class FrequencyGraph: NSView {
|
||||
}
|
||||
}
|
||||
|
||||
func initView() {
|
||||
func initView(operation: GraphLoadOperation) {
|
||||
// Setup Indicator
|
||||
// Zero line
|
||||
let zero: NSBezierPath = NSBezierPath()
|
||||
@@ -102,6 +102,9 @@ class FrequencyGraph: NSView {
|
||||
// Add data points
|
||||
var lastWasSkipped: Bool = false
|
||||
for point in 0..<data.count {
|
||||
if operation.isCancelled {
|
||||
return
|
||||
}
|
||||
// Get values
|
||||
let level: Double? = Double(data[point].components(separatedBy: ";")[1])
|
||||
let threshold: Double? = Double(data[point].components(separatedBy: ";")[2])
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// GraphLoadOperation.swift
|
||||
// Docsis Toolkit
|
||||
//
|
||||
// Created by Kilian Hofmann on 21.06.17.
|
||||
// Copyright © 2017 Kilian Hofmann. All rights reserved.
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
|
||||
class GraphLoadOperation: Operation {
|
||||
|
||||
var graph: FrequencyGraph!
|
||||
var item: FileWrapper!
|
||||
var downstream: Bool!
|
||||
|
||||
init(graph: FrequencyGraph, item: FileWrapper, downstream: Bool) {
|
||||
self.graph = graph
|
||||
self.item = item
|
||||
self.downstream = downstream
|
||||
}
|
||||
|
||||
override func main() {
|
||||
if isCancelled {
|
||||
return
|
||||
}
|
||||
if downstream {
|
||||
graph.data = FileOperations.loadDownstream(log: item.regularFileContents! as NSData)!
|
||||
} else {
|
||||
graph.data = FileOperations.loadUpstream(log: item.regularFileContents! as NSData)!
|
||||
}
|
||||
let keyString: String = item.filename!.components(separatedBy: " ")[1]
|
||||
graph.frequency = Double(keyString.substring(to: keyString.index(keyString.endIndex, offsetBy: -4)))! / 1000000
|
||||
graph.initView(operation: self)
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ class GraphWindow: NSWindowController {
|
||||
|
||||
var collectionViewItem: CollectionViewItemMonth!
|
||||
@IBOutlet var scrollView: NSScrollView!
|
||||
let opQueue: OperationQueue = OperationQueue()
|
||||
|
||||
override var windowNibName: String! {
|
||||
return "GraphWindow"
|
||||
@@ -24,6 +25,7 @@ class GraphWindow: NSWindowController {
|
||||
init(collectionViewItem: CollectionViewItemMonth) {
|
||||
super.init(window: nil)
|
||||
self.collectionViewItem = collectionViewItem
|
||||
opQueue.maxConcurrentOperationCount = 4
|
||||
}
|
||||
|
||||
override func windowDidLoad() {
|
||||
@@ -49,25 +51,13 @@ class GraphWindow: NSWindowController {
|
||||
for item in upstreamFiles {
|
||||
let graph: FrequencyGraph = FrequencyGraph(upstream: true, frame: NSMakeRect(0, CGFloat(numGraphs * FrequencyGraph.graphSizeWithSeparator), CGFloat(FrequencyGraph.maxGraphSize), CGFloat(FrequencyGraph.graphSize)), superview: content)
|
||||
graph.dataLoss = collectionViewItem.distribution
|
||||
graph.data = FileOperations.loadUpstream(log: item.regularFileContents! as NSData)!
|
||||
let keyString: String = item.filename!.components(separatedBy: " ")[1]
|
||||
graph.frequency = Double(keyString.substring(to: keyString.index(keyString.endIndex, offsetBy: -4)))! / 1000000
|
||||
let opQueue: OperationQueue = OperationQueue()
|
||||
opQueue.addOperation {
|
||||
graph.initView()
|
||||
}
|
||||
opQueue.addOperation(GraphLoadOperation(graph: graph, item: item, downstream: false))
|
||||
numGraphs += 1
|
||||
}
|
||||
for item in downstreamFiles {
|
||||
let graph: FrequencyGraph = FrequencyGraph(upstream: false, frame: NSMakeRect(0, CGFloat(numGraphs * FrequencyGraph.graphSizeWithSeparator), CGFloat(FrequencyGraph.maxGraphSize), CGFloat(FrequencyGraph.graphSize)), superview: content)
|
||||
graph.dataLoss = collectionViewItem.distribution
|
||||
graph.data = FileOperations.loadDownstream(log: item.regularFileContents! as NSData)!
|
||||
let keyString: String = item.filename!.components(separatedBy: " ")[1]
|
||||
graph.frequency = Double(keyString.substring(to: keyString.index(keyString.endIndex, offsetBy: -4)))! / 1000000
|
||||
let opQueue: OperationQueue = OperationQueue()
|
||||
opQueue.addOperation {
|
||||
graph.initView()
|
||||
}
|
||||
opQueue.addOperation(GraphLoadOperation(graph: graph, item: item, downstream: true))
|
||||
numGraphs += 1
|
||||
}
|
||||
}
|
||||
@@ -75,6 +65,7 @@ class GraphWindow: NSWindowController {
|
||||
|
||||
extension GraphWindow: NSWindowDelegate {
|
||||
func windowShouldClose(_ sender: Any) -> Bool {
|
||||
opQueue.cancelAllOperations()
|
||||
collectionViewItem?.isSelected = false
|
||||
collectionViewItem?.view.layer?.borderColor = NSColor.clear.cgColor
|
||||
return true
|
||||
|
||||
@@ -16,33 +16,33 @@
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" animationBehavior="default" id="F0z-JX-Cv5">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
|
||||
<windowPositionMask key="initialPositionMask" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="240" y="267" width="853" height="533"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="800"/>
|
||||
<view key="contentView" wantsLayer="YES" id="se5-gp-TjO">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="853" height="533"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<scrollView fixedFrame="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" translatesAutoresizingMaskIntoConstraints="NO" id="N7f-tq-7VU">
|
||||
<rect key="frame" x="20" y="20" width="440" height="251"/>
|
||||
<rect key="frame" x="20" y="20" width="813" height="493"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<clipView key="contentView" ambiguous="YES" id="cR7-yI-MsB">
|
||||
<rect key="frame" x="1" y="1" width="438" height="249"/>
|
||||
<rect key="frame" x="1" y="1" width="811" height="491"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<view fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Aer-4J-rbN">
|
||||
<rect key="frame" x="0.0" y="0.0" width="423" height="234"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="796" height="476"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
</view>
|
||||
</subviews>
|
||||
<color key="backgroundColor" name="disabledControlTextColor" catalog="System" colorSpace="catalog"/>
|
||||
</clipView>
|
||||
<scroller key="horizontalScroller" verticalHuggingPriority="750" horizontal="YES" id="zjd-Nw-zvr">
|
||||
<rect key="frame" x="1" y="234" width="438" height="16"/>
|
||||
<rect key="frame" x="1" y="476" width="811" height="16"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="Aon-x3-aqt">
|
||||
<rect key="frame" x="423" y="1" width="16" height="249"/>
|
||||
<rect key="frame" x="796" y="1" width="16" height="491"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
@@ -51,6 +51,7 @@
|
||||
<connections>
|
||||
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
|
||||
</connections>
|
||||
<point key="canvasLocation" x="292" y="185.5"/>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.1</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>454</string>
|
||||
<string>461</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
||||
@@ -46,9 +46,8 @@ class PDFItemViewController: NSViewController {
|
||||
month.stringValue = monthName
|
||||
guard dayFW != nil else { return }
|
||||
day.textColor = NSColor.black
|
||||
guard let log = dayFW?.fileWrappers?["KDLog.txt"] else { return }
|
||||
guard var logA = String(data: log.regularFileContents!, encoding: .utf8)?.components(separatedBy: "\n") else { return }
|
||||
logA.removeLast()
|
||||
guard let log = dayFW?.fileWrappers?["KDLog.hex"] else { return }
|
||||
guard let logA = FileOperations.load(log: log.regularFileContents! as NSData) else { return }
|
||||
loss.stringValue = "\(logA.count)"
|
||||
var am: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
var pm: [Int] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
version 2.1
|
||||
build 454
|
||||
build 461
|
||||
|
||||
Reference in New Issue
Block a user