3172 lines
132 KiB
VB.net
3172 lines
132 KiB
VB.net
|
|
Imports System.Data.Common
|
|||
|
|
Imports System.Globalization
|
|||
|
|
Imports System.IO
|
|||
|
|
Imports System.Text
|
|||
|
|
Imports System.Threading
|
|||
|
|
Imports FlexCell
|
|||
|
|
Imports Mysqlx
|
|||
|
|
Imports Newtonsoft.Json
|
|||
|
|
Imports Steema.TeeChart
|
|||
|
|
|
|||
|
|
Public Class Form1
|
|||
|
|
|
|||
|
|
|
|||
|
|
Public filepath As String
|
|||
|
|
|
|||
|
|
Public GdbConnString As String
|
|||
|
|
Public linglist As Dictionary(Of String, Steema.TeeChart.Styles.Line)
|
|||
|
|
Public linglist1 As Dictionary(Of String, Steema.TeeChart.Styles.Line)
|
|||
|
|
Dim LocalConnString As String
|
|||
|
|
Private _axis As List(Of Steema.TeeChart.Axis)
|
|||
|
|
Private _axis1 As List(Of Steema.TeeChart.Axis)
|
|||
|
|
Private _fastLine As Dictionary(Of String, Steema.TeeChart.Styles.FastLine)
|
|||
|
|
'Private _fastLine1 As Dictionary(Of String, Steema.TeeChart.Styles.FastLine)
|
|||
|
|
Private _curSor(1) As Steema.TeeChart.Tools.CursorTool
|
|||
|
|
Private _curSor1(1) As Steema.TeeChart.Tools.CursorTool
|
|||
|
|
Private Roomlist As Dictionary(Of String, String)
|
|||
|
|
Public g_Macconfig As (String, Dictionary(Of String, String))
|
|||
|
|
''' <summary>
|
|||
|
|
''' dat原始文件内容中的数据格式
|
|||
|
|
''' </summary>
|
|||
|
|
Enum LOG_DATA_FORMAT
|
|||
|
|
Hand = 0
|
|||
|
|
SN '日志每条数据增加序列号
|
|||
|
|
Len
|
|||
|
|
Len_8 '新增
|
|||
|
|
Check
|
|||
|
|
Date_H '年:5bit 月:5bit 日:5bit
|
|||
|
|
Date_L
|
|||
|
|
Type
|
|||
|
|
Time8B '小时时间戳
|
|||
|
|
Time16B
|
|||
|
|
Time24B
|
|||
|
|
Time32B
|
|||
|
|
Data
|
|||
|
|
End Enum
|
|||
|
|
''' <summary>
|
|||
|
|
''' 文件名结构解析
|
|||
|
|
''' </summary>
|
|||
|
|
Public Structure fileNameInfoStruct
|
|||
|
|
Public MAC As String
|
|||
|
|
Public HotelId As String
|
|||
|
|
Public RoomId As String
|
|||
|
|
Public CreateDateTime As String
|
|||
|
|
Public LogFileName As String
|
|||
|
|
End Structure
|
|||
|
|
Public Structure Log_DateStruct
|
|||
|
|
Public year As UInt16
|
|||
|
|
Public month As Byte
|
|||
|
|
Public day As Byte
|
|||
|
|
Public hour As Byte
|
|||
|
|
Public minute As Byte
|
|||
|
|
Public second As Byte
|
|||
|
|
Public milliscond As UInt16
|
|||
|
|
End Structure
|
|||
|
|
Enum Debugtype
|
|||
|
|
log = 1
|
|||
|
|
End Enum
|
|||
|
|
Enum LNetComm
|
|||
|
|
N_Send = 1 '网络发送数据
|
|||
|
|
N_Recv '网络接收数据
|
|||
|
|
End Enum
|
|||
|
|
''' <summary>
|
|||
|
|
''' BLV设备类型
|
|||
|
|
''' </summary>
|
|||
|
|
Enum BLV_DEVICE_TYPE
|
|||
|
|
|
|||
|
|
RS485_Switch = &H6 'T1开关
|
|||
|
|
RS485_Temp = &H7 'T1温控器
|
|||
|
|
RS485_Card = &HA 'T1插卡取电
|
|||
|
|
RS485_IR_SEND = &HF '红外转发
|
|||
|
|
RS485_RGB_Light = &H12 'RGB灯带
|
|||
|
|
RS485_XiaoBao = &H13 '小宝语音
|
|||
|
|
RS485_Time = &H23 '时间同步
|
|||
|
|
|
|||
|
|
C12Dimming = &H12 'BLV_Cx Dimming设备
|
|||
|
|
C5Music = &H15 'BLV_Cx MUSIC设备
|
|||
|
|
C5IO = &HF1 'BLV_Cx IO设备
|
|||
|
|
PC_TEST = &HF2 'BLV_Cx PC测试
|
|||
|
|
End Enum
|
|||
|
|
''' 日志数据 - 系统运行信息
|
|||
|
|
''' </summary>
|
|||
|
|
Enum LSYS
|
|||
|
|
PHY_Change = 1 'PHY状态变化记录
|
|||
|
|
DevInfo_Error '设备链表信息错误
|
|||
|
|
API_State '升级状态
|
|||
|
|
NET_ARGC '网络初始化参数
|
|||
|
|
MQTT_ARGC 'MQTT参数
|
|||
|
|
NetComm_State '网络通讯状态
|
|||
|
|
NET_DafaultARGC '网络默认参数
|
|||
|
|
End Enum
|
|||
|
|
Enum LOG_DEV_State
|
|||
|
|
Online = &H1
|
|||
|
|
Offline = &H2
|
|||
|
|
End Enum
|
|||
|
|
Enum LCOMM
|
|||
|
|
ASK_TO_Reply = 1 '轮询回复数据
|
|||
|
|
Send_Control 'RCU下发控制数据
|
|||
|
|
Control_Reply 'RCU控制回复数据
|
|||
|
|
Adjust_Baud '设备调整波特率
|
|||
|
|
End Enum
|
|||
|
|
''' <summary>
|
|||
|
|
''' 日志数据 - Launcher记录信息
|
|||
|
|
''' </summary>
|
|||
|
|
Enum LLauncher
|
|||
|
|
''' <summary>
|
|||
|
|
''' 校验APP
|
|||
|
|
''' </summary>
|
|||
|
|
App_Check = 1
|
|||
|
|
''' <summary>
|
|||
|
|
''' 读取APP
|
|||
|
|
''' </summary>
|
|||
|
|
Read_App
|
|||
|
|
''' <summary>
|
|||
|
|
''' 写Flash
|
|||
|
|
''' </summary>
|
|||
|
|
Write_Flash
|
|||
|
|
''' <summary>
|
|||
|
|
''' 恢复出厂设置
|
|||
|
|
''' </summary>
|
|||
|
|
Factory_Reset
|
|||
|
|
''' <summary>
|
|||
|
|
''' 复位信号源
|
|||
|
|
''' 0x00:软件复位
|
|||
|
|
''' 0x01:上电复位
|
|||
|
|
''' 0x02:看门狗复位
|
|||
|
|
''' 0x03:外部手动复位
|
|||
|
|
''' 0x05:从下电模式唤醒时的复位 - 通过WCHISPTool烧录后的复位
|
|||
|
|
''' </summary>
|
|||
|
|
Reset_Source
|
|||
|
|
End Enum
|
|||
|
|
''' 温控器设备数据结构
|
|||
|
|
''' </summary>
|
|||
|
|
Class Device_Temp
|
|||
|
|
Public on_off As Byte '开关机
|
|||
|
|
Public mode As Byte '模式
|
|||
|
|
Public fan As Byte '风速
|
|||
|
|
Public valve As Byte '阀门
|
|||
|
|
Public set_temp As Byte '设置温度
|
|||
|
|
Public indoor_temp As Byte '室内温度
|
|||
|
|
End Class
|
|||
|
|
''' 日志数据类型
|
|||
|
|
''' </summary>
|
|||
|
|
Enum log_type
|
|||
|
|
Launcher = 1 'Launcher信息记录
|
|||
|
|
SYS_Record '系统运行信息记录
|
|||
|
|
Device_COMM '设备通讯记录
|
|||
|
|
Device_Online '设备通讯状态记录
|
|||
|
|
Global_Parameters '所有设备状态定期记录 - 暂时还没用
|
|||
|
|
Net_COMM '网络通讯记录 - 暂时还没定
|
|||
|
|
Logic_Record '逻辑处理记录 - 暂时还没定
|
|||
|
|
|
|||
|
|
End Enum
|
|||
|
|
Public Structure LogDataInfoStruct
|
|||
|
|
Public MAC As String
|
|||
|
|
Public Log_Valid As Boolean
|
|||
|
|
Public Log_SN As UInt16
|
|||
|
|
Public Log_Len As UInt16
|
|||
|
|
Public Log_DateTime As Log_DateStruct
|
|||
|
|
Public Log_TimeSpan As Int64
|
|||
|
|
Public Log_Type As Byte
|
|||
|
|
Public Log_Content() As Byte
|
|||
|
|
Public HotelId As String
|
|||
|
|
Public RoomId As String
|
|||
|
|
Public CreateDateTime As String
|
|||
|
|
Public LogFileName As String
|
|||
|
|
Public parsing As List(Of String)
|
|||
|
|
End Structure
|
|||
|
|
Private Shared Log_Data_Len_Max As Int16 = 512
|
|||
|
|
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|||
|
|
Text = $"{Application.ProductName }{Application.ProductVersion }"
|
|||
|
|
filepath = $"{Application.StartupPath }\config.flx"
|
|||
|
|
g_Macconfig = ("", New Dictionary(Of String, String))
|
|||
|
|
GdbConnString = "Server=blv-cloud-db.mysql.rds.aliyuncs.com;Port=3307;Database=psmysql;Uid=blv_rcu;Pwd=fnadiaJDIJ7546;charset=utf8;"
|
|||
|
|
' 假设你的TeeChart控件名为tcChart
|
|||
|
|
AddHandler ChartBar.MouseWheel, AddressOf tcChart_ChartMouseWheel
|
|||
|
|
ChartBar.Zoom.ZoomPercent(130)
|
|||
|
|
|
|||
|
|
_axis = New List(Of Axis)
|
|||
|
|
_axis1 = New List(Of Axis)
|
|||
|
|
_fastLine = New Dictionary(Of String, Styles.FastLine)
|
|||
|
|
'_fastLine1 = New Dictionary(Of String, Styles.FastLine)
|
|||
|
|
My.Settings.Reload()
|
|||
|
|
If IO.Directory.Exists(My.Settings.FileDir) = True Then
|
|||
|
|
Label1.Text = My.Settings.FileDir
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
init_Grid_config()
|
|||
|
|
FileTo_Grid_config()
|
|||
|
|
linglist = New Dictionary(Of String, Steema.TeeChart.Styles.Line)
|
|||
|
|
'initChartBar(10, 1701747214, 1704822658)
|
|||
|
|
'Testfunction()
|
|||
|
|
'ksjfk()
|
|||
|
|
GetDevtype()
|
|||
|
|
My.Settings.Reload()
|
|||
|
|
|
|||
|
|
GetGetHotelList()
|
|||
|
|
If cbo_HotelList.Items.Count > 0 Then
|
|||
|
|
cbo_HotelList.SelectedIndex = 0
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
'通过API获取酒店ID
|
|||
|
|
Private Sub GetGetHotelList()
|
|||
|
|
cbo_HotelList.Items.Clear()
|
|||
|
|
If IsNothing(Roomlist) Then Roomlist = New Dictionary(Of String, String)
|
|||
|
|
Roomlist.Clear()
|
|||
|
|
Dim li As List(Of String) = GetAccountAuth()
|
|||
|
|
cbo_HotelList.Items.AddRange(li.ToArray())
|
|||
|
|
End Sub
|
|||
|
|
Private Function GetAccountAuth() As List(Of String)
|
|||
|
|
Dim result As List(Of String) = New List(Of String)()
|
|||
|
|
Dim jsonString As String = HttpMothod.PostData("http://blv-rd.tech:19055/api/LowerMachineLog/GetHotelList", "")
|
|||
|
|
If String.IsNullOrWhiteSpace(jsonString) Then Throw New Exception($"用户鉴权异常,请联系管理员")
|
|||
|
|
|
|||
|
|
Dim login As LoginReturn = JsonConvert.DeserializeObject(Of LoginReturn)(jsonString)
|
|||
|
|
If login Is Nothing Then Throw New Exception($"解析用户权限错误!")
|
|||
|
|
|
|||
|
|
If login.isok Then
|
|||
|
|
For Each item In login.response
|
|||
|
|
result.Add($"{item.code}|{item.name}")
|
|||
|
|
Roomlist.Add($"{item.code}|{item.name}", item.createdate)
|
|||
|
|
Next
|
|||
|
|
Else
|
|||
|
|
MsgBox("API获取酒店项目失败!")
|
|||
|
|
Return result
|
|||
|
|
End If
|
|||
|
|
Return result
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
' 事件处理程序
|
|||
|
|
Private Sub tcChart_ChartMouseWheel(sender As Object, e As MouseEventArgs)
|
|||
|
|
' 在这里添加你的逻辑
|
|||
|
|
' 例如,根据e.Delta判断滚轮滚动方向
|
|||
|
|
Dim tx, ty As Integer
|
|||
|
|
If IsNothing(_fastLine) OrElse _fastLine.Count = 0 Then Return
|
|||
|
|
Dim fl = _fastLine.Values(0)
|
|||
|
|
If e.Delta > 0 Then
|
|||
|
|
'MessageBox.Show("鼠标向上滚动")
|
|||
|
|
'tx = ChartBar.Zoom.
|
|||
|
|
' ty =
|
|||
|
|
' ChartBar.Zoom.ZoomRect(New Rectangle(0, 50, ChartBar.Width, 100))
|
|||
|
|
|
|||
|
|
|
|||
|
|
' If ChartBar.Zoom.HistorySteps.Count > 0 Then
|
|||
|
|
'ChartBar.Zoom.Undo()
|
|||
|
|
|
|||
|
|
'Else
|
|||
|
|
ChartBar.Zoom.ZoomRect(New Rectangle(0, 0, ChartBar.Width, ChartBar.Height))
|
|||
|
|
' Console.WriteLine($"鼠标向上滚动{ChartBar.Width},{ChartBar.Height}")
|
|||
|
|
'' End If
|
|||
|
|
'Dim rectc = ChartBar.RectangleToClient(New Rectangle(0, 0, ChartBar.Width, ChartBar.Height))
|
|||
|
|
'Console.WriteLine(fl.Chart.ChartRect.X)
|
|||
|
|
Else
|
|||
|
|
'MessageBox.Show("鼠标向下滚动")
|
|||
|
|
ChartBar.Zoom.Undo()
|
|||
|
|
' fl = _fastLine.Item(node.Key)
|
|||
|
|
'If ChartBar.Zoom.HistorySteps.Count > 0 Then
|
|||
|
|
' ChartBar.Zoom.Undo()
|
|||
|
|
' Console.WriteLine($"鼠标向上滚动_Undo")
|
|||
|
|
'Else
|
|||
|
|
' ChartBar.Zoom.ZoomRect(New Rectangle((ChartBar.Width / 2) - 300, 0, (ChartBar.Width / 2) + 100, ChartBar.Height))
|
|||
|
|
' Console.WriteLine($"鼠标向上滚动{(ChartBar.Width / 2) - 100},{(ChartBar.Width / 2) + 200}")
|
|||
|
|
'End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
'ChartBar.Zoom.ZoomRect(New Rectangle(100, 100, 120, 120))
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
'Dim X As Integer = Points1.CalcXPos(2)
|
|||
|
|
'Dim Y As Integer = TChart1.Axes.Left.CalcYPosValue(TChart1.Axes.Left.MaxYValue)
|
|||
|
|
'Dim Height As Integer = TChart1.Axes.Left.CalcYPosValue(TChart1.Axes.Left.MinYValue) - TChart1.Axes.Left.CalcYPosValue(TChart1.Axes.Left.MaxYValue)
|
|||
|
|
'Dim Width As Integer = Points1.CalcXPos(5) - X
|
|||
|
|
'Dim R As New Rectangle(X, Y, Width, Height)
|
|||
|
|
'TChart1.Zoom.ZoomRect(R)
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Public devnamedic As List(Of String)
|
|||
|
|
Public Sub GetDevtype()
|
|||
|
|
devnamedic = New List(Of String)
|
|||
|
|
Dim selectstr As String = "SELECT DEV_NAME
|
|||
|
|
FROM `psmysql`.`deviceparsingdatalog`
|
|||
|
|
GROUP BY DEV_NAME"
|
|||
|
|
Dim dt As DataTable
|
|||
|
|
Try
|
|||
|
|
Using db As New DbExecutor(DbExecutor.DbTypeEnum.Mysql, GdbConnString)
|
|||
|
|
db.Open()
|
|||
|
|
dt = db.ExecuteDataTable(selectstr)
|
|||
|
|
If IsNothing(dt) OrElse dt.Rows.Count = 0 OrElse dt.Columns.Count = 0 Then
|
|||
|
|
MsgBox($"数据查询失败!!!{vbCrLf }原因:{vbCrLf }数据查询语句异常:{selectstr}")
|
|||
|
|
Else
|
|||
|
|
For i = 0 To dt.Rows.Count - 1
|
|||
|
|
devnamedic.Add(dt(i)(0))
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Using
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Catch ex As Exception
|
|||
|
|
MsgBox($"数据查询失败!!!{vbCrLf }原因:{vbCrLf }{ex.Message }")
|
|||
|
|
Return
|
|||
|
|
End Try
|
|||
|
|
End Sub
|
|||
|
|
Public Function ClearDeviceform(dbpath As String, Tftp_Log As String) As Boolean
|
|||
|
|
|
|||
|
|
Dim localConn As New DbConnectionStringBuilder
|
|||
|
|
localConn.Add("Data Source", dbpath)
|
|||
|
|
'localConn.Add("Password", "123456")
|
|||
|
|
LocalConnString = localConn.ToString()
|
|||
|
|
|
|||
|
|
|
|||
|
|
Dim selectstr As String = $"CREATE TABLE IF NOT EXISTS [{Tftp_Log}] (
|
|||
|
|
[ID] integer COLLATE BINARY NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|||
|
|
[DevName] nvarchar(254) COLLATE BINARY,
|
|||
|
|
[FileName] nvarchar(254) COLLATE BINARY,
|
|||
|
|
[CreateFileTime] nvarchar(254) COLLATE BINARY,
|
|||
|
|
[Datastr] nvarchar(254) COLLATE BINARY,
|
|||
|
|
[T1] nvarchar(254) COLLATE BINARY,
|
|||
|
|
[DevService] nvarchar(254) COLLATE BINARY,
|
|||
|
|
[T3] nvarchar(254) COLLATE BINARY,
|
|||
|
|
[T2] nvarchar(254) COLLATE BINARY,
|
|||
|
|
[T5] nvarchar(254) COLLATE BINARY,
|
|||
|
|
[T4] nvarchar(254) COLLATE BINARY,
|
|||
|
|
[loop] nvarchar(254) COLLATE BINARY,
|
|||
|
|
[Datatime] integer COLLATE BINARY )"
|
|||
|
|
|
|||
|
|
Dim dt As DataTable
|
|||
|
|
Try
|
|||
|
|
Using db As New DbExecutor(DbExecutor.DbTypeEnum.Sqlite, LocalConnString)
|
|||
|
|
|
|||
|
|
db.Open()
|
|||
|
|
'Try
|
|||
|
|
' 'Dim vselectstr = $"DELETE FROM {Tftp_Log};"
|
|||
|
|
' 'db.ExecuteNonQuery(vselectstr)
|
|||
|
|
'Catch ex As Exception
|
|||
|
|
|
|||
|
|
|
|||
|
|
'End Try
|
|||
|
|
dt = db.ExecuteDataTable(selectstr)
|
|||
|
|
db.Close()
|
|||
|
|
If IsNothing(dt) Then
|
|||
|
|
MsgBox($"数据表创建失败!!!{vbCrLf }")
|
|||
|
|
Return False
|
|||
|
|
Else
|
|||
|
|
Return True
|
|||
|
|
End If
|
|||
|
|
Return True
|
|||
|
|
|
|||
|
|
End Using
|
|||
|
|
|
|||
|
|
Catch ex As Exception
|
|||
|
|
MsgBox($"数据表创建失败!!!{vbCrLf }原因:{vbCrLf }{ex.Message }")
|
|||
|
|
Return False
|
|||
|
|
End Try
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
Private Sub InitPieChart(kkdic As Dictionary(Of String, Dictionary(Of String, Double)), starttime As Date, stoptime As Date)
|
|||
|
|
InitTeeChart(kkdic, starttime, stoptime)
|
|||
|
|
|
|||
|
|
Dim fl As Steema.TeeChart.Styles.FastLine
|
|||
|
|
Dim tval As Dictionary(Of String, Double)
|
|||
|
|
Dim yt, yn As DateTime
|
|||
|
|
Dim sp = stoptime - starttime
|
|||
|
|
Dim dtOffset As New DateTimeOffset(starttime)
|
|||
|
|
Dim tstr As String
|
|||
|
|
Dim tstfsr As String
|
|||
|
|
|
|||
|
|
'Dim index As Integer = 0
|
|||
|
|
|
|||
|
|
For Each node In kkdic
|
|||
|
|
'Console.WriteLine($"{node.Key}")
|
|||
|
|
If node.Key = "执行条件状态" Then
|
|||
|
|
fl = _fastLine.Item(node.Key)
|
|||
|
|
Dim MarksTip1 As Steema.TeeChart.Tools.MarksTip = New Steema.TeeChart.Tools.MarksTip(ChartBar.Chart)
|
|||
|
|
MarksTip1.Series = fl
|
|||
|
|
MarksTip1.ForeColor = Color.White
|
|||
|
|
MarksTip1.BackColor = Color.Gray
|
|||
|
|
MarksTip1.HideDelay = 2500
|
|||
|
|
MarksTip1.MouseDelay = 100
|
|||
|
|
MarksTip1.Style = Styles.MarksStyles.LabelOrValue
|
|||
|
|
MarksTip1.MouseAction = Tools.MarksTipMouseAction.Click
|
|||
|
|
End If
|
|||
|
|
For t = 0 To sp.TotalSeconds
|
|||
|
|
fl = _fastLine.Item(node.Key)
|
|||
|
|
tval = node.Value
|
|||
|
|
|
|||
|
|
yt = (dtOffset.AddSeconds(t)).LocalDateTime
|
|||
|
|
tstr = $"{yt.Year }/{yt.Month }/{yt.Day } {yt.Hour }:{yt.Minute }:{yt.Second }"
|
|||
|
|
|
|||
|
|
If t <> 0 Then
|
|||
|
|
yn = (dtOffset.AddSeconds(t - 1)).LocalDateTime
|
|||
|
|
tstfsr = $"{yn.Year }/{yn.Month }/{yn.Day } {yn.Hour }:{yn.Minute }:{yn.Second }"
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
If node.Key = "执行条件状态" Then
|
|||
|
|
|
|||
|
|
|
|||
|
|
If tval.ContainsKey(tstr) Then
|
|||
|
|
If t = 0 OrElse Not (tval.Item(tstr) <> tval.Item(tstfsr)) Then
|
|||
|
|
|
|||
|
|
Else
|
|||
|
|
fl.Add(yt.AddHours(8).ToOADate, tval.Item(tstfsr))
|
|||
|
|
End If
|
|||
|
|
fl.Add(yt.AddHours(8).ToOADate, tval.Item(tstr))
|
|||
|
|
Else
|
|||
|
|
|
|||
|
|
If Date.Parse(tstr) < Date.Parse(tval.Keys(0)) Then
|
|||
|
|
fl.Add(yt.AddHours(8).ToOADate, 0)
|
|||
|
|
tval.Add(tstr, 0)
|
|||
|
|
Else
|
|||
|
|
|
|||
|
|
'Dim s = fl.YValues((fl.YValues.Count - 1))
|
|||
|
|
fl.Add(yt.AddHours(8).ToOADate, fl.YValues((fl.YValues.Count - 1)))
|
|||
|
|
's = fl.YValues((fl.YValues.Count - 1))
|
|||
|
|
tval.Add(tstr, fl.YValues((fl.YValues.Count - 1)))
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Else
|
|||
|
|
|
|||
|
|
If tval.ContainsKey(tstr) Then
|
|||
|
|
If t = 0 OrElse Not (tval.Item(tstr) <> tval.Item(tstfsr)) Then
|
|||
|
|
|
|||
|
|
Else
|
|||
|
|
fl.Add(yt.AddHours(8).ToOADate, tval.Item(tstfsr))
|
|||
|
|
End If
|
|||
|
|
fl.Add(yt.AddHours(8).ToOADate, tval.Item(tstr))
|
|||
|
|
'Console.WriteLine($"{tstr}:{ tval.Values(t)}")
|
|||
|
|
Else
|
|||
|
|
If Date.Parse(tstr) < Date.Parse(tval.Keys(0)) Then
|
|||
|
|
If tval.Values(0) = 1 Then
|
|||
|
|
fl.Add(yt.AddHours(8).ToOADate, 0)
|
|||
|
|
tval.Add(tstr, 0)
|
|||
|
|
' Console.WriteLine($"{tstr}:0")
|
|||
|
|
ElseIf tval.Values(0) = 0 Then
|
|||
|
|
fl.Add(yt.AddHours(8).ToOADate, 1)
|
|||
|
|
tval.Add(tstr, 1)
|
|||
|
|
' Console.WriteLine($"{tstr}:1")
|
|||
|
|
Else
|
|||
|
|
fl.Add(yt.AddHours(8).ToOADate, 0.5)
|
|||
|
|
tval.Add(tstr, 0.5)
|
|||
|
|
'Console.WriteLine($"{tstr}:0.5")
|
|||
|
|
End If
|
|||
|
|
Else
|
|||
|
|
If tval.Item(tstfsr) = 1 Then
|
|||
|
|
fl.Add(yt.AddHours(8).ToOADate, 1)
|
|||
|
|
tval.Add(tstr, 1)
|
|||
|
|
' Console.WriteLine($"{tstr}:1")
|
|||
|
|
ElseIf tval.Item(tstfsr) = 0 Then
|
|||
|
|
fl.Add(yt.AddHours(8).ToOADate, 0)
|
|||
|
|
tval.Add(tstr, 0)
|
|||
|
|
' Console.WriteLine($"{tstr}:0")
|
|||
|
|
Else
|
|||
|
|
fl.Add(yt.AddHours(8).ToOADate, 0.5)
|
|||
|
|
tval.Add(tstr, 0.5)
|
|||
|
|
' Console.WriteLine($"{tstr}:0.5")
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Next
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub InitPieChart(kkdic As Dictionary(Of String, Dictionary(Of Long, Double)), starttime As Long, stoptime As Long)
|
|||
|
|
|
|||
|
|
|
|||
|
|
InitTeeChart(kkdic, starttime, stoptime)
|
|||
|
|
Dim fl As Steema.TeeChart.Styles.FastLine
|
|||
|
|
Dim tval As Dictionary(Of Long, Double)
|
|||
|
|
Dim dtOffset As New DateTimeOffset(New DateTime(1970, 1, 1, 0, 0, 0))
|
|||
|
|
' 获取本地日期和时间
|
|||
|
|
Dim yt As DateTime
|
|||
|
|
|
|||
|
|
For t = starttime To stoptime
|
|||
|
|
For Each node In kkdic
|
|||
|
|
fl = _fastLine.Item(node.Key)
|
|||
|
|
tval = node.Value
|
|||
|
|
yt = (dtOffset.AddSeconds(t)).LocalDateTime
|
|||
|
|
|
|||
|
|
If tval.ContainsKey(t) Then
|
|||
|
|
If t = starttime OrElse Not (tval.Item(t) = tval.Item(t - 1)) Then
|
|||
|
|
Else
|
|||
|
|
fl.Add(yt.ToOADate, tval.Item(t - 1))
|
|||
|
|
'Console.WriteLine($"{yt.ToOADate}:{ tval.Item(t - 1)}")
|
|||
|
|
End If
|
|||
|
|
fl.Add(yt.ToOADate, tval.Item(t))
|
|||
|
|
'Console.WriteLine($"{yt.ToOADate}:{ tval.Item(t)}")
|
|||
|
|
''Console.WriteLine(DateTime.FromOADate(yt.ToOADate).ToString("yyyy-MM-dd HH:mm:ss"))
|
|||
|
|
|
|||
|
|
'#1/16/2024 01:09:47 AM#
|
|||
|
|
Else
|
|||
|
|
If t < tval.Keys(0) Then
|
|||
|
|
If tval.Values(0) = 1 Then
|
|||
|
|
fl.Add(yt.ToOADate, 0)
|
|||
|
|
tval.Add(t, 0)
|
|||
|
|
'Console.WriteLine($"{yt.ToOADate}:0")
|
|||
|
|
ElseIf tval.Values(0) = 0 Then
|
|||
|
|
fl.Add(yt.ToOADate, 1)
|
|||
|
|
tval.Add(t, 1)
|
|||
|
|
'Console.WriteLine($"{yt.ToOADate}:1")
|
|||
|
|
Else
|
|||
|
|
fl.Add(yt.ToOADate, 0.5)
|
|||
|
|
tval.Add(t, 0.5)
|
|||
|
|
'Console.WriteLine($"{yt.ToOADate}:0.5")
|
|||
|
|
End If
|
|||
|
|
Else
|
|||
|
|
If tval.Item(t - 1) = 1 Then
|
|||
|
|
fl.Add(yt.ToOADate, 1)
|
|||
|
|
tval.Add(t, 1)
|
|||
|
|
'Console.WriteLine($"{yt.ToOADate}:1")
|
|||
|
|
ElseIf tval.Item(t - 1) = 0 Then
|
|||
|
|
fl.Add(yt.ToOADate, 0)
|
|||
|
|
tval.Add(t, 0)
|
|||
|
|
'Console.WriteLine($"{yt.ToOADate}:0")
|
|||
|
|
Else
|
|||
|
|
fl.Add(yt.ToOADate, 0.5)
|
|||
|
|
tval.Add(t, 0.5)
|
|||
|
|
'Console.WriteLine($"{yt.ToOADate}:0.5")
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
Next
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
Public Sub initChartBar(tCounta As Integer, starttime As Double, stoptime As Double)
|
|||
|
|
|
|||
|
|
'Dim devline = AddTeeChartStylesLine()
|
|||
|
|
|
|||
|
|
ChartBar.Header.Text = "" '标题
|
|||
|
|
ChartBar.Header.Visible = True
|
|||
|
|
ChartBar.Legend.Transparent = False '刻印说明
|
|||
|
|
' ChartBar.Legend.Alignment = Steema.TeeChart.LegendAlignments.Top
|
|||
|
|
ChartBar.Aspect.View3D = False
|
|||
|
|
ChartBar.Axes.Left.Automatic = True
|
|||
|
|
ChartBar.Axes.Left.AutomaticMaximum = True
|
|||
|
|
ChartBar.Axes.Left.AutomaticMinimum = True
|
|||
|
|
ChartBar.Axes.Left.Labels.ValueFormat = "0.0"
|
|||
|
|
ChartBar.Axes.Left.Increment = 0.5
|
|||
|
|
ChartBar.Axes.Left.Labels.LabelHeight(10)
|
|||
|
|
|
|||
|
|
'ChartBar.Axes.Left.Scroll(15, True)
|
|||
|
|
|
|||
|
|
'ChartBar.Axes.Left.Labels.Exponent = True
|
|||
|
|
'Line1.Clear()
|
|||
|
|
'ChartBar.Axes.
|
|||
|
|
ChartBar.Axes.Bottom.AutomaticMaximum = False
|
|||
|
|
ChartBar.Axes.Bottom.AutomaticMinimum = False
|
|||
|
|
ChartBar.Axes.Bottom.Automatic = False
|
|||
|
|
ChartBar.Axes.Bottom.Increment = 1
|
|||
|
|
ChartBar.Axes.Bottom.Maximum = stoptime
|
|||
|
|
'ChartBar.Axes.Bottom.Minimum = starttime
|
|||
|
|
'ChartBar.Axes.Bottom.Labels.Width = 20
|
|||
|
|
'ChartBar.Axes.Bottom.Labels.DateTimeFormat = "HH:mm:ss"
|
|||
|
|
'ChartBar.Series(0).XValues.DateTime = False
|
|||
|
|
'ChartBar.Axes.Bottom.MaxXValue = stoptime
|
|||
|
|
'ChartBar.Axes.Bottom.ma = stoptime
|
|||
|
|
'ChartBar.Axes.Bottom.Scroll(1705386785, False)
|
|||
|
|
|
|||
|
|
'ChartBar.Axes.Bottom.Scroll()
|
|||
|
|
'ChartBar.Zoom.ZoomRect(New Rectangle(0, 0, 1000, 1000))
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Dim ftemp = tCounta
|
|||
|
|
ChartBar.Axes.Left.Maximum = ftemp ' / 100
|
|||
|
|
ChartBar.Axes.Left.Minimum = 0 '/ 100
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Bottom.Labels.Align = -45
|
|||
|
|
ChartBar.Axes.Bottom.Labels.MultiLine = True
|
|||
|
|
|
|||
|
|
|
|||
|
|
'Dim X As Integer = ChartBar
|
|||
|
|
|
|||
|
|
'Dim R As New Rectangle(X, Y, Width, Height)
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
' ChartBar.Refresh()
|
|||
|
|
End Sub
|
|||
|
|
Public Sub Testfunction()
|
|||
|
|
|
|||
|
|
ChartBar.Header.Text = "" '标题
|
|||
|
|
ChartBar.Header.Visible = True
|
|||
|
|
ChartBar.Aspect.View3D = False
|
|||
|
|
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Left.Automatic = False
|
|||
|
|
ChartBar.Axes.Left.AutomaticMaximum = False
|
|||
|
|
ChartBar.Axes.Left.AutomaticMinimum = False
|
|||
|
|
ChartBar.Axes.Left.Labels.ValueFormat = "0.0"
|
|||
|
|
ChartBar.Axes.Left.Increment = 0.5
|
|||
|
|
ChartBar.Axes.Left.Maximum = 10 ' / 100
|
|||
|
|
ChartBar.Axes.Left.Minimum = 0 '/ 100
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Bottom.AutomaticMaximum = False
|
|||
|
|
ChartBar.Axes.Bottom.AutomaticMinimum = False
|
|||
|
|
ChartBar.Axes.Bottom.Automatic = False
|
|||
|
|
ChartBar.Axes.Bottom.Labels.Align = -45
|
|||
|
|
ChartBar.Axes.Bottom.Labels.MultiLine = True
|
|||
|
|
ChartBar.Axes.Bottom.Labels.DateTimeFormat = "yyyy-MM-dd"
|
|||
|
|
ChartBar.Series(0).XValues.DateTime = True
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
' 创建 DateTimeOffset 对象并设置其值为指定的 UTC 秒数
|
|||
|
|
Dim dtOffset As New DateTimeOffset(New DateTime(1970, 1, 1), TimeSpan.Zero)
|
|||
|
|
' 获取本地日期和时间
|
|||
|
|
Dim yt As DateTime = (dtOffset + TimeSpan.FromSeconds(1704822366)).LocalDateTime
|
|||
|
|
Dim minValue As DateTime = New DateTime(yt.Year, yt.Month, yt.Day, yt.Hour, yt.Minute, yt.Second) '' 最小日期
|
|||
|
|
yt = (dtOffset + TimeSpan.FromSeconds(1704823530)).LocalDateTime
|
|||
|
|
Dim maxValue As DateTime = New DateTime(yt.Year, yt.Month, yt.Day, yt.Hour, yt.Minute, yt.Second) '' 最小日期
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Bottom.Maximum = maxValue.ToOADate
|
|||
|
|
ChartBar.Axes.Bottom.Minimum = minValue.ToOADate
|
|||
|
|
'Dim dou As Double = 1 / (maxValue.ToOADate - minValue.ToOADate)
|
|||
|
|
'ChartBar.Axes.Bottom.Increment = TimeSpan.FromSeconds(1).TotalSeconds
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Public Sub ksjfk()
|
|||
|
|
' 创建TeeChart控件对象
|
|||
|
|
Dim chart = ChartBar.Chart
|
|||
|
|
|
|||
|
|
' 添加Series到图表上(这里使用Line Series作示例)
|
|||
|
|
Dim series As New Steema.TeeChart.Styles.Line()
|
|||
|
|
'chart.Add(series)
|
|||
|
|
ChartBar.Series.Add(series)
|
|||
|
|
' 定义要显示的数据点及其相应的X轴标签
|
|||
|
|
Dim xDataPoints() As Double = {10, 20, 30, 40} ' X轴数据点
|
|||
|
|
Dim yDataPoints() As Double = {50, 60, 70, 80} ' Y轴数据点
|
|||
|
|
Dim labels() As String = {"Label1", "Label2", "Label3", "Label4"} ' X轴标签
|
|||
|
|
|
|||
|
|
' 遍历数据并设置每个数据点的值和标签
|
|||
|
|
For i As Integer = 0 To xDataPoints.Length - 1
|
|||
|
|
|
|||
|
|
Dim point As New PointF(xDataPoints(i), yDataPoints(i))
|
|||
|
|
|
|||
|
|
' 设置X轴标签
|
|||
|
|
point.X = labels(i)
|
|||
|
|
|
|||
|
|
' 向系列中添加数据点
|
|||
|
|
series.Add(point)
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
' 显示图表
|
|||
|
|
'chart.ShowDialog()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
Public Function AddTeeChartStylesLine() As Styles.Line
|
|||
|
|
Dim devline As Steema.TeeChart.Styles.Line = New Styles.Line
|
|||
|
|
ChartBar.Series.Add(devline)
|
|||
|
|
Dim minValue As DateTime = New DateTime(2024, 1, 10, 2, 35, 30) '' 最小日期
|
|||
|
|
|
|||
|
|
|
|||
|
|
Return devline
|
|||
|
|
' Dim chart As TChart = ChartBar
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
Public Sub init_Grid_config()
|
|||
|
|
With Grid_config
|
|||
|
|
.NewFile()
|
|||
|
|
.Cols = 3
|
|||
|
|
.Rows = 7
|
|||
|
|
.Width = 300
|
|||
|
|
.DisplayRowNumber = False
|
|||
|
|
.Cell(0, 0).Text = "序号"
|
|||
|
|
.Cell(0, 1).Text = "属性"
|
|||
|
|
.Cell(0, 2).Text = "属性值"
|
|||
|
|
.Column(0).Width = 0
|
|||
|
|
.Column(1).Width = 100
|
|||
|
|
.Column(1).Locked = True
|
|||
|
|
.Column(2).Width = 150
|
|||
|
|
.Column(1).Alignment = AlignmentEnum.CenterCenter
|
|||
|
|
.Column(2).Alignment = AlignmentEnum.CenterCenter
|
|||
|
|
.Cell(1, 1).Text = "开始时间"
|
|||
|
|
.Cell(2, 1).Text = "结束时间"
|
|||
|
|
.Cell(3, 1).Text = "机型"
|
|||
|
|
.Cell(4, 1).Text = "界面宽度"
|
|||
|
|
.Cell(5, 1).Text = "界面高度"
|
|||
|
|
.Cell(6, 1).Text = "左右比例"
|
|||
|
|
.Cell(1, 2).CellType = CellTypeEnum.DateTime
|
|||
|
|
.Cell(2, 2).CellType = CellTypeEnum.DateTime
|
|||
|
|
.Cell(3, 2).CellType = CellTypeEnum.ComboBox
|
|||
|
|
.Row(4).Visible = False
|
|||
|
|
|
|||
|
|
.Row(5).Visible = False
|
|||
|
|
.Row(6).Visible = False
|
|||
|
|
End With
|
|||
|
|
End Sub
|
|||
|
|
Public Sub FileTo_Grid_config()
|
|||
|
|
If IO.File.Exists(filepath) Then
|
|||
|
|
Grid_config.OpenFile(filepath)
|
|||
|
|
Dim kk As Integer = 0
|
|||
|
|
Dim kr As Integer = 0
|
|||
|
|
If Integer.TryParse(Grid_config.Cell(4, 2).Text, kk) And Integer.TryParse(Grid_config.Cell(5, 2).Text, kr) Then
|
|||
|
|
If kk <> 0 And kr <> 0 Then
|
|||
|
|
Size = New Size(kk, kr)
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
kk = 0
|
|||
|
|
If Integer.TryParse(Grid_config.Cell(6, 2).Text, kk) Then
|
|||
|
|
If kk <> 0 Then
|
|||
|
|
SplitContainer1.SplitterDistance = kk
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
Public Sub Grid_config_FileTo()
|
|||
|
|
|
|||
|
|
Grid_config.Cell(4, 2).Text = Size.Width
|
|||
|
|
Grid_config.Cell(5, 2).Text = Size.Height
|
|||
|
|
Grid_config.Cell(6, 2).Text = SplitContainer1.SplitterDistance
|
|||
|
|
Grid_config.SaveFile(filepath)
|
|||
|
|
|
|||
|
|
|
|||
|
|
My.Settings.FileDir = Label1.Text
|
|||
|
|
My.Settings.Save()
|
|||
|
|
If IsNothing(_fastLine) OrElse _fastLine.Count = 0 Then Return
|
|||
|
|
Dim fastNameList As String = String.Empty
|
|||
|
|
For Each node In ChartBar.Axes.Custom
|
|||
|
|
fastNameList = fastNameList & node.title.Caption & ","
|
|||
|
|
Next
|
|||
|
|
fastNameList = fastNameList.Substring(0, fastNameList.Length - 1)
|
|||
|
|
My.Settings.fastLineName = fastNameList
|
|||
|
|
My.Settings.Save()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
|
|||
|
|
Grid_config_FileTo()
|
|||
|
|
If IsNothing(threadli) Then Return
|
|||
|
|
For Each node In threadli
|
|||
|
|
node.Abort()
|
|||
|
|
Next
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
|
|||
|
|
Grid_config.AddItem("")
|
|||
|
|
Grid_config.Cell(Grid_config.Rows - 1, 1).Text = "机型"
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Private Sub ToolStripButton3_Click(sender As Object, e As EventArgs) Handles ToolStripButton3.Click
|
|||
|
|
Grid_configDeleteRow(Grid_config.ActiveCell.Row)
|
|||
|
|
End Sub
|
|||
|
|
Public Sub Grid_configDeleteRow(erow As Integer)
|
|||
|
|
Dim devname As String = Grid_config.Cell(erow, 1).Text
|
|||
|
|
If devname.Equals("机型") Then
|
|||
|
|
Grid_config.Row(erow).Delete()
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles ToolStripButton2.Click
|
|||
|
|
init_Grid_config()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub ToolStripButton4_Click(sender As Object, e As EventArgs) Handles ToolStripButton4.Click
|
|||
|
|
'MysqlDataDispose()
|
|||
|
|
SqlitDataDispose()
|
|||
|
|
End Sub
|
|||
|
|
Public Sub SqlitDataDispose()
|
|||
|
|
If String.IsNullOrEmpty(Label1.Text) Then
|
|||
|
|
MsgBox("未选择日志目录")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
If Not IO.Directory.Exists(Label1.Text) Then
|
|||
|
|
MsgBox("日志目录不存在")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Dim filrpath As String = Grid_config.Cell(3, 2).Text.Trim
|
|||
|
|
If String.IsNullOrEmpty(filrpath) Then
|
|||
|
|
MsgBox("目标机型为空")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
Dim mubdir As String = $"{Label1.Text}\{filrpath}"
|
|||
|
|
If Not IO.Directory.Exists(mubdir) Then
|
|||
|
|
MsgBox("目标机型目录不存在")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
IO.Directory.CreateDirectory($"{Label1.Text}\ParsingLog\{filrpath}")
|
|||
|
|
Dim ParsingLog As String = $"{Label1.Text}\ParsingLog\{filrpath}"
|
|||
|
|
|
|||
|
|
Dim localConn As New DbConnectionStringBuilder
|
|||
|
|
localConn.Add("Data Source", $"{ParsingLog}\Tftp_Log.db")
|
|||
|
|
|
|||
|
|
LocalConnString = localConn.ToString()
|
|||
|
|
If String.IsNullOrEmpty(LocalConnString) Then
|
|||
|
|
MsgBox("未选择日志目录或未解析该机型数据")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Dim selectstr As String = "SELECT * FROM `Tftp_Log` WHERE"
|
|||
|
|
Dim cstrpar As String = String.Empty
|
|||
|
|
Dim starttime, stoptime As DateTime
|
|||
|
|
Dim dtZone As DateTime = New DateTime(1970, 1, 1, 0, 0, 0)
|
|||
|
|
Try
|
|||
|
|
|
|||
|
|
starttime = DateTime.Parse(Grid_config.Cell(1, 2).Text.Trim)
|
|||
|
|
stoptime = DateTime.Parse(Grid_config.Cell(2, 2).Text.Trim)
|
|||
|
|
If IsNothing(starttime) OrElse IsNothing(stoptime) Then
|
|||
|
|
MsgBox($"数据查询失败!!!{vbCrLf }原因:{vbCrLf }日期输入错误")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
Catch ex As Exception
|
|||
|
|
MsgBox($"数据查询失败!!!{vbCrLf }原因:{vbCrLf }日期输入错误")
|
|||
|
|
Return
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
For i = 1 To Grid_config.Rows - 1
|
|||
|
|
If i = 1 Then
|
|||
|
|
selectstr = $"{selectstr}`DataTime`>='{starttime.ToUniversalTime.Ticks }' And "
|
|||
|
|
ElseIf i = 2 Then
|
|||
|
|
selectstr = $"{selectstr}`DataTime`<='{stoptime.ToUniversalTime.Ticks}' And "
|
|||
|
|
ElseIf i = 3 Then
|
|||
|
|
cstrpar = $"{cstrpar}OR `DevName` = '{Grid_config.Cell(i, 2).Text.Trim}'{vbCrLf }"
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Next
|
|||
|
|
If Not String.IsNullOrEmpty(cstrpar) Then
|
|||
|
|
cstrpar = cstrpar.Remove(0, 2)
|
|||
|
|
selectstr = $"{selectstr}({cstrpar.Trim }) ORDER BY (`DataTime`) ASC"
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Dim treenode As Dictionary(Of String, List(Of (String, String))) = New Dictionary(Of String, List(Of (String, String)))
|
|||
|
|
Dim treedic As List(Of (String, String))
|
|||
|
|
Dim rval As Double = 0
|
|||
|
|
Dim colounmdic As Dictionary(Of String, Dictionary(Of String, Double)) = New Dictionary(Of String, Dictionary(Of String, Double))
|
|||
|
|
Dim T3dci As Dictionary(Of String, Double) = New Dictionary(Of String, Double)
|
|||
|
|
Dim dt As DataTable
|
|||
|
|
|
|||
|
|
Try
|
|||
|
|
Using db As New DbExecutor(DbExecutor.DbTypeEnum.Sqlite, LocalConnString)
|
|||
|
|
db.Open()
|
|||
|
|
dt = db.ExecuteDataTable(selectstr)
|
|||
|
|
If IsNothing(dt) OrElse dt.Rows.Count = 0 OrElse dt.Columns.Count = 0 Then
|
|||
|
|
MsgBox($"数据查询失败!!!")
|
|||
|
|
db.Close()
|
|||
|
|
Return
|
|||
|
|
Else
|
|||
|
|
|
|||
|
|
Dim sqldate As Date
|
|||
|
|
Dim timse As String
|
|||
|
|
Dim val1, val2, val3 As String
|
|||
|
|
Dim keystr As String
|
|||
|
|
For i = 0 To dt.Rows.Count - 1
|
|||
|
|
Dim Tcint As Long = (dt.Rows(i)("Datatime"))
|
|||
|
|
sqldate = New DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)
|
|||
|
|
sqldate = sqldate.AddTicks(Tcint)
|
|||
|
|
|
|||
|
|
sqldate.ToLocalTime()
|
|||
|
|
timse = $"{sqldate.Year }/{sqldate.Month }/{sqldate.Day } {sqldate.Hour }:{sqldate.Minute }:{sqldate.Second }"
|
|||
|
|
|
|||
|
|
If i = 0 Then
|
|||
|
|
starttime = sqldate
|
|||
|
|
ElseIf i = dt.Rows.Count - 1 Then
|
|||
|
|
stoptime = sqldate
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Try
|
|||
|
|
keystr = $"{dt.Rows(i)("FileName")}-{dt.Rows(i)("CreateFileTime")}"
|
|||
|
|
If treenode.ContainsKey(keystr) Then
|
|||
|
|
treedic = treenode.Item(keystr)
|
|||
|
|
Else
|
|||
|
|
treedic = New List(Of (String, String))
|
|||
|
|
treenode.Add(keystr, treedic)
|
|||
|
|
End If
|
|||
|
|
treedic.Add((timse, $"{dt.Rows(i)("Datastr")}"))
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Catch ex As Exception
|
|||
|
|
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
If IsDBNull(dt.Rows(i)("T4")) AndAlso ((Not IsDBNull(dt.Rows(i)("T1")) OrElse (Not IsDBNull(dt.Rows(i)("T3")))) AndAlso Not IsDBNull(dt.Rows(i)("loop"))) Then
|
|||
|
|
Dim vloop As String = $"loop{dt.Rows(i)("loop")}"
|
|||
|
|
If Not IsDBNull(dt.Rows(i)("T3")) Then
|
|||
|
|
|
|||
|
|
If T3dci.ContainsKey(timse) Then
|
|||
|
|
T3dci.Item(timse) = dt.Rows(i)("loop")
|
|||
|
|
Else
|
|||
|
|
T3dci.Add(timse, dt.Rows(i)("loop"))
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
ElseIf Not IsDBNull(dt.Rows(i)("T1")) Then
|
|||
|
|
|
|||
|
|
If colounmdic.ContainsKey(vloop) Then
|
|||
|
|
If colounmdic.Item(vloop).ContainsKey(timse) Then
|
|||
|
|
If dt.Rows(i)("T1").Equals("1") Then
|
|||
|
|
colounmdic.Item(vloop).Item(timse) = 1
|
|||
|
|
Else
|
|||
|
|
colounmdic.Item(vloop).Item(timse) = 0
|
|||
|
|
End If
|
|||
|
|
Else
|
|||
|
|
If dt.Rows(i)("T1").Equals("1") Then
|
|||
|
|
colounmdic.Item(vloop).Add(timse, 1)
|
|||
|
|
Else
|
|||
|
|
colounmdic.Item(vloop).Add(timse, 0)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
Else
|
|||
|
|
Dim dic As Dictionary(Of String, Double) = New Dictionary(Of String, Double)
|
|||
|
|
colounmdic.Add(vloop, dic)
|
|||
|
|
If dt.Rows(i)("T1").Equals("1") Then
|
|||
|
|
dic.Add(timse, 1)
|
|||
|
|
Else
|
|||
|
|
dic.Add(timse, 0)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
Else
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
ElseIf Not IsDBNull(dt.Rows(i)("T4")) Then
|
|||
|
|
'Console.WriteLine($"{dt.Rows(i)("FileName")}{timse}, {dt.Rows(i)("Datastr")}"")
|
|||
|
|
'Console.WriteLine($"{dt.Rows(i)("FileName")} {timse} {dt.Rows(i)("Datastr")}")
|
|||
|
|
If colounmdic.ContainsKey("T4") Then
|
|||
|
|
If colounmdic.Item("T4").ContainsKey(timse) Then
|
|||
|
|
If dt.Rows(i)("T4").Equals("1") Then
|
|||
|
|
colounmdic.Item("T4").Item(timse) = 1
|
|||
|
|
Else
|
|||
|
|
colounmdic.Item("T4").Item(timse) = 0
|
|||
|
|
End If
|
|||
|
|
Else
|
|||
|
|
If dt.Rows(i)("T4").Equals("1") Then
|
|||
|
|
colounmdic.Item("T4").Add(timse, 1)
|
|||
|
|
Else
|
|||
|
|
colounmdic.Item("T4").Add(timse, 0)
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
Else
|
|||
|
|
|
|||
|
|
Dim dic As Dictionary(Of String, Double) = New Dictionary(Of String, Double)
|
|||
|
|
colounmdic.Add("T4", dic)
|
|||
|
|
If dt.Rows(i)("T4").Equals("1") Then
|
|||
|
|
dic.Add(timse, 1)
|
|||
|
|
Else
|
|||
|
|
dic.Add(timse, 0)
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
ElseIf Not IsDBNull(dt.Rows(i)("DevService")) AndAlso Not IsDBNull(dt.Rows(i)("loop")) AndAlso dt.Rows(i)("DevService").Equals("0") Then
|
|||
|
|
If colounmdic.ContainsKey("DevService") Then
|
|||
|
|
If colounmdic.Item("DevService").ContainsKey(timse) Then
|
|||
|
|
If dt.Rows(i)("loop").Equals("1") Then
|
|||
|
|
colounmdic.Item("DevService").Item(timse) = 1
|
|||
|
|
Else
|
|||
|
|
colounmdic.Item("DevService").Item(timse) = 0
|
|||
|
|
End If
|
|||
|
|
Else
|
|||
|
|
If dt.Rows(i)("loop").Equals("1") Then
|
|||
|
|
colounmdic.Item("DevService").Add(timse, 1)
|
|||
|
|
Else
|
|||
|
|
colounmdic.Item("DevService").Add(timse, 0)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
Else
|
|||
|
|
Dim dic As Dictionary(Of String, Double) = New Dictionary(Of String, Double)
|
|||
|
|
colounmdic.Add("DevService", dic)
|
|||
|
|
If dt.Rows(i)("loop").Equals("1") Then
|
|||
|
|
dic.Add(timse, 1)
|
|||
|
|
Else
|
|||
|
|
dic.Add(timse, 0)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
db.Close()
|
|||
|
|
End Using
|
|||
|
|
|
|||
|
|
|
|||
|
|
Catch ex As Exception
|
|||
|
|
MsgBox($"数据查询失败!!!{vbCrLf }原因:{vbCrLf }{ex.Message }")
|
|||
|
|
Return
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
colounmdic.Add("执行条件状态", T3dci)
|
|||
|
|
SetTreeStakeData(treenode)
|
|||
|
|
SortDic(colounmdic)
|
|||
|
|
ChangeLineAlias(colounmdic)
|
|||
|
|
InitPieChart(colounmdic, starttime.AddHours(-8), stoptime.AddHours(-8))
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
'键值对排序
|
|||
|
|
Private Sub SortDic(ByRef kkdic As Dictionary(Of String, Dictionary(Of String, Double)))
|
|||
|
|
Dim T4 As New Dictionary(Of String, Double)
|
|||
|
|
Dim T2 As New Dictionary(Of String, Double)
|
|||
|
|
Dim DevService As New Dictionary(Of String, Double)
|
|||
|
|
Dim li As New Dictionary(Of String, Dictionary(Of String, Double))
|
|||
|
|
If kkdic.ContainsKey("T4") Then
|
|||
|
|
T4 = kkdic.Item("T4")
|
|||
|
|
kkdic.Remove("T4")
|
|||
|
|
End If
|
|||
|
|
If kkdic.ContainsKey("DevService") Then
|
|||
|
|
DevService = kkdic.Item("DevService")
|
|||
|
|
kkdic.Remove("DevService")
|
|||
|
|
End If
|
|||
|
|
If kkdic.ContainsKey("执行条件状态") Then
|
|||
|
|
T2 = kkdic.Item("执行条件状态")
|
|||
|
|
kkdic.Remove("执行条件状态")
|
|||
|
|
End If
|
|||
|
|
Dim arrys = kkdic.Keys.ToArray
|
|||
|
|
arrys = arrys.OrderBy(Function(x) x).ToArray
|
|||
|
|
For Each item In arrys
|
|||
|
|
li.Add(item, kkdic.Item(item))
|
|||
|
|
Next
|
|||
|
|
If Not IsNothing(T4) AndAlso T4.Count > 0 Then
|
|||
|
|
li.Add("T4", T4)
|
|||
|
|
End If
|
|||
|
|
If Not IsNothing(DevService) AndAlso DevService.Count > 0 Then
|
|||
|
|
li.Add("取电服务", DevService)
|
|||
|
|
End If
|
|||
|
|
If Not IsNothing(T2) AndAlso T2.Count > 0 Then
|
|||
|
|
li.Add("执行条件状态", T2)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
kkdic = li
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
' 自定义比较器
|
|||
|
|
|
|||
|
|
|
|||
|
|
'设置树桩表数据
|
|||
|
|
Private Sub SetTreeStakeData(treenode As Dictionary(Of String, List(Of (String, String))))
|
|||
|
|
If IsNothing(treenode) OrElse treenode.Count = 0 Then Return
|
|||
|
|
TreeView1.Nodes.Clear()
|
|||
|
|
TreeView1.Nodes.Add(Grid_config.Cell(3, 2).Text)
|
|||
|
|
Dim timgs As String
|
|||
|
|
For Each item In treenode
|
|||
|
|
'
|
|||
|
|
Dim node As TreeNode = New TreeNode(item.Key)
|
|||
|
|
TreeView1.Nodes(0).Nodes.Add(node)
|
|||
|
|
For Each item1 In item.Value
|
|||
|
|
timgs = DateTime.Parse(item1.Item1).AddHours(8).ToString("yyyy-MM-dd HH:mm:ss")
|
|||
|
|
node.Nodes.Add(timgs & "|" & item1.Item2)
|
|||
|
|
Next
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
'修改图线别名
|
|||
|
|
Private Sub ChangeLineAlias(ByRef kkdic As Dictionary(Of String, Dictionary(Of String, Double)))
|
|||
|
|
If IsNothing(g_Macconfig) OrElse String.IsNullOrEmpty(g_Macconfig.Item1) OrElse IsNothing(g_Macconfig.Item2) OrElse g_Macconfig.Item2.Count = 0 OrElse IsNothing(kkdic) OrElse kkdic.Count = 0 Then Return
|
|||
|
|
If Grid_config.Cell(3, 2).Text.Trim.Equals(g_Macconfig.Item1) Then
|
|||
|
|
Dim kkdic1 As New Dictionary(Of String, Dictionary(Of String, Double))
|
|||
|
|
For Each item In kkdic
|
|||
|
|
If item.Key.Equals("T4") Then
|
|||
|
|
kkdic1.Add("有无人", kkdic.Item("T4"))
|
|||
|
|
ElseIf g_Macconfig.Item2.ContainsKey(item.Key) Then
|
|||
|
|
kkdic1.Add(g_Macconfig.Item2.Item(item.Key), kkdic.Item(item.Key))
|
|||
|
|
Else
|
|||
|
|
kkdic1.Add(item.Key, kkdic.Item(item.Key))
|
|||
|
|
End If
|
|||
|
|
Next
|
|||
|
|
kkdic = kkdic1
|
|||
|
|
Return
|
|||
|
|
Else
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Public Sub MysqlDataDispose()
|
|||
|
|
Dim selectstr As String = "SELECT * FROM `psmysql`.`deviceparsingdatalog` WHERE"
|
|||
|
|
Dim cstrpar As String = String.Empty
|
|||
|
|
Dim starttime, stoptime As DateTime
|
|||
|
|
Dim dtZone As DateTime = New DateTime(1970, 1, 1, 0, 0, 0)
|
|||
|
|
Try
|
|||
|
|
|
|||
|
|
starttime = DateTime.Parse(Grid_config.Cell(1, 2).Text.Trim)
|
|||
|
|
stoptime = DateTime.Parse(Grid_config.Cell(2, 2).Text.Trim)
|
|||
|
|
If IsNothing(starttime) OrElse IsNothing(stoptime) Then
|
|||
|
|
MsgBox($"数据查询失败!!!{vbCrLf }原因:{vbCrLf }日期输入错误")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
Catch ex As Exception
|
|||
|
|
MsgBox($"数据查询失败!!!{vbCrLf }原因:{vbCrLf }日期输入错误")
|
|||
|
|
Return
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
For i = 1 To Grid_config.Rows - 1
|
|||
|
|
If i = 1 Then
|
|||
|
|
selectstr = $"{selectstr}`DateTime`>='{starttime.Year }/{starttime.Month }/{starttime.Day } {starttime.Hour }:{starttime.Minute }:{starttime.Second }' And "
|
|||
|
|
ElseIf i = 2 Then
|
|||
|
|
selectstr = $"{selectstr}`DateTime`<='{stoptime.Year }/{stoptime.Month }/{stoptime.Day } {stoptime.Hour }:{stoptime.Minute }:{stoptime.Second }' And "
|
|||
|
|
ElseIf i = 3 Then
|
|||
|
|
cstrpar = $"{cstrpar}OR `DEV_NAME` = '{Grid_config.Cell(i, 2).Text.Trim}'{vbCrLf }"
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Next
|
|||
|
|
If Not String.IsNullOrEmpty(cstrpar) Then
|
|||
|
|
cstrpar = cstrpar.Remove(0, 2)
|
|||
|
|
selectstr = $"{selectstr}({cstrpar.Trim }) ORDER BY (`DateTime`) ASC"
|
|||
|
|
End If
|
|||
|
|
' Dim rowdic As Dictionary(Of String, Dictionary(Of String, String)) = New Dictionary(Of String, Dictionary(Of String, String))
|
|||
|
|
Dim colounmdic As Dictionary(Of String, Dictionary(Of String, Double)) = New Dictionary(Of String, Dictionary(Of String, Double))
|
|||
|
|
Dim dt As DataTable
|
|||
|
|
Dim rval As Double = 0
|
|||
|
|
Try
|
|||
|
|
|
|||
|
|
Using db As New DbExecutor(DbExecutor.DbTypeEnum.Mysql, GdbConnString)
|
|||
|
|
db.Open()
|
|||
|
|
dt = db.ExecuteDataTable(selectstr)
|
|||
|
|
If IsNothing(dt) OrElse dt.Rows.Count = 0 OrElse dt.Columns.Count = 0 Then
|
|||
|
|
MsgBox($"数据查询失败!!!{vbCrLf }原因:{vbCrLf }数据查询语句异常:{selectstr}")
|
|||
|
|
db.Close()
|
|||
|
|
Return
|
|||
|
|
Else
|
|||
|
|
|
|||
|
|
|
|||
|
|
Dim sqldate As Date
|
|||
|
|
Dim timse As String
|
|||
|
|
|
|||
|
|
For i = 0 To dt.Rows.Count - 1
|
|||
|
|
sqldate = Date.Parse(dt.Rows(i)("DateTime"))
|
|||
|
|
timse = $"{sqldate.Year }/{sqldate.Month }/{sqldate.Day } {sqldate.Hour }:{sqldate.Minute }:{sqldate.Second }"
|
|||
|
|
If i = 0 Then
|
|||
|
|
starttime = sqldate
|
|||
|
|
ElseIf i = dt.Rows.Count - 1 Then
|
|||
|
|
stoptime = sqldate
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
' Try
|
|||
|
|
'If i = 558 Then
|
|||
|
|
' Console.WriteLine(i)
|
|||
|
|
' End If
|
|||
|
|
If Not colounmdic.ContainsKey("Room_isExist") Then
|
|||
|
|
colounmdic.Add("Room_isExist", New Dictionary(Of String, Double))
|
|||
|
|
End If
|
|||
|
|
If IsDBNull(dt.Rows(i)("Room_isExist")) Then
|
|||
|
|
rval = 0
|
|||
|
|
Else
|
|||
|
|
Double.TryParse(dt.Rows(i)("Room_isExist"), rval)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
If colounmdic.Item("Room_isExist").ContainsKey(timse) Then
|
|||
|
|
colounmdic.Item("Room_isExist").Item(timse) = rval
|
|||
|
|
Else
|
|||
|
|
colounmdic.Item("Room_isExist").Add(timse, rval)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
If Not colounmdic.ContainsKey("isExist_Gol") Then
|
|||
|
|
colounmdic.Add("isExist_Gol", New Dictionary(Of String, Double))
|
|||
|
|
End If
|
|||
|
|
If IsDBNull(dt.Rows(i)("isExist_Gol")) Then
|
|||
|
|
rval = 0
|
|||
|
|
Else
|
|||
|
|
Double.TryParse(dt.Rows(i)("isExist_Gol"), rval)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
If colounmdic.Item("isExist_Gol").ContainsKey(timse) Then
|
|||
|
|
colounmdic.Item("isExist_Gol").Item(timse) = rval
|
|||
|
|
Else
|
|||
|
|
colounmdic.Item("isExist_Gol").Add(timse, rval)
|
|||
|
|
End If
|
|||
|
|
'Catch ex As Exception
|
|||
|
|
' Console.WriteLine(i)
|
|||
|
|
'End Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
' Try
|
|||
|
|
For j = 1 To 5
|
|||
|
|
selectstr = $"isExist_Area_{j}"
|
|||
|
|
cstrpar = $"isTrig_{j}"
|
|||
|
|
If Not colounmdic.ContainsKey(selectstr) Then
|
|||
|
|
colounmdic.Add(selectstr, New Dictionary(Of String, Double))
|
|||
|
|
End If
|
|||
|
|
'Double.TryParse(dt.Rows(i)(selectstr), rval)
|
|||
|
|
If IsDBNull(dt.Rows(i)(selectstr)) Then
|
|||
|
|
rval = 0
|
|||
|
|
Else
|
|||
|
|
Double.TryParse(dt.Rows(i)(selectstr), rval)
|
|||
|
|
End If
|
|||
|
|
If colounmdic.Item(selectstr).ContainsKey(timse) Then
|
|||
|
|
colounmdic.Item(selectstr).Item(timse) = rval
|
|||
|
|
Else
|
|||
|
|
colounmdic.Item(selectstr).Add(timse, rval)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
If Not colounmdic.ContainsKey(cstrpar) Then
|
|||
|
|
colounmdic.Add(cstrpar, New Dictionary(Of String, Double))
|
|||
|
|
End If
|
|||
|
|
If IsDBNull(dt.Rows(i)(cstrpar)) Then
|
|||
|
|
rval = 0
|
|||
|
|
Else
|
|||
|
|
Double.TryParse(dt.Rows(i)(cstrpar), rval)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
If colounmdic.Item(cstrpar).ContainsKey(timse) Then
|
|||
|
|
colounmdic.Item(cstrpar).Item(timse) = rval
|
|||
|
|
Else
|
|||
|
|
colounmdic.Item(cstrpar).Add(timse, rval)
|
|||
|
|
End If
|
|||
|
|
Next
|
|||
|
|
'Catch ex As Exception
|
|||
|
|
' Console.WriteLine(i)
|
|||
|
|
'End Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Using
|
|||
|
|
|
|||
|
|
InitPieChart(colounmdic, starttime, stoptime)
|
|||
|
|
|
|||
|
|
|
|||
|
|
Catch ex As Exception
|
|||
|
|
MsgBox($"数据查询失败!!!{vbCrLf }原因:{vbCrLf }{ex.Message }")
|
|||
|
|
Return
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Public Sub initGrid_Mysqldate(rowdic As Dictionary(Of String, Dictionary(Of String, String)))
|
|||
|
|
If IsNothing(rowdic) AndAlso rowdic.Count = 0 AndAlso (Not rowdic.ContainsKey("colounmdic")) Then
|
|||
|
|
MsgBox($"数据加载失败!!数据为空或未检测到列信息。")
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Dim starttime As Long = 0
|
|||
|
|
Dim stoptime As Long = 0
|
|||
|
|
Dim kkdic As Dictionary(Of String, Dictionary(Of Long, Double)) = New Dictionary(Of String, Dictionary(Of Long, Double))
|
|||
|
|
Dim colounmdic As Dictionary(Of String, String) = rowdic.Item("colounmdic")
|
|||
|
|
With Grid_Mysqldate
|
|||
|
|
.NewFile()
|
|||
|
|
.AutoRedraw = False
|
|||
|
|
.Cols = colounmdic.Count + 3
|
|||
|
|
.Rows = 1
|
|||
|
|
.DisplayRowNumber = True
|
|||
|
|
.Cell(0, 0).Text = "序号"
|
|||
|
|
.Cell(0, 1).Text = "时间"
|
|||
|
|
.Cell(0, 2).Text = "时间戳"
|
|||
|
|
.Column(0).Width = 20
|
|||
|
|
.Column(1).Width = 150
|
|||
|
|
.Column(1).Alignment = AlignmentEnum.CenterCenter
|
|||
|
|
|
|||
|
|
For i = 0 To colounmdic.Count - 1
|
|||
|
|
.Cell(0, i + 3).Text = colounmdic.Keys(i)
|
|||
|
|
.Column(i + 3).Alignment = AlignmentEnum.CenterCenter
|
|||
|
|
Next
|
|||
|
|
Dim dtOffset As New DateTimeOffset(New DateTime(1970, 1, 1), TimeSpan.Zero)
|
|||
|
|
' 获取本地日期和时间
|
|||
|
|
|
|||
|
|
|
|||
|
|
For Each node In rowdic
|
|||
|
|
If node.Key.Equals("colounmdic") Then Continue For
|
|||
|
|
.AddItem("")
|
|||
|
|
|
|||
|
|
Dim t As Long = Long.Parse(node.Key)
|
|||
|
|
t = t / 1000
|
|||
|
|
Dim yt As DateTime = (dtOffset + TimeSpan.FromSeconds(t)).LocalDateTime
|
|||
|
|
If starttime = 0 OrElse t < starttime Then
|
|||
|
|
starttime = t
|
|||
|
|
End If
|
|||
|
|
If stoptime = 0 OrElse t > stoptime Then
|
|||
|
|
stoptime = t
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
.Cell(.Rows - 1, 1).Text = yt.ToString("yyyy-MM-dd HH:mm:ss")
|
|||
|
|
.Cell(.Rows - 1, 2).Text = t.ToString
|
|||
|
|
For Each index In node.Value
|
|||
|
|
For j = 0 To colounmdic.Count - 1
|
|||
|
|
' 'Console.WriteLine(.Cell(0, j + 2).Text)
|
|||
|
|
If .Cell(0, j + 3).Text.Equals(index.Key) Then
|
|||
|
|
.Cell(.Rows - 1, j + 3).Text = index.Value
|
|||
|
|
End If
|
|||
|
|
Next
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
Dim datadic As Dictionary(Of Long, Double)
|
|||
|
|
If kkdic.ContainsKey(node.Value.Keys(0)) Then
|
|||
|
|
datadic = kkdic.Item(node.Value.Keys(0))
|
|||
|
|
If datadic.ContainsKey(t) Then
|
|||
|
|
datadic.Item(t) = CInt(node.Value.Values(0))
|
|||
|
|
Else
|
|||
|
|
datadic.Add(t, node.Value.Values(0))
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Else
|
|||
|
|
datadic = New Dictionary(Of Long, Double)
|
|||
|
|
datadic.Add(t, node.Value.Values(0))
|
|||
|
|
kkdic.Add(node.Value.Keys(0), datadic)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
End With
|
|||
|
|
Grid_Mysqldate.AutoRedraw = True
|
|||
|
|
Grid_Mysqldate.Refresh()
|
|||
|
|
|
|||
|
|
|
|||
|
|
InitPieChart(kkdic, starttime, stoptime)
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 初始化Chart控件
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub InitTeeChart(kkdic As Dictionary(Of String, Dictionary(Of Long, Double)), starttime As Long, stoptime As Long)
|
|||
|
|
ChartBar.AutoRepaint = False
|
|||
|
|
ChartBar.Header.Lines = New String() {""} 'TeeChart标题
|
|||
|
|
ChartBar.Panning.InsideBounds = True
|
|||
|
|
ChartBar.Panning.Allow = ScrollModes.Horizontal
|
|||
|
|
InitCustomAxies(kkdic, starttime, stoptime)
|
|||
|
|
InitFastLine(kkdic)
|
|||
|
|
InitCursor()
|
|||
|
|
ChartBar.AutoRepaint = True
|
|||
|
|
ChartBar.Refresh()
|
|||
|
|
End Sub
|
|||
|
|
Private Sub InitTeeChart(kkdic As Dictionary(Of String, Dictionary(Of String, Double)), starttime As Date, stoptime As Date)
|
|||
|
|
ChartBar.AutoRepaint = False
|
|||
|
|
ChartBar.Header.Lines = New String() {""} 'TeeChart标题
|
|||
|
|
ChartBar.Panning.InsideBounds = True
|
|||
|
|
ChartBar.Panning.Allow = ScrollModes.Horizontal
|
|||
|
|
InitCustomAxies(kkdic, starttime, stoptime)
|
|||
|
|
InitFastLine(kkdic)
|
|||
|
|
InitCursor()
|
|||
|
|
ChartBar.AutoRepaint = True
|
|||
|
|
ChartBar.Refresh()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 初始化轴
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub InitCustomAxies(kkdic As Dictionary(Of String, Dictionary(Of String, Double)), starttime As Date, stoptime As Date)
|
|||
|
|
|
|||
|
|
_axis.Clear()
|
|||
|
|
ChartBar.Axes.Custom.Clear()
|
|||
|
|
ChartBar.Walls.Visible = False '不显示立面(背景色将统一)
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Bottom.Title.Caption = "时间轴"
|
|||
|
|
ChartBar.Axes.Bottom.Title.Visible = False
|
|||
|
|
ChartBar.Axes.Bottom.MaximumOffset = 4 '最大值偏移
|
|||
|
|
ChartBar.Axes.Bottom.MinimumOffset = 4 '最小值偏移
|
|||
|
|
ChartBar.Axes.Bottom.Grid.Style = System.Drawing.Drawing2D.DashStyle.Dash
|
|||
|
|
ChartBar.Axes.Bottom.Grid.Width = 2
|
|||
|
|
ChartBar.Axes.Bottom.Ticks.Color = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
|
|||
|
|
ChartBar.Axes.Bottom.Ticks.Length = 4 '标记长度
|
|||
|
|
ChartBar.Axes.Bottom.Ticks.Width = 4 '标记宽度
|
|||
|
|
ChartBar.Axes.Bottom.Grid.Transparency = 60
|
|||
|
|
' _axis.Add(ChartBar.Axes.Bottom)
|
|||
|
|
ChartBar.Axes.Bottom.Automatic = True
|
|||
|
|
|
|||
|
|
Dim dtOffset As New DateTimeOffset(New DateTime(1970, 1, 1, 0, 0, 0))
|
|||
|
|
' 获取本地日期和时间
|
|||
|
|
Dim yt As DateTime
|
|||
|
|
yt = stoptime ' (dtOffset.AddSeconds(stoptime)).LocalDateTime
|
|||
|
|
ChartBar.Axes.Bottom.Maximum = yt.AddHours(8).ToOADate
|
|||
|
|
Dim bvtOffset As New DateTimeOffset(New DateTime(1970, 1, 1, 0, 0, 0))
|
|||
|
|
yt = starttime ' (dtOffset.AddSeconds(starttime)).LocalDateTime
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Bottom.Minimum = yt.AddHours(8).ToOADate
|
|||
|
|
' ChartBar.Axes.Bottom.Increment = 1
|
|||
|
|
ChartBar.Axes.Bottom.Logarithmic = False
|
|||
|
|
'ChartBar.Axes.Right.Title.Right = 20
|
|||
|
|
ChartBar.Axes.Bottom.Labels.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Left.Title.Caption = "电流-电压轴"
|
|||
|
|
ChartBar.Axes.Left.Title.Visible = False
|
|||
|
|
ChartBar.Axes.Left.MaximumOffset = 4 '最大值偏移
|
|||
|
|
ChartBar.Axes.Left.MinimumOffset = 1 '最小值偏移
|
|||
|
|
ChartBar.Axes.Left.Grid.Style = System.Drawing.Drawing2D.DashStyle.Dash
|
|||
|
|
ChartBar.Axes.Left.Grid.Width = 2
|
|||
|
|
ChartBar.Axes.Left.Ticks.Color = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
|
|||
|
|
ChartBar.Axes.Left.Ticks.Length = 2 '标记长度
|
|||
|
|
ChartBar.Axes.Left.Ticks.Width = 2 '标记宽度
|
|||
|
|
ChartBar.Axes.Left.Grid.Transparency = 60
|
|||
|
|
ChartBar.Axes.Left.Automatic = False
|
|||
|
|
ChartBar.Axes.Left.Minimum = 0.001
|
|||
|
|
ChartBar.Axes.Left.Maximum = 1000
|
|||
|
|
ChartBar.Axes.Left.Logarithmic = True
|
|||
|
|
|
|||
|
|
|
|||
|
|
For i = 0 To kkdic.Count - 1
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
'_axis.Add(ChartBar.Axes.Left)
|
|||
|
|
'Case Else 'IO
|
|||
|
|
Dim idx As Integer = i
|
|||
|
|
_axis.Add(New Steema.TeeChart.Axis)
|
|||
|
|
|
|||
|
|
_axis(i).Title.Caption = kkdic.Keys(i) '标题文本
|
|||
|
|
|
|||
|
|
_axis(i).Title.Font.Brush.Color = Color.GhostWhite
|
|||
|
|
|
|||
|
|
_axis(i).Title.Angle = 0 '标题角度
|
|||
|
|
_axis(i).AxisPen.Color = Color.FromArgb(255, idx * 12, 255 - idx * 10, idx * 6) '颜色
|
|||
|
|
_axis(i).OtherSide = True '右边显示
|
|||
|
|
|
|||
|
|
_axis(i).StartPosition = idx * 8.0R
|
|||
|
|
_axis(i).EndPosition = _axis(i).StartPosition + 4.0R
|
|||
|
|
_axis(i).Automatic = False
|
|||
|
|
_axis(i).Minimum = 0
|
|||
|
|
_axis(i).Maximum = 1
|
|||
|
|
_axis(i).Increment = 1.0R
|
|||
|
|
|
|||
|
|
If i = kkdic.Count - 1 Then
|
|||
|
|
_axis(i).Minimum = 0
|
|||
|
|
_axis(i).Maximum = 12
|
|||
|
|
_axis(i).Increment = 12.0R
|
|||
|
|
_axis(i).StartPosition = idx * 8.0R
|
|||
|
|
_axis(i).EndPosition = _axis(i).StartPosition + 10.0R
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
_axis(i).Grid.Visible = False
|
|||
|
|
_axis(i).Labels.Angle = 0 '角度
|
|||
|
|
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Custom.Add(_axis(i))
|
|||
|
|
'AddHandler _axis(i).GetAxisDrawLabel, AddressOf Axis_GetAxisDrawLabel
|
|||
|
|
|
|||
|
|
'End Select
|
|||
|
|
Next
|
|||
|
|
AddHandler ChartBar.ClickAxis, AddressOf Axis_GetAxisDrawLabel
|
|||
|
|
End Sub
|
|||
|
|
Private Sub Axis_GetAxisDrawLabel(sender As Object, e As MouseEventArgs)
|
|||
|
|
Dim enderAxis As Axis = sender
|
|||
|
|
Dim inputalstr As String = InputBox(enderAxis.Title.Caption, "请输入新的名称")
|
|||
|
|
If String.IsNullOrEmpty(inputalstr) Then Return
|
|||
|
|
enderAxis.Title.Caption = inputalstr
|
|||
|
|
End Sub
|
|||
|
|
''' <summary>
|
|||
|
|
''' 初始化轴
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub InitCustomAxies1(kkdic As Dictionary(Of String, Dictionary(Of String, Double)), starttime As Date, stoptime As Date)
|
|||
|
|
|
|||
|
|
_axis.Clear()
|
|||
|
|
ChartBar.Axes.Custom.Clear()
|
|||
|
|
ChartBar.Walls.Visible = False '不显示立面(背景色将统一)
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Bottom.Title.Caption = "时间轴"
|
|||
|
|
ChartBar.Axes.Bottom.Title.Visible = False
|
|||
|
|
ChartBar.Axes.Bottom.MaximumOffset = 4 '最大值偏移
|
|||
|
|
ChartBar.Axes.Bottom.MinimumOffset = 4 '最小值偏移
|
|||
|
|
ChartBar.Axes.Bottom.Grid.Style = System.Drawing.Drawing2D.DashStyle.Dash
|
|||
|
|
ChartBar.Axes.Bottom.Grid.Width = 2
|
|||
|
|
ChartBar.Axes.Bottom.Ticks.Color = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
|
|||
|
|
ChartBar.Axes.Bottom.Ticks.Length = 4 '标记长度
|
|||
|
|
ChartBar.Axes.Bottom.Ticks.Width = 4 '标记宽度
|
|||
|
|
ChartBar.Axes.Bottom.Grid.Transparency = 60
|
|||
|
|
' _axis.Add(ChartBar.Axes.Bottom)
|
|||
|
|
ChartBar.Axes.Bottom.Automatic = False
|
|||
|
|
|
|||
|
|
Dim dtOffset As New DateTimeOffset(New DateTime(1970, 1, 1, 0, 0, 0))
|
|||
|
|
' 获取本地日期和时间
|
|||
|
|
Dim yt As DateTime
|
|||
|
|
yt = stoptime ' (dtOffset.AddSeconds(stoptime)).LocalDateTime
|
|||
|
|
ChartBar.Axes.Bottom.Maximum = yt.ToOADate
|
|||
|
|
Dim bvtOffset As New DateTimeOffset(New DateTime(1970, 1, 1, 0, 0, 0))
|
|||
|
|
yt = starttime ' (dtOffset.AddSeconds(starttime)).LocalDateTime
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Bottom.Minimum = yt.ToOADate
|
|||
|
|
' ChartBar.Axes.Bottom.Increment = 1
|
|||
|
|
ChartBar.Axes.Bottom.Logarithmic = False
|
|||
|
|
'ChartBar.Axes.Right.Title.Right = 20
|
|||
|
|
ChartBar.Axes.Bottom.Labels.DateTimeFormat = "yyyy-MM-dd HH"
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Left.Title.Caption = "电流-电压轴"
|
|||
|
|
ChartBar.Axes.Left.Title.Visible = False
|
|||
|
|
ChartBar.Axes.Left.MaximumOffset = 4 '最大值偏移
|
|||
|
|
ChartBar.Axes.Left.MinimumOffset = 4 '最小值偏移
|
|||
|
|
ChartBar.Axes.Left.Grid.Style = System.Drawing.Drawing2D.DashStyle.Dash
|
|||
|
|
ChartBar.Axes.Left.Grid.Width = 2
|
|||
|
|
ChartBar.Axes.Left.Ticks.Color = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
|
|||
|
|
ChartBar.Axes.Left.Ticks.Length = 2 '标记长度
|
|||
|
|
ChartBar.Axes.Left.Ticks.Width = 2 '标记宽度
|
|||
|
|
ChartBar.Axes.Left.Grid.Transparency = 60
|
|||
|
|
ChartBar.Axes.Left.Automatic = False
|
|||
|
|
ChartBar.Axes.Left.Minimum = 0.001
|
|||
|
|
ChartBar.Axes.Left.Maximum = 1000
|
|||
|
|
ChartBar.Axes.Left.Logarithmic = True
|
|||
|
|
|
|||
|
|
|
|||
|
|
For i = 0 To kkdic.Count - 1
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
'_axis.Add(ChartBar.Axes.Left)
|
|||
|
|
'Case Else 'IO
|
|||
|
|
Dim idx As Integer = i
|
|||
|
|
_axis.Add(New Steema.TeeChart.Axis)
|
|||
|
|
_axis(i).Title.Caption = kkdic.Keys(i) '标题文本
|
|||
|
|
|
|||
|
|
_axis(i).Title.Font.Brush.Color = Color.GhostWhite
|
|||
|
|
|
|||
|
|
_axis(i).Title.Angle = 0 '标题角度
|
|||
|
|
_axis(i).AxisPen.Color = Color.FromArgb(255, idx * 12, 255 - idx * 10, idx * 6) '颜色
|
|||
|
|
_axis(i).OtherSide = True '右边显示
|
|||
|
|
|
|||
|
|
_axis(i).StartPosition = idx * 8.0R
|
|||
|
|
_axis(i).EndPosition = _axis(i).StartPosition + 4.0R
|
|||
|
|
_axis(i).Automatic = False
|
|||
|
|
_axis(i).Minimum = 0
|
|||
|
|
_axis(i).Maximum = 1
|
|||
|
|
_axis(i).Increment = 1.0R
|
|||
|
|
_axis(i).Grid.Visible = False
|
|||
|
|
_axis(i).Labels.Angle = 0 '角度
|
|||
|
|
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Custom.Add(_axis(i))
|
|||
|
|
|
|||
|
|
'End Select
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
Private Sub InitCustomAxies(kkdic As Dictionary(Of String, Dictionary(Of Long, Double)), starttime As Long, stoptime As Long)
|
|||
|
|
|
|||
|
|
_axis.Clear()
|
|||
|
|
ChartBar.Axes.Custom.Clear()
|
|||
|
|
ChartBar.Walls.Visible = False '不显示立面(背景色将统一)
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Bottom.Title.Caption = "时间轴"
|
|||
|
|
ChartBar.Axes.Bottom.Title.Visible = False
|
|||
|
|
ChartBar.Axes.Bottom.MaximumOffset = 4 '最大值偏移
|
|||
|
|
ChartBar.Axes.Bottom.MinimumOffset = 4 '最小值偏移
|
|||
|
|
ChartBar.Axes.Bottom.Grid.Style = System.Drawing.Drawing2D.DashStyle.Dash
|
|||
|
|
ChartBar.Axes.Bottom.Grid.Width = 2
|
|||
|
|
ChartBar.Axes.Bottom.Ticks.Color = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
|
|||
|
|
ChartBar.Axes.Bottom.Ticks.Length = 4 '标记长度
|
|||
|
|
ChartBar.Axes.Bottom.Ticks.Width = 4 '标记宽度
|
|||
|
|
ChartBar.Axes.Bottom.Grid.Transparency = 60
|
|||
|
|
' _axis.Add(ChartBar.Axes.Bottom)
|
|||
|
|
ChartBar.Axes.Bottom.Automatic = False
|
|||
|
|
|
|||
|
|
Dim dtOffset As New DateTimeOffset(New DateTime(1970, 1, 1, 0, 0, 0))
|
|||
|
|
' 获取本地日期和时间
|
|||
|
|
Dim yt As DateTime
|
|||
|
|
yt = (dtOffset.AddSeconds(stoptime)).LocalDateTime
|
|||
|
|
ChartBar.Axes.Bottom.Maximum = yt.ToOADate
|
|||
|
|
Dim bvtOffset As New DateTimeOffset(New DateTime(1970, 1, 1, 0, 0, 0))
|
|||
|
|
yt = (dtOffset.AddSeconds(starttime)).LocalDateTime
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Bottom.Minimum = yt.ToOADate
|
|||
|
|
' ChartBar.Axes.Bottom.Increment = 1
|
|||
|
|
ChartBar.Axes.Bottom.Logarithmic = False
|
|||
|
|
'ChartBar.Axes.Right.Title.Right = 20
|
|||
|
|
ChartBar.Axes.Bottom.Labels.DateTimeFormat = "yyyy-MM-dd HH"
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Left.Title.Caption = "电流-电压轴"
|
|||
|
|
ChartBar.Axes.Left.Title.Visible = False
|
|||
|
|
ChartBar.Axes.Left.MaximumOffset = 4 '最大值偏移
|
|||
|
|
ChartBar.Axes.Left.MinimumOffset = 4 '最小值偏移
|
|||
|
|
ChartBar.Axes.Left.Grid.Style = System.Drawing.Drawing2D.DashStyle.Dash
|
|||
|
|
ChartBar.Axes.Left.Grid.Width = 2
|
|||
|
|
ChartBar.Axes.Left.Ticks.Color = System.Drawing.Color.FromArgb(CType(CType(0, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(255, Byte), Integer))
|
|||
|
|
ChartBar.Axes.Left.Ticks.Length = 2 '标记长度
|
|||
|
|
ChartBar.Axes.Left.Ticks.Width = 2 '标记宽度
|
|||
|
|
ChartBar.Axes.Left.Grid.Transparency = 60
|
|||
|
|
ChartBar.Axes.Left.Automatic = False
|
|||
|
|
ChartBar.Axes.Left.Minimum = 0.001
|
|||
|
|
ChartBar.Axes.Left.Maximum = 1000
|
|||
|
|
ChartBar.Axes.Left.Logarithmic = True
|
|||
|
|
|
|||
|
|
|
|||
|
|
For i = 0 To kkdic.Count - 1
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
'_axis.Add(ChartBar.Axes.Left)
|
|||
|
|
'Case Else 'IO
|
|||
|
|
Dim idx As Integer = i
|
|||
|
|
_axis.Add(New Steema.TeeChart.Axis)
|
|||
|
|
_axis(i).Title.Caption = kkdic.Keys(i) '标题文本
|
|||
|
|
|
|||
|
|
_axis(i).Title.Font.Brush.Color = Color.GhostWhite
|
|||
|
|
|
|||
|
|
_axis(i).Title.Angle = 0 '标题角度
|
|||
|
|
_axis(i).AxisPen.Color = Color.FromArgb(255, idx * 12, 255 - idx * 10, idx * 6) '颜色
|
|||
|
|
_axis(i).OtherSide = True '右边显示
|
|||
|
|
|
|||
|
|
_axis(i).StartPosition = idx * 8.0R
|
|||
|
|
_axis(i).EndPosition = _axis(i).StartPosition + 4.0R
|
|||
|
|
_axis(i).Automatic = False
|
|||
|
|
_axis(i).Minimum = 0
|
|||
|
|
_axis(i).Maximum = 1
|
|||
|
|
_axis(i).Increment = 1.0R
|
|||
|
|
_axis(i).Grid.Visible = False
|
|||
|
|
_axis(i).Labels.Angle = 0 '角度
|
|||
|
|
|
|||
|
|
|
|||
|
|
ChartBar.Axes.Custom.Add(_axis(i))
|
|||
|
|
|
|||
|
|
'End Select
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
''' <summary>
|
|||
|
|
''' 初始化线
|
|||
|
|
''' </summary>
|
|||
|
|
Private Sub InitFastLine(kkdic As Dictionary(Of String, Dictionary(Of Long, Double)))
|
|||
|
|
ChartBar.Series.Clear()
|
|||
|
|
_fastLine.Clear()
|
|||
|
|
Dim namebuf() As String
|
|||
|
|
'namebuf = My.Settings.fastLineName.Split(",")
|
|||
|
|
For i = 0 To kkdic.Count - 1
|
|||
|
|
|
|||
|
|
_fastLine.Add(kkdic.Keys(i), New Steema.TeeChart.Styles.FastLine)
|
|||
|
|
AddHandler _fastLine.Item(kkdic.Keys(i)).Click, AddressOf FastLine1_Click
|
|||
|
|
' _fastLine(i).Title = $"电流{i}" ' FastLineTitle(i) '标题
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint
|
|||
|
|
ChartBar.Series.Add(_fastLine.Item(kkdic.Keys(i)))
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).XValues.DateTime = True
|
|||
|
|
'Select Case i
|
|||
|
|
' Case 0
|
|||
|
|
' _fastLine(i).Title = $"电流"
|
|||
|
|
' ' FastLine(i).CustomVertAxis = ChartBar.Axes.Left '绑定电流轴
|
|||
|
|
' _fastLine(i).Transparency = 0 '线条透明度
|
|||
|
|
' _fastLine(i).LinePen.Color = Color.FromArgb(255, 255, 0, 0) '线条颜色
|
|||
|
|
'
|
|||
|
|
' Case 1 To 5
|
|||
|
|
' If i = 1 Then
|
|||
|
|
' _fastLine(i).Title = $"电压"
|
|||
|
|
' Else
|
|||
|
|
' _fastLine(i).Title = $"CH{i - 1}"
|
|||
|
|
' End If
|
|||
|
|
|
|||
|
|
' ' _fastLine(i).Visible = False
|
|||
|
|
' ' _fastLine(i).CustomVertAxis = _axis(0) '绑定电压
|
|||
|
|
' _fastLine(i).Transparency = 75 '线条透明度
|
|||
|
|
' _fastLine(i).LinePen.Color = Color.FromArgb(126, 0, 0, 255) '线条颜色
|
|||
|
|
' _fastLine(i).Legend.Visible = True '不在图例中显示
|
|||
|
|
' Case Else
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).Title = $"{kkdic.Keys(i)}"
|
|||
|
|
'_fastLine(i).Legend.Visible = True '不在图例中显示
|
|||
|
|
' _fastLine.Item(kkdic.Keys(i)).Visible = False
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).Transparency = 0 '线条透明度
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).CustomVertAxis = _axis(i) '绑定IO轴
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).Stairs = True '线条阶梯状
|
|||
|
|
Dim random As New Random()
|
|||
|
|
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).LinePen.Color = Color.GhostWhite '线条颜色
|
|||
|
|
'_fastLine.Item(kkdic.Keys(i)).LinePen.Color = Color.Blue
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).LinePen.Width = 2
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).Legend.Visible = False '不在图例中显示
|
|||
|
|
' _fastLine(i).LinePen.Color = _axis(i - 5).Labels.Color
|
|||
|
|
'End Select
|
|||
|
|
' FastLine(i).LinePen.Color = Color.FromArgb(12, 12, 12, 12) '颜色
|
|||
|
|
' FastLine(i).ColorEach = False '各点之间颜色不一
|
|||
|
|
Next
|
|||
|
|
End Sub
|
|||
|
|
Private Sub InitFastLine(kkdic As Dictionary(Of String, Dictionary(Of String, Double)))
|
|||
|
|
ChartBar.Series.Clear()
|
|||
|
|
_fastLine.Clear()
|
|||
|
|
For i = 0 To kkdic.Count - 1
|
|||
|
|
_fastLine.Add(kkdic.Keys(i), New Steema.TeeChart.Styles.FastLine)
|
|||
|
|
AddHandler _fastLine.Item(kkdic.Keys(i)).Click, AddressOf FastLine1_Click
|
|||
|
|
|
|||
|
|
' _fastLine(i).Title = $"电流{i}" ' FastLineTitle(i) '标题
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).TreatNulls = Steema.TeeChart.Styles.TreatNullsStyle.DoNotPaint
|
|||
|
|
ChartBar.Series.Add(_fastLine.Item(kkdic.Keys(i)))
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).XValues.DateTime = True
|
|||
|
|
'Select Case i
|
|||
|
|
' Case 0
|
|||
|
|
' _fastLine(i).Title = $"电流"
|
|||
|
|
' ' FastLine(i).CustomVertAxis = ChartBar.Axes.Left '绑定电流轴
|
|||
|
|
' _fastLine(i).Transparency = 0 '线条透明度
|
|||
|
|
' _fastLine(i).LinePen.Color = Color.FromArgb(255, 255, 0, 0) '线条颜色
|
|||
|
|
'
|
|||
|
|
' Case 1 To 5
|
|||
|
|
' If i = 1 Then
|
|||
|
|
' _fastLine(i).Title = $"电压"
|
|||
|
|
' Else
|
|||
|
|
' _fastLine(i).Title = $"CH{i - 1}"
|
|||
|
|
' End If
|
|||
|
|
|
|||
|
|
' ' _fastLine(i).Visible = False
|
|||
|
|
' ' _fastLine(i).CustomVertAxis = _axis(0) '绑定电压
|
|||
|
|
' _fastLine(i).Transparency = 75 '线条透明度
|
|||
|
|
' _fastLine(i).LinePen.Color = Color.FromArgb(126, 0, 0, 255) '线条颜色
|
|||
|
|
' _fastLine(i).Legend.Visible = True '不在图例中显示
|
|||
|
|
' Case Else
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).Title = 1111 ' $"{kkdic.Keys(i)}"
|
|||
|
|
'_fastLine(i).Legend.Visible = True '不在图例中显示
|
|||
|
|
' _fastLine.Item(kkdic.Keys(i)).Visible = False
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).Transparency = 0 '线条透明度
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).CustomVertAxis = _axis(i) '绑定IO轴
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).Stairs = True '线条阶梯状
|
|||
|
|
Dim random As New Random()
|
|||
|
|
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).LinePen.Color = Color.GhostWhite '线条颜色
|
|||
|
|
'_fastLine.Item(kkdic.Keys(i)).LinePen.Color = Color.Blue
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).LinePen.Width = 2
|
|||
|
|
_fastLine.Item(kkdic.Keys(i)).Legend.Visible = False '不在图例中显示
|
|||
|
|
' _fastLine(i).LinePen.Color = _axis(i - 5).Labels.Color
|
|||
|
|
'End Select
|
|||
|
|
' FastLine(i).LinePen.Color = Color.FromArgb(12, 12, 12, 12) '颜色
|
|||
|
|
' FastLine(i).ColorEach = False '各点之间颜色不一
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
Private Sub InitCursor()
|
|||
|
|
ChartBar.Tools.Clear()
|
|||
|
|
For i = 0 To _curSor.Length - 1
|
|||
|
|
_curSor(i) = New Steema.TeeChart.Tools.CursorTool
|
|||
|
|
ChartBar.Tools.Add(_curSor(i))
|
|||
|
|
_curSor(i).Style = Steema.TeeChart.Tools.CursorToolStyles.Vertical
|
|||
|
|
_curSor(i).OriginalCursor = System.Windows.Forms.Cursors.Default
|
|||
|
|
_curSor(i).Pen.Style = System.Drawing.Drawing2D.DashStyle.Dot
|
|||
|
|
_curSor(i).Pen.Width = 2
|
|||
|
|
_curSor(i).Tag = i
|
|||
|
|
'_curSor(i).Series = _fastLine.Item("执行条件状态")
|
|||
|
|
_curSor(i).Active = True
|
|||
|
|
_curSor(i).FollowMouse = False
|
|||
|
|
'_curSor(i).Pen.Visible = False
|
|||
|
|
_curSor(i).Pen.Visible = True
|
|||
|
|
'_curSor(i).Chart.ShowCoord
|
|||
|
|
'_curSor(i).ValueFormat = "X: {X}, Y: {Y}"
|
|||
|
|
Dim cursorTool As New Steema.TeeChart.Tools.CursorTool()
|
|||
|
|
|
|||
|
|
AddHandler _curSor(i).Change, AddressOf CursorChange
|
|||
|
|
Select Case i
|
|||
|
|
Case 0
|
|||
|
|
_curSor(i).Pen.Color = System.Drawing.Color.OrangeRed
|
|||
|
|
Case 1
|
|||
|
|
_curSor(i).Pen.Color = System.Drawing.Color.Green
|
|||
|
|
Case 2
|
|||
|
|
_curSor(i).Pen.Color = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(128, Byte), Integer), CType(CType(255, Byte), Integer))
|
|||
|
|
End Select
|
|||
|
|
Next
|
|||
|
|
End Sub
|
|||
|
|
''' <summary>
|
|||
|
|
''' 光标位置改变触发事件
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="sender"></param>
|
|||
|
|
''' <param name="e"></param>
|
|||
|
|
Private Sub CursorChange(sender As Object, e As Steema.TeeChart.Tools.CursorChangeEventArgs)
|
|||
|
|
Dim index As Integer = sender.tag
|
|||
|
|
CursorChangeDataDisplay(index)
|
|||
|
|
End Sub
|
|||
|
|
''' <summary>
|
|||
|
|
''' 光标移动显示数据
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="index">当前移动的是第几个光标</param>
|
|||
|
|
Private Sub CursorChangeDataDisplay(index As Integer)
|
|||
|
|
|
|||
|
|
Dim X1 As Double = 0
|
|||
|
|
Dim X2 As Double = 0
|
|||
|
|
Dim dtOffset As New DateTimeOffset(New DateTime(1900, 1, 1), TimeSpan.Zero)
|
|||
|
|
Dim Nx As Double = 0
|
|||
|
|
' 获取本地日期和时间
|
|||
|
|
Dim yt As DateTime
|
|||
|
|
Dim ts As TimeSpan
|
|||
|
|
Select Case index
|
|||
|
|
Case 0
|
|||
|
|
X1 = _curSor(index).XValue.ToString("#0.00000")
|
|||
|
|
yt = DateTime.FromOADate(X1)
|
|||
|
|
|
|||
|
|
Nx = X1
|
|||
|
|
'Console.WriteLine($"CursorChangeDataDisplay:X1 {X1}:{yt.ToString("yyyy-MM-dd HH:mm:ss")}")
|
|||
|
|
'yt = (dtOffset + TimeSpan.FromDays(X1)).LocalDateTime
|
|||
|
|
'yt = yt + TimeSpan.FromHours(8)
|
|||
|
|
labY1.Text = yt.ToString("dd HH:mm:ss")
|
|||
|
|
ts = New TimeSpan(yt.Ticks)
|
|||
|
|
labY1.Tag = ts.TotalSeconds
|
|||
|
|
Case 1
|
|||
|
|
X2 = _curSor(index).XValue.ToString("#0.00000")
|
|||
|
|
yt = DateTime.FromOADate(X2)
|
|||
|
|
Nx = X2
|
|||
|
|
'yt = yt + TimeSpan.FromHours(8)
|
|||
|
|
labY2.Text = yt.ToString("dd HH:mm:ss")
|
|||
|
|
'Console.WriteLine($"CursorChangeDataDisplay:X2 {X2}:{yt.ToString("yyyy-MM-dd HH:mm:ss")}")
|
|||
|
|
ts = New TimeSpan(yt.Ticks)
|
|||
|
|
labY2.Tag = ts.TotalSeconds
|
|||
|
|
End Select
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Double.TryParse(labY1.Tag, X1)
|
|||
|
|
Double.TryParse(labY2.Tag, X2)
|
|||
|
|
|
|||
|
|
Dim couinm As Double = X2 - X1
|
|||
|
|
lab1_2.Text = ""
|
|||
|
|
If couinm < 0 Then
|
|||
|
|
lab1_2.Text = " - "
|
|||
|
|
End If
|
|||
|
|
';'Console.WriteLine($"CursorChangeDataDisplay:{ _curSor(index).XValue.ToString("#0.00")}|{_curSor(index).XValue.ToString("#0.00")}|{couinm}")
|
|||
|
|
Dim timeval As TimeSpan = TimeSpan.FromSeconds(Math.Abs(couinm))
|
|||
|
|
' 'Console.WriteLine(couinm)
|
|||
|
|
If timeval.Days > 0 Then
|
|||
|
|
lab1_2.Text = $"{ lab1_2.Text}{timeval.Days }天 "
|
|||
|
|
End If
|
|||
|
|
lab1_2.Text = $"{ lab1_2.Text}{timeval.Hours }:{timeval.Minutes }:{timeval.Seconds }"
|
|||
|
|
|
|||
|
|
'SetSelectNode(yt)
|
|||
|
|
|
|||
|
|
'获取
|
|||
|
|
';Dim e = ChartBar.PointToScreen(New System.Drawing.Point(_curSor(index).XValue, _curSor(index).YValue))
|
|||
|
|
'Dim fl = _fastLine.Item("执行条件状态")
|
|||
|
|
'Dim cupos = _curSor(index).Chart.Animations
|
|||
|
|
''获取鼠标的 x 和 y 坐标
|
|||
|
|
'Dim x As Integer = e.X
|
|||
|
|
'Dim y As Integer = e.Y
|
|||
|
|
|
|||
|
|
|
|||
|
|
''使用 TeeChart 的 Chart 方法来转换坐标
|
|||
|
|
|
|||
|
|
'Dim chartX As Double = fl.XValues(x)
|
|||
|
|
''Double chartY = FastLine1.Chart.GetChartYValue(y);
|
|||
|
|
'Dim chartY As Double = fl.YValues(y)
|
|||
|
|
'fl.Chart.CalcClickedPart(New System.Drawing.Point(_curSor(index).XValue, _curSor(index).YValue))
|
|||
|
|
|
|||
|
|
'fl.ClickTolerance
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
' 设置选择节点
|
|||
|
|
Private Sub SetSelectNode(yt As DateTime)
|
|||
|
|
If IsNothing(TreeView1) OrElse TreeView1.Nodes.Count = 0 Then Return
|
|||
|
|
Dim node As TreeNode = TreeView1.Nodes(0)
|
|||
|
|
Dim datetime As Date
|
|||
|
|
Dim bbuf() As String
|
|||
|
|
Dim nstr As String
|
|||
|
|
For Each childNode As TreeNode In node.Nodes
|
|||
|
|
bbuf = childNode.Text.Split(".")
|
|||
|
|
nstr = bbuf(1).Substring(4)
|
|||
|
|
datetime = DateTime.ParseExact(nstr, "yyyy-MM-dd HH:mm:ss", Nothing)
|
|||
|
|
If datetime > yt Then
|
|||
|
|
For Each childNode2 As TreeNode In childNode.Nodes
|
|||
|
|
bbuf = childNode2.Text.Split("|")
|
|||
|
|
nstr = bbuf(0)
|
|||
|
|
datetime = DateTime.ParseExact(nstr, "yyyy-MM-dd HH:mm:ss", Nothing)
|
|||
|
|
If datetime <= yt Then
|
|||
|
|
TreeView1.SelectedNode = childNode2
|
|||
|
|
TreeView1.Select()
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
Next
|
|||
|
|
End If
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Private _curTool As Steema.TeeChart.Tools.CursorTool
|
|||
|
|
Private Sub ChartBar_MouseDoubleClick(sender As Object, e As MouseEventArgs) Handles ChartBar.MouseDoubleClick
|
|||
|
|
If e.Button = MouseButtons.Middle Then
|
|||
|
|
ChartBar.Zoom.Undo()
|
|||
|
|
ElseIf e.Button = MouseButtons.Left Then
|
|||
|
|
Dim idx As Integer
|
|||
|
|
Dim row As Integer
|
|||
|
|
|
|||
|
|
If _curTool Is Nothing Then
|
|||
|
|
idx = 0
|
|||
|
|
_curTool = _curSor(idx)
|
|||
|
|
_curTool.FollowMouse = True
|
|||
|
|
'row = _rowChart.Cursor + idx * (EnCursor.Width + 2) + 1 + EnCursor.FollowMouse + 1
|
|||
|
|
'GrdChartInfo.Cell(row, EnGridCol.Value).Text = $"1"
|
|||
|
|
|
|||
|
|
Else
|
|||
|
|
If _curTool.FollowMouse = False Then
|
|||
|
|
idx = _curTool.Tag
|
|||
|
|
' row = _rowChart.Cursor + idx * (EnCursor.Width + 2) + 1 + EnCursor.FollowMouse + 1
|
|||
|
|
'_isUserChange = False
|
|||
|
|
_curTool.FollowMouse = False
|
|||
|
|
'GrdChartInfo.Cell(row, EnGridCol.Value).Text = $"0"
|
|||
|
|
|
|||
|
|
idx += 1
|
|||
|
|
If idx >= _curSor.Length Then
|
|||
|
|
idx = 0
|
|||
|
|
_curTool = _curSor(idx)
|
|||
|
|
_curTool.FollowMouse = True
|
|||
|
|
Else
|
|||
|
|
_curTool = _curSor(idx)
|
|||
|
|
_curTool.FollowMouse = True
|
|||
|
|
' row = _rowChart.Cursor + idx * (EnCursor.Width + 2) + 1 + EnCursor.FollowMouse + 1
|
|||
|
|
'GrdChartInfo.Cell(row, EnGridCol.Value).Text = $"1"
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
'_isUserChange = True
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Private Sub ChartBar_MouseClick(sender As Object, e As MouseEventArgs) Handles ChartBar.MouseClick
|
|||
|
|
If e.Button = MouseButtons.Middle Then
|
|||
|
|
|
|||
|
|
ChartBar.Zoom.Undo()
|
|||
|
|
ElseIf e.Button = MouseButtons.Right Then
|
|||
|
|
If IsNothing(_curTool) Then Return
|
|||
|
|
_curTool.FollowMouse = False
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub FastLine1_Click(sender As Object, e As MouseEventArgs)
|
|||
|
|
Dim fl As Styles.FastLine = sender
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
'For Each node In _fastLine
|
|||
|
|
' If node.Value.Title.Equals(fl.Title) Then
|
|||
|
|
' fl = node.Value
|
|||
|
|
' Dim x1 As Double = 0
|
|||
|
|
' labdevanme.Text = fl.Title
|
|||
|
|
' ''Console.WriteLine($"{e.X} {fl.YValues.Value(e.X).ToString("#0.0.")} {e.Y} {fl.YValues.Value(e.Y).ToString("#0.00")}")
|
|||
|
|
' Dim intcv As Integer = CInt(Math.Round(ChartBar.Series(0).YScreenToValue(e.Y)))
|
|||
|
|
' labval.Text = intcv.ToString
|
|||
|
|
|
|||
|
|
|
|||
|
|
' 'Console.WriteLine(fl.XValues.Value.Length)
|
|||
|
|
' x1 = ChartBar.Series(0).XScreenToValue(e.X)
|
|||
|
|
' Dim stra As String = fl.XValues.AsDateTime(e.X)
|
|||
|
|
|
|||
|
|
|
|||
|
|
' Dim dtOffset As New DateTimeOffset(New DateTime(1970, 1, 1), TimeSpan.Zero)
|
|||
|
|
' ' 获取本地日期和时间
|
|||
|
|
' Dim yt As DateTime
|
|||
|
|
' yt = DateTime.FromOADate(x1)
|
|||
|
|
' yt = yt + TimeSpan.FromHours(8)
|
|||
|
|
' 'Console.WriteLine($"FastLine1_Click:{x1}:{ yt.ToString("yyyy-MM-dd HH:mm:ss")}")
|
|||
|
|
' labDate.Text = yt.ToString("yyyy-MM-dd HH:mm:ss")
|
|||
|
|
|
|||
|
|
' End If
|
|||
|
|
'Next
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Private Sub Grid_config_ComboDropDown(Sender As Object, e As Grid.ComboDropDownEventArgs)
|
|||
|
|
Grid_config.ComboBox(0).Items.Clear()
|
|||
|
|
If IsNothing(devnamedic) OrElse devnamedic.Count = 0 Then Return
|
|||
|
|
Grid_config.ComboBox(0).Items.AddRange(devnamedic.ToArray)
|
|||
|
|
End Sub
|
|||
|
|
Public filequeue As Queue
|
|||
|
|
Private Sub ToolStripButton6_Click(sender As Object, e As EventArgs) Handles ToolStripButton6.Click
|
|||
|
|
If String.IsNullOrEmpty(Label1.Text) Then
|
|||
|
|
MsgBox("未选择日志目录")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
If Not IO.Directory.Exists(Label1.Text) Then
|
|||
|
|
MsgBox("日志目录不存在")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Dim filrpath As String = Grid_config.Cell(3, 2).Text.Trim
|
|||
|
|
If String.IsNullOrEmpty(filrpath) Then
|
|||
|
|
MsgBox("目标机型为空")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
Dim mubdir As String = $"{Label1.Text}\{filrpath}"
|
|||
|
|
If Not IO.Directory.Exists(mubdir) Then
|
|||
|
|
MsgBox("目标机型目录不存在")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
Dim TFTPNew() As String
|
|||
|
|
|
|||
|
|
|
|||
|
|
IO.Directory.CreateDirectory($"{Label1.Text}\ParsingLog\{filrpath}")
|
|||
|
|
Dim ParsingLog As String = $"{Label1.Text}\ParsingLog\{filrpath}"
|
|||
|
|
Dim filename() As String = IO.Directory.GetFiles(mubdir)
|
|||
|
|
Dim starttime As Date
|
|||
|
|
Dim stoptime As Date
|
|||
|
|
filequeue = New Queue
|
|||
|
|
Dim filgtime As Date
|
|||
|
|
If String.IsNullOrEmpty(Grid_config.Cell(1, 2).Text.Trim) OrElse String.IsNullOrEmpty(Grid_config.Cell(2, 2).Text.Trim) Then
|
|||
|
|
MsgBox("开始时间或结束时间为空")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
Date.TryParse(Grid_config.Cell(1, 2).Text.Trim, starttime)
|
|||
|
|
Date.TryParse(Grid_config.Cell(2, 2).Text.Trim, stoptime)
|
|||
|
|
If IsNothing(starttime) OrElse IsNothing(stoptime) OrElse (starttime > stoptime) Then
|
|||
|
|
MsgBox("开始时间或结束时间异常")
|
|||
|
|
Return
|
|||
|
|
End If
|
|||
|
|
Dim filenamebuff() As String
|
|||
|
|
Dim tstr As String = "yyMMddHHmmss" ' 对应的格式
|
|||
|
|
|
|||
|
|
ProgressBar2.Maximum = filename.Length
|
|||
|
|
ProgressBar2.Minimum = 0
|
|||
|
|
|
|||
|
|
If IO.Directory.Exists($"C:\TFTP-New\") Then
|
|||
|
|
TFTPNew = IO.Directory.GetFiles("C:\TFTP-New\")
|
|||
|
|
If TFTPNew.Length > 0 Then
|
|||
|
|
For Each node In TFTPNew
|
|||
|
|
'判断文件名称是否包含目标机型
|
|||
|
|
If node.Contains(filrpath) Then
|
|||
|
|
' 判断文件创建时间是否在10分钟之前
|
|||
|
|
If (DateTime.Now - IO.File.GetCreationTime(node)).TotalMinutes > 10 Then
|
|||
|
|
'将文件移动到日志目录的对应机型文件夹
|
|||
|
|
If IO.File.Exists($"{Label1.Text}\{filrpath}") Then
|
|||
|
|
|
|||
|
|
Else
|
|||
|
|
Try
|
|||
|
|
IO.File.Move(node, $"{Label1.Text}\{filrpath}{node.Substring(node.LastIndexOf("\"))}")
|
|||
|
|
|
|||
|
|
Catch ex As Exception
|
|||
|
|
MsgBox($"{Label1.Text}\{filrpath}{node.Substring(node.LastIndexOf("\"))}")
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
Next
|
|||
|
|
End If
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
For i = 0 To filename.Length - 1
|
|||
|
|
Dim node As String = filename(i)
|
|||
|
|
Dim index As String = node.Substring(node.LastIndexOf("\") + 1)
|
|||
|
|
filenamebuff = index.Split("_")
|
|||
|
|
filenamebuff = filenamebuff(filenamebuff.Length - 1).Split(".")
|
|||
|
|
Try
|
|||
|
|
filgtime = DateTime.ParseExact(filenamebuff(0), tstr, CultureInfo.InvariantCulture)
|
|||
|
|
|
|||
|
|
If starttime <= filgtime AndAlso filgtime <= stoptime Then
|
|||
|
|
'ProgressBar2.Value = i
|
|||
|
|
'Label2.Text = i Mod filename.Length
|
|||
|
|
filequeue.Enqueue($"{ParsingLog}\{index}")
|
|||
|
|
IO.File.Copy($"{mubdir}\{index}", $"{ParsingLog}\{index}")
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Catch ex As Exception
|
|||
|
|
Continue For
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
Next
|
|||
|
|
'ProgressBar2.Value = filename.Length
|
|||
|
|
'Label2.Text = "解析完成"
|
|||
|
|
ClearDeviceform($"{ParsingLog}\Tftp_Log.db", "Tftp_Log")
|
|||
|
|
StartParsinglog(filequeue, $"{ParsingLog}\Tftp_Log.db")
|
|||
|
|
' Label2.ForeColor = Color.DarkGreen
|
|||
|
|
End Sub
|
|||
|
|
Public threadli As List(Of Thread)
|
|||
|
|
Public Sub StartParsinglog(fileli As Queue, dbpath As String)
|
|||
|
|
If IsNothing(threadli) Then threadli = New List(Of Thread)
|
|||
|
|
For Each node In threadli
|
|||
|
|
node.Abort()
|
|||
|
|
Next
|
|||
|
|
threadli.Clear()
|
|||
|
|
For i = 1 To 1
|
|||
|
|
|
|||
|
|
Dim t As New Thread(Sub() ParsinglogThreadRuning(fileli, dbpath))
|
|||
|
|
t.SetApartmentState(Threading.ApartmentState.STA)
|
|||
|
|
t.IsBackground = True
|
|||
|
|
threadli.Add(t)
|
|||
|
|
t.Start()
|
|||
|
|
Next
|
|||
|
|
End Sub
|
|||
|
|
Public Sub ParsinglogThreadRuning(fileli As Queue, dbpath As String)
|
|||
|
|
Dim nct As Integer = fileli.Count
|
|||
|
|
While fileli.Count > 0
|
|||
|
|
|
|||
|
|
Dim filename As String = fileli.Dequeue
|
|||
|
|
SetUIProgressBar1(nct - fileli.Count)
|
|||
|
|
GetFileInfoList(filename, dbpath) '解析文件
|
|||
|
|
|
|||
|
|
'数据入库
|
|||
|
|
End While
|
|||
|
|
SetUIProgressBar1(ProgressBar2.Maximum)
|
|||
|
|
End Sub
|
|||
|
|
Delegate Sub delegate_MatchingInfo_Change(berval As Integer)
|
|||
|
|
|
|||
|
|
Public Sub SetUIProgressBar1(berval As Integer)
|
|||
|
|
If InvokeRequired = True Then
|
|||
|
|
Dim dev As New delegate_MatchingInfo_Change(AddressOf SetUIProgressBar1)
|
|||
|
|
Me.Invoke(dev, berval)
|
|||
|
|
Else
|
|||
|
|
ProgressBar2.Value = berval
|
|||
|
|
If ProgressBar2.Value = ProgressBar2.Maximum Then
|
|||
|
|
Label2.Text = "解析完成"
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 解析文件内容
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="datFile"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Private Function GetFileInfoList(filename As String, dbpath As String) As Boolean
|
|||
|
|
Dim result As Boolean = True
|
|||
|
|
'确认文件是否存在
|
|||
|
|
|
|||
|
|
|
|||
|
|
'读取文件内容
|
|||
|
|
Dim file_data As Byte() = My.Computer.FileSystem.ReadAllBytes(filename)
|
|||
|
|
Dim sampleArr_len As UInt32 = file_data.Length
|
|||
|
|
Dim sampleArr_showlen As UInt32 = 0
|
|||
|
|
Dim data_len As UInt16
|
|||
|
|
Dim data_end As Byte
|
|||
|
|
Dim fileInfoList As New List(Of LogDataInfoStruct) '读取文件内容保存在此变量
|
|||
|
|
Dim Addnode As LogDataInfoStruct
|
|||
|
|
|
|||
|
|
'解析文件名,获取MAC、酒店id、房号、生成日期等信息
|
|||
|
|
Dim tmpFileNameInfo As fileNameInfoStruct = GetFileNameInfo(filename)
|
|||
|
|
'Try
|
|||
|
|
While sampleArr_showlen < sampleArr_len
|
|||
|
|
If file_data(sampleArr_showlen) = &HA5 And sampleArr_showlen + 3 < sampleArr_len Then '判断文件头
|
|||
|
|
data_len = file_data(sampleArr_showlen + LOG_DATA_FORMAT.Len) Or (file_data(sampleArr_showlen + LOG_DATA_FORMAT.Len_8) << 8) '读取数据长度
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
If data_len < Log_Data_Len_Max And sampleArr_showlen + data_len - 1 < file_data.Length Then
|
|||
|
|
data_end = file_data(sampleArr_showlen + data_len - 1)
|
|||
|
|
'Console.WriteLine($"Data Len :{data_len:d} Data :{data_end:X}")
|
|||
|
|
If sampleArr_showlen + data_len <= sampleArr_len AndAlso file_data(sampleArr_showlen + data_len - 1) = &H5A Then '判断文件尾
|
|||
|
|
|
|||
|
|
Dim data_buff(data_len - 1) As Byte
|
|||
|
|
' Dim data_string As String
|
|||
|
|
|
|||
|
|
Array.Copy(file_data, sampleArr_showlen, data_buff, 0, data_len)
|
|||
|
|
sampleArr_showlen += data_len '数据偏移
|
|||
|
|
If GetSumCheckMod(data_buff, data_len) = &H0 Then
|
|||
|
|
'Console.WriteLine("Data Check Succ !\r\n")
|
|||
|
|
|
|||
|
|
'Parsing_a_piece_of_data(data_buff, show_form, DataGridView1)
|
|||
|
|
|
|||
|
|
' data_list.Add(data_buff) '保存一份数据,添加到列表中
|
|||
|
|
|
|||
|
|
If fileInfoList.Count = 0 Then
|
|||
|
|
Addnode = File_Data_Parsing_To_Iten(tmpFileNameInfo, data_buff, Nothing)
|
|||
|
|
Else
|
|||
|
|
Addnode = File_Data_Parsing_To_Iten(tmpFileNameInfo, data_buff, fileInfoList.Item(fileInfoList.Count - 1))
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
fileInfoList.Add(Addnode)
|
|||
|
|
'data_string = BitConverter.ToString(data_buff)
|
|||
|
|
'data_string = data_string.Replace("-", " ")
|
|||
|
|
'Console.WriteLine(data_string)
|
|||
|
|
Else
|
|||
|
|
' AnalysisLog("Data Check Fail !\r\n")
|
|||
|
|
Console.WriteLine("Data Check Fail !\r\n")
|
|||
|
|
End If
|
|||
|
|
Else
|
|||
|
|
sampleArr_showlen += 1
|
|||
|
|
' AnalysisLog("Data Len Fail!!! Now Len:" & sampleArr_showlen)
|
|||
|
|
Console.WriteLine("Data Len Fail!!! Now Len:" & sampleArr_showlen)
|
|||
|
|
result = False
|
|||
|
|
End If
|
|||
|
|
Else
|
|||
|
|
sampleArr_showlen += 1
|
|||
|
|
'AnalysisLog("Data Len Fail!!! Now Len:" & sampleArr_showlen)
|
|||
|
|
result = False
|
|||
|
|
Console.WriteLine("Data Len Error!!! " & sampleArr_showlen)
|
|||
|
|
End If
|
|||
|
|
Else
|
|||
|
|
sampleArr_showlen += 1
|
|||
|
|
result = False
|
|||
|
|
End If
|
|||
|
|
'delay(1)
|
|||
|
|
'Application.DoEvents()
|
|||
|
|
End While
|
|||
|
|
'RaiseEvent Fileschedule(sampleArr_len, True)
|
|||
|
|
'Catch ex As Exception
|
|||
|
|
' AdminLog.ApplicationLog.WriteErrorLog(ex)
|
|||
|
|
'End Try
|
|||
|
|
|
|||
|
|
'数据添加到列表
|
|||
|
|
' fileInfoList = File_Data_Parsing_To_List(datFileName, data_list)
|
|||
|
|
|
|||
|
|
interpositionTfTpData(fileInfoList, dbpath)
|
|||
|
|
Return result
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
Public Sub interpositionTfTpData(fileInfoList As List(Of LogDataInfoStruct), dbpath As String)
|
|||
|
|
Dim selectstr As String = String.Empty
|
|||
|
|
Dim Insert As String
|
|||
|
|
Dim localDateTimeString As String ' 本地时间日期字符串
|
|||
|
|
Dim format As String = "yyyy-MM-dd HH:mm:ss" ' 根据您的字符串格式调整
|
|||
|
|
|
|||
|
|
' 解析字符串为DateTime对象
|
|||
|
|
Dim localDateTime As DateTime
|
|||
|
|
|
|||
|
|
' 将DateTime对象的种类指定为UTC
|
|||
|
|
Dim utcDateTime As DateTime
|
|||
|
|
|
|||
|
|
For Each node In fileInfoList
|
|||
|
|
|
|||
|
|
Select Case node.Log_Type
|
|||
|
|
Case 7
|
|||
|
|
|
|||
|
|
|
|||
|
|
For Each index In node.parsing
|
|||
|
|
|
|||
|
|
If IsNothing(index) Then Continue For
|
|||
|
|
localDateTimeString = $"20{node.Log_DateTime.year}-{node.Log_DateTime.month.ToString.PadLeft(2, "0") }-{node.Log_DateTime.day.ToString.PadLeft(2, "0") } {node.Log_DateTime.hour.ToString.PadLeft(2, "0") }:{node.Log_DateTime.minute.ToString.PadLeft(2, "0") }:{node.Log_DateTime.second.ToString.PadLeft(2, "0") }"
|
|||
|
|
If DateTime.TryParse(localDateTimeString, localDateTime) Then
|
|||
|
|
Else
|
|||
|
|
Console.WriteLine(localDateTimeString)
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
utcDateTime = DateTime.SpecifyKind(localDateTime, DateTimeKind.Utc)
|
|||
|
|
If index.Contains("VCLog:T1") Then
|
|||
|
|
Dim sbuf() As String = index.Split(":")
|
|||
|
|
Insert = $"INSERT INTO [Tftp_Log]
|
|||
|
|
([FileName]
|
|||
|
|
,[CreateFileTime]
|
|||
|
|
,[Datastr]
|
|||
|
|
,[DevName]
|
|||
|
|
,[T1]
|
|||
|
|
,[loop]
|
|||
|
|
,[Datatime])
|
|||
|
|
VALUES
|
|||
|
|
('{node.LogFileName }','{node.CreateDateTime}','{index}','{node.MAC }'
|
|||
|
|
,'{sbuf(3)}'
|
|||
|
|
,'{sbuf(2)}'
|
|||
|
|
,'{localDateTime.ToUniversalTime.Ticks }');{vbCrLf }"
|
|||
|
|
selectstr = $"{selectstr}{Insert}"
|
|||
|
|
ElseIf index.Contains("VCLog:T3") Then
|
|||
|
|
Dim sbuf() As String = index.Split(":")
|
|||
|
|
Insert = $"INSERT INTO [Tftp_Log]
|
|||
|
|
([FileName]
|
|||
|
|
,[CreateFileTime]
|
|||
|
|
,[Datastr]
|
|||
|
|
,[DevName]
|
|||
|
|
,[T3]
|
|||
|
|
,[loop]
|
|||
|
|
,[Datatime])
|
|||
|
|
VALUES
|
|||
|
|
('{node.LogFileName }','{node.CreateDateTime}','{index}','{node.MAC }'
|
|||
|
|
,'{sbuf(3)}'
|
|||
|
|
,'{sbuf(2)}'
|
|||
|
|
,'{localDateTime.ToUniversalTime.Ticks }');{vbCrLf }"
|
|||
|
|
selectstr = $"{selectstr}{Insert}"
|
|||
|
|
ElseIf index.Contains("VCLog:T5") Then
|
|||
|
|
Dim sbuf() As String = index.Split(":")
|
|||
|
|
Insert = $"INSERT INTO [Tftp_Log]
|
|||
|
|
([FileName]
|
|||
|
|
,[CreateFileTime]
|
|||
|
|
,[Datastr]
|
|||
|
|
,[DevName]
|
|||
|
|
,[T5]
|
|||
|
|
,[Datatime])
|
|||
|
|
VALUES
|
|||
|
|
('{node.LogFileName }','{node.CreateDateTime}','{index}','{node.MAC }'
|
|||
|
|
,'{sbuf(2)}'
|
|||
|
|
,'{localDateTime.ToUniversalTime.Ticks }');{vbCrLf }"
|
|||
|
|
selectstr = $"{selectstr}{Insert}"
|
|||
|
|
ElseIf index.Contains("DevService:loop") Then
|
|||
|
|
|
|||
|
|
Dim sbuf() As String = index.Split(":")
|
|||
|
|
Insert = $"INSERT INTO [Tftp_Log]
|
|||
|
|
([FileName]
|
|||
|
|
,[CreateFileTime]
|
|||
|
|
,[Datastr]
|
|||
|
|
,[DevName]
|
|||
|
|
,[DevService]
|
|||
|
|
,[loop]
|
|||
|
|
,[Datatime])
|
|||
|
|
VALUES
|
|||
|
|
('{node.LogFileName }','{node.CreateDateTime}','{index}','{node.MAC }'
|
|||
|
|
,'{sbuf(2).Split(",")(0)}'
|
|||
|
|
,'{sbuf(3)}'
|
|||
|
|
,'{localDateTime.ToUniversalTime.Ticks }');{vbCrLf }"
|
|||
|
|
selectstr = $"{selectstr}{Insert}"
|
|||
|
|
|
|||
|
|
ElseIf index.Contains("VCLog:T2") Then
|
|||
|
|
Dim sbuf() As String = index.Split(":")
|
|||
|
|
Insert = $"INSERT INTO [Tftp_Log]
|
|||
|
|
([FileName]
|
|||
|
|
,[CreateFileTime]
|
|||
|
|
,[Datastr]
|
|||
|
|
,[DevName]
|
|||
|
|
,[T2]
|
|||
|
|
,[loop]
|
|||
|
|
,[Datatime])
|
|||
|
|
VALUES
|
|||
|
|
('{node.LogFileName }','{node.CreateDateTime}','{index}','{node.MAC }'
|
|||
|
|
,'{sbuf(3)}'
|
|||
|
|
,'{sbuf(2)}'
|
|||
|
|
,'{localDateTime.ToUniversalTime.Ticks }');{vbCrLf }"
|
|||
|
|
selectstr = $"{selectstr}{Insert}"
|
|||
|
|
ElseIf index.Contains("VCLog:T4") Then
|
|||
|
|
Dim sbuf() As String = index.Split(":")
|
|||
|
|
Insert = $"INSERT INTO [Tftp_Log]
|
|||
|
|
([FileName]
|
|||
|
|
,[CreateFileTime]
|
|||
|
|
,[Datastr]
|
|||
|
|
,[DevName]
|
|||
|
|
,[T4]
|
|||
|
|
,[Datatime])
|
|||
|
|
VALUES
|
|||
|
|
('{node.LogFileName }','{node.CreateDateTime}','{index}','{node.MAC }'
|
|||
|
|
,'{sbuf(2)}'
|
|||
|
|
,'{localDateTime.ToUniversalTime.Ticks}');{vbCrLf }"
|
|||
|
|
selectstr = $"{selectstr}{Insert}"
|
|||
|
|
End If
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
End Select
|
|||
|
|
|
|||
|
|
Next
|
|||
|
|
'selectstr = $"{selectstr}COMMIT ;"
|
|||
|
|
Dim dt As DataTable
|
|||
|
|
|
|||
|
|
|
|||
|
|
' Try
|
|||
|
|
Using db As New DbExecutor(DbExecutor.DbTypeEnum.Sqlite, LocalConnString)
|
|||
|
|
db.Open()
|
|||
|
|
Try
|
|||
|
|
' 开始一个事务
|
|||
|
|
db.BeginTransaction()
|
|||
|
|
dt = db.ExecuteDataTable(selectstr)
|
|||
|
|
db.CommitTransaction()
|
|||
|
|
Catch ex As Exception
|
|||
|
|
db.RollbackTransaction()
|
|||
|
|
End Try
|
|||
|
|
db.Close()
|
|||
|
|
End Using
|
|||
|
|
|
|||
|
|
'Catch ex As Exception
|
|||
|
|
' MsgBox($"数据批量写入失败!!!{vbCrLf }原因:{vbCrLf }{ex.Message }")
|
|||
|
|
'End Try
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Function GetFileNameInfo(ByVal datFile As String) As fileNameInfoStruct
|
|||
|
|
Dim tmpFileInfo As New fileNameInfoStruct
|
|||
|
|
Dim fileInfo As FileInfo = New FileInfo(datFile)
|
|||
|
|
Dim FileNameStr As String = fileInfo.Name
|
|||
|
|
Dim Strbyte As String() = FileNameStr.Split("_")
|
|||
|
|
|
|||
|
|
Dim lastModified As DateTime = fileInfo.LastWriteTime
|
|||
|
|
Try
|
|||
|
|
tmpFileInfo.MAC = Strbyte(0)
|
|||
|
|
tmpFileInfo.HotelId = Strbyte(1)
|
|||
|
|
tmpFileInfo.RoomId = Strbyte(2)
|
|||
|
|
'tmpFileInfo.CreateDateTime = datFile.DateLastModified
|
|||
|
|
tmpFileInfo.CreateDateTime = Format(lastModified, "yyyy-MM-dd HH:mm:ss")
|
|||
|
|
|
|||
|
|
tmpFileInfo.LogFileName = fileInfo.Name
|
|||
|
|
Catch ex As Exception
|
|||
|
|
AdminLog.ApplicationLog.WriteErrorLog(ex)
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
Return tmpFileInfo
|
|||
|
|
End Function
|
|||
|
|
Public Function File_Data_Parsing_To_Iten(ByVal datFileName As fileNameInfoStruct, databuff() As Byte, lastdata As LogDataInfoStruct) As LogDataInfoStruct
|
|||
|
|
Dim save_data As New LogDataInfoStruct
|
|||
|
|
'Dim parsing_string As String
|
|||
|
|
Dim hour_tick As Int32
|
|||
|
|
Dim hour_temp As Int32
|
|||
|
|
Dim data_date As Int32
|
|||
|
|
'数据类型及长度等
|
|||
|
|
'save_data.original_data = file_data(idx)
|
|||
|
|
save_data.Log_SN = databuff(LOG_DATA_FORMAT.SN)
|
|||
|
|
save_data.Log_Type = databuff(LOG_DATA_FORMAT.Type)
|
|||
|
|
hour_temp = databuff(LOG_DATA_FORMAT.Len_8)
|
|||
|
|
save_data.Log_Len = (databuff(LOG_DATA_FORMAT.Len) Or (hour_temp << 8)) - LOG_DATA_FORMAT.Data '数据长度
|
|||
|
|
|
|||
|
|
' If save_data.Log_Len > Log_Data_Len_Max Then
|
|||
|
|
'save_data.len = Log_Data_Len_Max 数据长度超过数据最大长度
|
|||
|
|
' Return tmpDataList
|
|||
|
|
' End If
|
|||
|
|
|
|||
|
|
'日期
|
|||
|
|
data_date = (databuff(LOG_DATA_FORMAT.Date_L) And &HFF) '记录时间
|
|||
|
|
hour_temp = databuff(LOG_DATA_FORMAT.Date_H)
|
|||
|
|
data_date = data_date Or (hour_temp << 8)
|
|||
|
|
|
|||
|
|
hour_tick = databuff(LOG_DATA_FORMAT.Time8B)
|
|||
|
|
hour_temp = databuff(LOG_DATA_FORMAT.Time16B)
|
|||
|
|
hour_tick = hour_tick Or (hour_temp << 8)
|
|||
|
|
hour_temp = databuff(LOG_DATA_FORMAT.Time24B)
|
|||
|
|
hour_tick = hour_tick Or (hour_temp << 16)
|
|||
|
|
hour_temp = databuff(LOG_DATA_FORMAT.Time32B)
|
|||
|
|
hour_tick = hour_tick Or (hour_temp << 24)
|
|||
|
|
|
|||
|
|
save_data.Log_DateTime.year = (data_date >> 10) And &H1F
|
|||
|
|
save_data.Log_DateTime.month = (data_date >> 5) And &H1F
|
|||
|
|
save_data.Log_DateTime.day = (data_date) And &H1F
|
|||
|
|
|
|||
|
|
'时间
|
|||
|
|
save_data.Log_DateTime.hour = hour_tick \ 3600000
|
|||
|
|
|
|||
|
|
'防止24:00:00 溢出 Momo 2022-06-26 24:00:00
|
|||
|
|
If save_data.Log_DateTime.hour >= 24 Then save_data.Log_DateTime.hour = 0
|
|||
|
|
|
|||
|
|
hour_temp = hour_tick Mod 3600000
|
|||
|
|
save_data.Log_DateTime.minute = hour_temp \ 60000
|
|||
|
|
hour_temp = hour_temp Mod 60000
|
|||
|
|
save_data.Log_DateTime.second = hour_temp \ 1000
|
|||
|
|
save_data.Log_DateTime.milliscond = hour_temp Mod 1000
|
|||
|
|
|
|||
|
|
|
|||
|
|
'分离文件内容中的数据
|
|||
|
|
Dim copy As UInt16 = save_data.Log_Len - 1
|
|||
|
|
Dim parsing_data(copy - 1) As Byte
|
|||
|
|
|
|||
|
|
Array.Copy(databuff, LOG_DATA_FORMAT.Data, parsing_data, 0, copy)
|
|||
|
|
|
|||
|
|
save_data.Log_Content = parsing_data
|
|||
|
|
|
|||
|
|
'parsing_string = BitConverter.ToString(parsing_data)
|
|||
|
|
'parsing_string = parsing_string.Replace("-", " ")
|
|||
|
|
'Console.WriteLine($"parsing_string:{parsing_string}")
|
|||
|
|
|
|||
|
|
'parsing_string = $"Data SN:{save_data.Log_SN:d} TYPE:{save_data.Log_Type:d} Len:{save_data.Log_Len:d} data_date:{data_date:X} hour_tick:{hour_tick:X}"
|
|||
|
|
' Console.WriteLine(parsing_string)
|
|||
|
|
|
|||
|
|
'解析数据内容
|
|||
|
|
Dim Parsing_Param As New List(Of String)
|
|||
|
|
Parsing_Data_Content(save_data.Log_Type, parsing_data, Parsing_Param) '解析
|
|||
|
|
|
|||
|
|
'判断Param参数,不够10个则补足
|
|||
|
|
If Parsing_Param.Count > 0 Then
|
|||
|
|
Dim len As Integer = 10 - Parsing_Param.Count
|
|||
|
|
Dim par(len - 1) As String
|
|||
|
|
Parsing_Param.AddRange(par)
|
|||
|
|
End If
|
|||
|
|
save_data.parsing = Parsing_Param
|
|||
|
|
save_data.Log_TimeSpan = Get_Data_Time_Difference2(lastdata, save_data) '时间差
|
|||
|
|
save_data.Log_Valid = True
|
|||
|
|
save_data.HotelId = datFileName.HotelId
|
|||
|
|
save_data.RoomId = datFileName.RoomId
|
|||
|
|
save_data.CreateDateTime = datFileName.CreateDateTime
|
|||
|
|
save_data.LogFileName = datFileName.LogFileName
|
|||
|
|
save_data.MAC = datFileName.MAC
|
|||
|
|
' Dim savedata As String = $"[HotelId:{save_data.HotelId }],{vbCrLf}[RoomId:{save_data.RoomId}],{vbCrLf}[LogFileName:{save_data.LogFileName }],{vbCrLf}[Log_SN:{save_data.Log_SN }],{vbCrLf}[Log_Len:{save_data.Log_SN}],{vbCrLf}[Log_DateTime:{ newtime_h(save_data).ToString("yyyy-MM-dd HH:mm:ss") }],{vbCrLf}[Log_TimeSpan:{save_data.Log_TimeSpan}],{vbCrLf}[Log_Type:{Parsing_Param}],{vbCrLf}[CreateDateTime:{save_data.CreateDateTime}],{vbCrLf}[LogFileName:{save_data.LogFileName }]"
|
|||
|
|
' Console.WriteLine($"解析数据包({idx}):{vbCrLf}{savedata}")
|
|||
|
|
' Console.WriteLine($"解析数据包({idx})")
|
|||
|
|
Return save_data
|
|||
|
|
End Function
|
|||
|
|
''' <summary>
|
|||
|
|
''' 解析数据内容
|
|||
|
|
''' 按照数据类型来解析,用于加载表格时的数据显示 - 简单的内容解析
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="data_content"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Public Function Parsing_Data_Content(data_type As Byte, data_content As Byte(), ByRef Type_Param As List(Of String)) As List(Of String)
|
|||
|
|
|
|||
|
|
|
|||
|
|
Dim dev_temp As New Device_Temp
|
|||
|
|
Try
|
|||
|
|
Select Case data_type
|
|||
|
|
|
|||
|
|
Case log_type.Launcher
|
|||
|
|
Type_Param.Add("Launcher信息")
|
|||
|
|
Type_Param = Parsing_LogData_Launcher_Content(data_content, Type_Param)
|
|||
|
|
Case log_type.SYS_Record
|
|||
|
|
Type_Param.Add("系统信息")
|
|||
|
|
Type_Param = Parsing_LogData_SYS_Record_Content(data_content, Type_Param)
|
|||
|
|
Case log_type.Device_COMM
|
|||
|
|
Type_Param.Add("设备通讯")
|
|||
|
|
Type_Param = Parsing_LogData_Device_COMM_Content(data_content, Type_Param)
|
|||
|
|
Case log_type.Device_Online
|
|||
|
|
Type_Param.Add("设备通讯状态")
|
|||
|
|
Type_Param = Parsing_LogData_Device_Online_Content(data_content, Type_Param)
|
|||
|
|
Case log_type.Global_Parameters
|
|||
|
|
Type_Param.Add("定期保存设备信息")
|
|||
|
|
Type_Param = Parsing_LogData_Global_Parameters_Content(data_content, Type_Param)
|
|||
|
|
Case log_type.Net_COMM
|
|||
|
|
Type_Param.Add("网络处理")
|
|||
|
|
Type_Param = Parsing_LogData_Net_COMM_Content(data_content, Type_Param)
|
|||
|
|
Case log_type.Logic_Record
|
|||
|
|
Type_Param.Add("事件处理")
|
|||
|
|
Type_Param = Parsing_LogData_Logic_Record_Content(data_content, Type_Param)
|
|||
|
|
Case Else
|
|||
|
|
Type_Param.Add("数据类型错误")
|
|||
|
|
End Select
|
|||
|
|
Catch ex As Exception
|
|||
|
|
AdminLog.ApplicationLog.WriteErrorLog(ex)
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
Return Type_Param
|
|||
|
|
End Function
|
|||
|
|
''' <summary>
|
|||
|
|
''' 系统运行信息数据解析
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="data_content"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Public Function Parsing_LogData_SYS_Record_Content(data_content As Byte(), ByRef Type_Param As List(Of String)) As List(Of String)
|
|||
|
|
|
|||
|
|
'data_parsing = "系统运行数据解析" & BitConverter.ToString(data_content).Replace("-", " ")
|
|||
|
|
|
|||
|
|
Dim sys_type As Byte = data_content(0)
|
|||
|
|
|
|||
|
|
Try
|
|||
|
|
Select Case sys_type
|
|||
|
|
Case LSYS.PHY_Change
|
|||
|
|
Type_Param.Add("网络PHY状态记录")
|
|||
|
|
If data_content(1) = &H0 Then
|
|||
|
|
Type_Param.Add("拔出")
|
|||
|
|
ElseIf data_content(1) = &H1 Then
|
|||
|
|
Type_Param.Add("插入")
|
|||
|
|
Else
|
|||
|
|
Type_Param.Add($"PHY状态错误: {data_content(1)}")
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Case LSYS.DevInfo_Error
|
|||
|
|
Type_Param.Add("设备链表读取信息错误记录")
|
|||
|
|
Type_Param.Add($"设备类型:{data_content(1)}")
|
|||
|
|
Type_Param.Add($"地址:{data_content(2)}")
|
|||
|
|
Type_Param.Add($"链表信息读取错误")
|
|||
|
|
Case LSYS.API_State
|
|||
|
|
Type_Param.Add("系统升级信息")
|
|||
|
|
If data_content(1) = &H1 Then
|
|||
|
|
Type_Param.Add("串口升级")
|
|||
|
|
ElseIf data_content(1) = &H2 Then
|
|||
|
|
Type_Param.Add("网络升级")
|
|||
|
|
Else
|
|||
|
|
Type_Param.Add("错误升级类型")
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
If data_content(2) = &H1 Then
|
|||
|
|
Type_Param.Add("写入成功")
|
|||
|
|
ElseIf data_content(2) = &H2 Then
|
|||
|
|
Type_Param.Add("写入失败")
|
|||
|
|
ElseIf data_content(2) = &H3 Then
|
|||
|
|
Type_Param.Add("文件块数错误")
|
|||
|
|
ElseIf data_content(2) = &H4 Then
|
|||
|
|
Type_Param.Add("MD5校验错误")
|
|||
|
|
ElseIf data_content(2) = &H5 Then
|
|||
|
|
Type_Param.Add("CRC校验错误")
|
|||
|
|
ElseIf data_content(2) = &H6 Then
|
|||
|
|
Type_Param.Add("跳转Launcher")
|
|||
|
|
Else
|
|||
|
|
Type_Param.Add("未知状态")
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
Case LSYS.NET_ARGC
|
|||
|
|
Type_Param.Add("网络初始化:")
|
|||
|
|
Type_Param.Add($"IP : {data_content(1)}.{data_content(2)}.{data_content(3)}.{data_content(4)}")
|
|||
|
|
Type_Param.Add($"MAC : {data_content(5)}.{data_content(6)}.{data_content(7)}.{data_content(8)}.{data_content(9)}.{data_content(10)}")
|
|||
|
|
Type_Param.Add($"服务器IP : {data_content(11)}.{data_content(12)}.{data_content(13)}.{data_content(14)}")
|
|||
|
|
Type_Param.Add($"TFTP服务器IP : {data_content(15)}.{data_content(16)}.{data_content(17)}.{data_content(18)}")
|
|||
|
|
Type_Param.Add($"MQTT服务器IP : {data_content(19)}.{data_content(20)}.{data_content(21)}.{data_content(22)}")
|
|||
|
|
Case LSYS.MQTT_ARGC
|
|||
|
|
Type_Param.Add("MQTT初始化参数")
|
|||
|
|
Type_Param.Add("还没解析")
|
|||
|
|
Case LSYS.NetComm_State
|
|||
|
|
Type_Param.Add("云端通讯状态")
|
|||
|
|
If data_content(1) = &H0 Then
|
|||
|
|
Type_Param.Add("服务器状态:离线")
|
|||
|
|
ElseIf data_content(1) = &H1 Then
|
|||
|
|
Type_Param.Add("本地服务器通信正常")
|
|||
|
|
ElseIf data_content(1) = &H2 Then
|
|||
|
|
Type_Param.Add("云端服务器通信正常")
|
|||
|
|
Else
|
|||
|
|
Type_Param.Add("云端通讯状态 - 未知状态")
|
|||
|
|
End If
|
|||
|
|
Case LSYS.NET_DafaultARGC
|
|||
|
|
|
|||
|
|
Type_Param.Add("网络初始化")
|
|||
|
|
Type_Param.Add($"IP : {data_content(1)}.{data_content(2)}.{data_content(3)}.{data_content(4)}")
|
|||
|
|
Type_Param.Add($"网关 : {data_content(5)}.{data_content(6)}.{data_content(7)}.{data_content(8)}")
|
|||
|
|
Type_Param.Add($"子网掩码 : {data_content(9)}.{data_content(10)}.{data_content(11)}.{data_content(12)}")
|
|||
|
|
Type_Param.Add($"DNS_IP : {data_content(13)}.{data_content(14)}.{data_content(15)}.{data_content(16)}")
|
|||
|
|
|
|||
|
|
If data_content(17) = &H1 Then
|
|||
|
|
Type_Param.Add("网络ArgcFlag标志:PC设置参数")
|
|||
|
|
Else
|
|||
|
|
Type_Param.Add("网络ArgcFlag标志:主机默认参数")
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
If data_content(18) = &H2 Then
|
|||
|
|
Type_Param.Add("DHCP标志:关闭DHCP")
|
|||
|
|
Else
|
|||
|
|
Type_Param.Add("DHCP标志:启动DHCP")
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
If data_content(19) = &H1 Then
|
|||
|
|
Type_Param.Add("使用本地服务器标志")
|
|||
|
|
Else
|
|||
|
|
Type_Param.Add("使用云端服务器标志")
|
|||
|
|
End If
|
|||
|
|
Case Else
|
|||
|
|
Type_Param.Add($"系统运行信息 类型错误{sys_type}")
|
|||
|
|
End Select
|
|||
|
|
Catch ex As Exception
|
|||
|
|
AdminLog.ApplicationLog.WriteErrorLog(ex)
|
|||
|
|
Type_Param.Add("数据异常----")
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
Return Type_Param
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备通讯数据解析
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="data_content"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Public Function Parsing_LogData_Device_COMM_Content(data_content As Byte(), ByRef Type_Param As List(Of String)) As List(Of String)
|
|||
|
|
Dim data_type As Byte = data_content(0)
|
|||
|
|
Dim data_port As Byte = data_content(1)
|
|||
|
|
Dim data_baud As UInt32
|
|||
|
|
Dim data_buff(data_content.Length - 7) As Byte
|
|||
|
|
|
|||
|
|
Array.Copy(data_content, 6, data_buff, 0, data_content.Length - 6)
|
|||
|
|
|
|||
|
|
data_baud = data_content(5)
|
|||
|
|
data_baud = (data_baud << 8) Or data_content(4)
|
|||
|
|
data_baud = (data_baud << 8) Or data_content(3)
|
|||
|
|
data_baud = (data_baud << 8) Or data_content(2)
|
|||
|
|
Try
|
|||
|
|
Select Case data_type
|
|||
|
|
Case LCOMM.Adjust_Baud '设备切换通讯波特率
|
|||
|
|
|
|||
|
|
Type_Param.Add($"设备切换通讯波特率")
|
|||
|
|
data_baud = data_content(6)
|
|||
|
|
data_baud = (data_baud << 8) Or data_content(5)
|
|||
|
|
data_baud = (data_baud << 8) Or data_content(4)
|
|||
|
|
data_baud = (data_baud << 8) Or data_content(3)
|
|||
|
|
|
|||
|
|
Obtaining_The_Device_Type(data_content(1), Type_Param)
|
|||
|
|
Type_Param.Add($" 设备地址:{data_content(2)}")
|
|||
|
|
Type_Param.Add($" 切换波特率:{data_baud}" & vbCrLf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
Case LCOMM.ASK_TO_Reply '轮询回复数据
|
|||
|
|
Type_Param.Add($"轮询回复数据")
|
|||
|
|
Type_Param.Add($"Port_{data_port} ")
|
|||
|
|
Type_Param.Add($"Baud:{data_baud} ")
|
|||
|
|
Type_Param.Add("485通讯数据:" & BitConverter.ToString(data_buff).Replace("-", " "))
|
|||
|
|
DataTypes.Parsing_485Data_type(data_buff, Type_Param)
|
|||
|
|
|
|||
|
|
Case LCOMM.Control_Reply 'RCU下发数据
|
|||
|
|
Type_Param.Add($"RCU下发数据")
|
|||
|
|
Type_Param.Add($"Port_{data_port}")
|
|||
|
|
Type_Param.Add($"Baud:{data_baud}")
|
|||
|
|
Type_Param.Add("485通讯数据:" & BitConverter.ToString(data_buff).Replace("-", " "))
|
|||
|
|
DataTypes.Parsing_485Data_type(data_buff, Type_Param)
|
|||
|
|
|
|||
|
|
Case LCOMM.Send_Control 'RCU接收控制回复数据
|
|||
|
|
Type_Param.Add($"RCU接收控制回复数据")
|
|||
|
|
Type_Param.Add($"Port_{data_port}")
|
|||
|
|
Type_Param.Add($"Baud:{data_baud}")
|
|||
|
|
Type_Param.Add("485通讯数据:" & BitConverter.ToString(data_buff).Replace("-", " "))
|
|||
|
|
DataTypes.Parsing_485Data_type(data_buff, Type_Param)
|
|||
|
|
Case Else
|
|||
|
|
Type_Param.Add("类型错误:" & BitConverter.ToString(data_content).Replace("-", " "))
|
|||
|
|
End Select
|
|||
|
|
Catch ex As Exception
|
|||
|
|
AdminLog.ApplicationLog.WriteErrorLog(ex)
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
Return Type_Param
|
|||
|
|
End Function
|
|||
|
|
''' <summary>
|
|||
|
|
''' 设备通讯状态数据解析
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="data_content"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Public Function Parsing_LogData_Device_Online_Content(data_content As Byte(), ByRef Type_Param As List(Of String)) As List(Of String)
|
|||
|
|
Dim dev_type As Byte = data_content(0)
|
|||
|
|
Dim dev_addr As Byte = data_content(1)
|
|||
|
|
Dim dev_state As Byte = data_content(2)
|
|||
|
|
Try
|
|||
|
|
Type_Param.Add("设备状态改变")
|
|||
|
|
Type_Param = Obtaining_The_Device_Type(dev_type, Type_Param)
|
|||
|
|
Type_Param.Add($"设备地址:{dev_addr} ")
|
|||
|
|
If dev_state = LOG_DEV_State.Offline Then
|
|||
|
|
Type_Param.Add("设备状态:离线")
|
|||
|
|
ElseIf dev_state = LOG_DEV_State.Online Then
|
|||
|
|
Type_Param.Add("设备状态:在线")
|
|||
|
|
Else
|
|||
|
|
Type_Param.Add($"状态错误:{dev_state}")
|
|||
|
|
End If
|
|||
|
|
Catch ex As Exception
|
|||
|
|
AdminLog.ApplicationLog.WriteErrorLog(ex)
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
Return Type_Param
|
|||
|
|
End Function
|
|||
|
|
''' <summary>
|
|||
|
|
''' 获取设备类型
|
|||
|
|
''' </summary>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Public Function Obtaining_The_Device_Type(data As Byte, ByRef Type_Param As List(Of String)) As List(Of String)
|
|||
|
|
Try
|
|||
|
|
Select Case data
|
|||
|
|
Case BLV_DEVICE_TYPE.C12Dimming
|
|||
|
|
Type_Param.Add("设备类型:C12调光设备")
|
|||
|
|
Case BLV_DEVICE_TYPE.C5IO
|
|||
|
|
Type_Param.Add("设备类型:C5IO设备")
|
|||
|
|
Case BLV_DEVICE_TYPE.C5Music
|
|||
|
|
Type_Param.Add("设备类型:C5Music设备")
|
|||
|
|
Case BLV_DEVICE_TYPE.PC_TEST
|
|||
|
|
Type_Param.Add("设备类型:BLV PC TEST")
|
|||
|
|
Case BLV_DEVICE_TYPE.RS485_Card
|
|||
|
|
Type_Param.Add("设备类型:RS485 插卡取电")
|
|||
|
|
Case BLV_DEVICE_TYPE.RS485_IR_SEND
|
|||
|
|
Type_Param.Add("设备类型:RS485 红外转发")
|
|||
|
|
Case BLV_DEVICE_TYPE.RS485_RGB_Light
|
|||
|
|
Type_Param.Add("设备类型:RS485 RGB灯带")
|
|||
|
|
Case BLV_DEVICE_TYPE.RS485_Switch
|
|||
|
|
Type_Param.Add("设备类型:RS485 开关")
|
|||
|
|
Case BLV_DEVICE_TYPE.RS485_Temp
|
|||
|
|
Type_Param.Add("设备类型:RS485 温控器")
|
|||
|
|
Case BLV_DEVICE_TYPE.RS485_Time
|
|||
|
|
Type_Param.Add("设备类型:时间同步")
|
|||
|
|
Case BLV_DEVICE_TYPE.RS485_XiaoBao
|
|||
|
|
Type_Param.Add("设备类型:RS485 小宝语音")
|
|||
|
|
Case Else
|
|||
|
|
Type_Param.Add($"未知设备:{data}")
|
|||
|
|
End Select
|
|||
|
|
Catch ex As Exception
|
|||
|
|
AdminLog.ApplicationLog.WriteErrorLog(ex)
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
Return Type_Param
|
|||
|
|
End Function
|
|||
|
|
''' <summary>
|
|||
|
|
''' 所有设备状态定期保存数据解析
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="data_content"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Public Function Parsing_LogData_Global_Parameters_Content(data_content As Byte(), ByRef Type_Param As List(Of String)) As List(Of String)
|
|||
|
|
Type_Param.Add("所有设备状态定期保存数据解析" & BitConverter.ToString(data_content).Replace("-", " "))
|
|||
|
|
Return Type_Param
|
|||
|
|
End Function
|
|||
|
|
''' <summary>
|
|||
|
|
''' 网络处理记录信息解析
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="data_content"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Public Function Parsing_LogData_Net_COMM_Content(data_content As Byte(), ByRef Type_Param As List(Of String)) As List(Of String)
|
|||
|
|
|
|||
|
|
Dim net_type As Byte = data_content(0)
|
|||
|
|
Dim net_port As UInt16
|
|||
|
|
Select Case net_type
|
|||
|
|
Case LNetComm.N_Recv
|
|||
|
|
Try
|
|||
|
|
Type_Param.Add("网络接收记录")
|
|||
|
|
Type_Param.Add($"套接字序号(1~4):{data_content(1)}")
|
|||
|
|
Type_Param.Add($"接收IP:{data_content(2)}.{data_content(3)}.{data_content(4)}.{data_content(5)}")
|
|||
|
|
net_port = data_content(7)
|
|||
|
|
net_port <<= 8
|
|||
|
|
net_port = net_port Or data_content(6)
|
|||
|
|
Type_Param.Add($"接收端口Port:{net_port}")
|
|||
|
|
Type_Param.Add("Data:" & BitConverter.ToString(data_content, 8).Replace("-", " "))
|
|||
|
|
DataTypes.Check_Network_Data(data_content, Type_Param, True)
|
|||
|
|
Catch ex As Exception
|
|||
|
|
Type_Param.Add("网络数据解析错误:" & BitConverter.ToString(data_content, 1).Replace("-", " "))
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
Case LNetComm.N_Send
|
|||
|
|
Try
|
|||
|
|
Type_Param.Add("网络发送记录")
|
|||
|
|
Type_Param.Add($"套接字序号(1~4):{data_content(1)}")
|
|||
|
|
Type_Param.Add($"发送IP:{data_content(2)}.{data_content(3)}.{data_content(4)}.{data_content(5)}")
|
|||
|
|
net_port = data_content(7)
|
|||
|
|
net_port <<= 8
|
|||
|
|
net_port = net_port Or data_content(6)
|
|||
|
|
Type_Param.Add($"发送端口Port:{net_port}")
|
|||
|
|
Type_Param.Add("Data:" & BitConverter.ToString(data_content, 8).Replace("-", " "))
|
|||
|
|
DataTypes.Check_Network_Data(data_content, Type_Param, False)
|
|||
|
|
Catch ex As Exception
|
|||
|
|
Console.WriteLine("网络数据解析错误:长度不够")
|
|||
|
|
Type_Param.Add("网络数据解析错误:" & BitConverter.ToString(data_content, 1).Replace("-", " "))
|
|||
|
|
End Try
|
|||
|
|
End Select
|
|||
|
|
|
|||
|
|
Return Type_Param
|
|||
|
|
End Function
|
|||
|
|
''' <summary>
|
|||
|
|
''' 事件处理记录信息解析
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="data_content"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Public Function Parsing_LogData_Logic_Record_Content(data_content As Byte(), ByRef Type_Param As List(Of String)) As List(Of String)
|
|||
|
|
'Type_Param.Add("事件处理记录信息解析" & BitConverter.ToString(data_content).Replace("-", " "))
|
|||
|
|
Dim net_type As Byte = data_content(0)
|
|||
|
|
Select Case net_type
|
|||
|
|
Case Debugtype.log
|
|||
|
|
Type_Param.Add("调试日志")
|
|||
|
|
Type_Param.Add(Encoding.GetEncoding("GBK").GetString(data_content, 1, data_content.Length - 1))
|
|||
|
|
|
|||
|
|
End Select
|
|||
|
|
Return Type_Param
|
|||
|
|
End Function
|
|||
|
|
''' <summary>
|
|||
|
|
''' Launcher类型数据解析
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="data_content"></param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Public Function Parsing_LogData_Launcher_Content(data_content As Byte(), ByRef Type_Param As List(Of String)) As List(Of String)
|
|||
|
|
|
|||
|
|
Dim Launcher_type As Byte = data_content(0)
|
|||
|
|
Try
|
|||
|
|
Select Case Launcher_type
|
|||
|
|
Case LLauncher.App_Check
|
|||
|
|
Type_Param.Add("校验APP")
|
|||
|
|
|
|||
|
|
If data_content(1) = &H0 Then
|
|||
|
|
Type_Param.Add("相同")
|
|||
|
|
ElseIf data_content(1) = &H1 Then
|
|||
|
|
Type_Param.Add("APP版本号不同")
|
|||
|
|
ElseIf data_content(1) = &H2 Then
|
|||
|
|
Type_Param.Add("特征区CRC不同")
|
|||
|
|
ElseIf data_content(1) = &H3 Then
|
|||
|
|
Type_Param.Add("Flash APP地址错误")
|
|||
|
|
ElseIf data_content(1) = &H4 Then
|
|||
|
|
Type_Param.Add("Flash APP数据校验错误")
|
|||
|
|
ElseIf data_content(1) = &H5 Then
|
|||
|
|
Type_Param.Add("Flash APP标志未置位")
|
|||
|
|
ElseIf data_content(1) = &H6 Then
|
|||
|
|
Type_Param.Add("Flash 特征区的CRC校验错误")
|
|||
|
|
ElseIf data_content(1) = &H7 Then
|
|||
|
|
Type_Param.Add("MCU Flash数据校验错误")
|
|||
|
|
ElseIf data_content(1) = &H8 Then
|
|||
|
|
Type_Param.Add("MCU Flash的APP标志未置位")
|
|||
|
|
ElseIf data_content(1) = &H9 Then
|
|||
|
|
Type_Param.Add("MCU Flash特征区的CRC校验错误")
|
|||
|
|
Else
|
|||
|
|
Type_Param.Add("数据错误")
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
Case LLauncher.Read_App
|
|||
|
|
Type_Param.Add("读取APP")
|
|||
|
|
If data_content(1) = &H0 Then
|
|||
|
|
Type_Param.Add("成功")
|
|||
|
|
ElseIf data_content(1) = &H1 Then
|
|||
|
|
Type_Param.Add("失败")
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
Case LLauncher.Reset_Source
|
|||
|
|
Type_Param.Add("复位源")
|
|||
|
|
If data_content(1) = &H0 Then
|
|||
|
|
Type_Param.Add("软件复位")
|
|||
|
|
ElseIf data_content(1) = &H1 Then
|
|||
|
|
Type_Param.Add("上电复位")
|
|||
|
|
ElseIf data_content(1) = &H2 Then
|
|||
|
|
Type_Param.Add("看门狗超时复位")
|
|||
|
|
ElseIf data_content(1) = &H3 Then
|
|||
|
|
Type_Param.Add("外部手动复位")
|
|||
|
|
ElseIf data_content(1) = &H5 Then
|
|||
|
|
Type_Param.Add("从下电模式唤醒时的复位")
|
|||
|
|
Else
|
|||
|
|
Type_Param.Add($"复位源位置:{data_content(1):00}")
|
|||
|
|
End If
|
|||
|
|
Case Else
|
|||
|
|
Type_Param.Add("数据类型错误")
|
|||
|
|
End Select
|
|||
|
|
Catch ex As Exception
|
|||
|
|
AdminLog.ApplicationLog.WriteErrorLog(ex)
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
Return Type_Param
|
|||
|
|
End Function
|
|||
|
|
Public Function Get_Data_Time_Difference2(lastdata As LogDataInfoStruct, data As LogDataInfoStruct) As Int64
|
|||
|
|
Dim temp_tick As Int64 = 0
|
|||
|
|
Dim temp_time As New Log_DateStruct
|
|||
|
|
Dim temp_time2 As New Log_DateStruct
|
|||
|
|
If IsNothing(lastdata) Then Return temp_tick
|
|||
|
|
|
|||
|
|
temp_time.year = data.Log_DateTime.year + 2000
|
|||
|
|
|
|||
|
|
If data.Log_DateTime.month = 0 Then
|
|||
|
|
temp_time.month = data.Log_DateTime.month + 1
|
|||
|
|
Else
|
|||
|
|
temp_time.month = data.Log_DateTime.month
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
If data.Log_DateTime.day = 0 Then
|
|||
|
|
temp_time.day = data.Log_DateTime.day + 1
|
|||
|
|
Else
|
|||
|
|
temp_time.day = data.Log_DateTime.day
|
|||
|
|
End If
|
|||
|
|
temp_time.hour = data.Log_DateTime.hour
|
|||
|
|
temp_time.minute = data.Log_DateTime.minute
|
|||
|
|
temp_time.second = data.Log_DateTime.second
|
|||
|
|
temp_time.milliscond = data.Log_DateTime.milliscond
|
|||
|
|
|
|||
|
|
temp_time2.year = lastdata.Log_DateTime.year + 2000
|
|||
|
|
If lastdata.Log_DateTime.month = 0 Then
|
|||
|
|
temp_time2.month = lastdata.Log_DateTime.month + 1
|
|||
|
|
Else
|
|||
|
|
temp_time2.month = lastdata.Log_DateTime.month
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
If lastdata.Log_DateTime.day = 0 Then
|
|||
|
|
temp_time2.day = lastdata.Log_DateTime.day + 1
|
|||
|
|
Else
|
|||
|
|
temp_time2.day = lastdata.Log_DateTime.day
|
|||
|
|
End If
|
|||
|
|
temp_time2.hour = lastdata.Log_DateTime.hour
|
|||
|
|
temp_time2.minute = lastdata.Log_DateTime.minute
|
|||
|
|
temp_time2.second = lastdata.Log_DateTime.second
|
|||
|
|
temp_time2.milliscond = lastdata.Log_DateTime.milliscond
|
|||
|
|
|
|||
|
|
|
|||
|
|
' Try
|
|||
|
|
|
|||
|
|
Dim temp_date1 As New DateTime(temp_time.year, temp_time.month, temp_time.day, temp_time.hour, temp_time.minute, temp_time.second)
|
|||
|
|
Dim temp_date2 As New DateTime(temp_time2.year, temp_time2.month, temp_time2.day, temp_time2.hour, temp_time2.minute, temp_time2.second)
|
|||
|
|
|
|||
|
|
temp_tick = DateDiff(DateInterval.Second, temp_date2, temp_date1) 'temp_date1 - temp_date2
|
|||
|
|
temp_tick = temp_tick * 1000 + temp_time.milliscond - temp_time2.milliscond
|
|||
|
|
|
|||
|
|
'Catch ex As Exception
|
|||
|
|
' 'ShowRichTextBox(RichTextBox1, " xxx 时间格式错误:tempDate1:" & tmpSn & "," & temp_time.year & "," & temp_time.month & "," & temp_time.day & "," & temp_time.hour & "," & temp_time.minute & "," & temp_time.second)
|
|||
|
|
' 'ShowRichTextBox(RichTextBox1, " xxx 时间格式错误:tempDate2:" & tmpSn & "," & temp_time2.year & "," & temp_time2.month & "," & temp_time2.day & "," & temp_time2.hour & "," & temp_time2.minute & "," & temp_time2.second)
|
|||
|
|
'End Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Return temp_tick
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
''' 和校验取余数
|
|||
|
|
''' 求Byte数组的和校验取余数
|
|||
|
|
''' </summary>
|
|||
|
|
''' <param name="dataPacket">Byte数组</param>
|
|||
|
|
''' <returns></returns>
|
|||
|
|
Public Function GetSumCheckMod(dataPacket As Byte(), datalen As Byte) As Byte
|
|||
|
|
Dim sum As Integer
|
|||
|
|
For idx = 0 To datalen - 1
|
|||
|
|
sum += dataPacket(idx)
|
|||
|
|
sum = sum And &HFF
|
|||
|
|
Next
|
|||
|
|
Dim sumMod As Byte = &HFF - sum
|
|||
|
|
Return sumMod
|
|||
|
|
End Function
|
|||
|
|
'弃用
|
|||
|
|
Public Sub ParsingLog(Mac As String, starttime As Date, stoptime As Date)
|
|||
|
|
|
|||
|
|
'获取ftp文件夹列表
|
|||
|
|
'筛选出符合时间的文件
|
|||
|
|
'线程解析对应文件
|
|||
|
|
'事务操作入库
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|||
|
|
Using dlg As New FolderBrowserDialog
|
|||
|
|
dlg.Description = "请选择文件解析后存放文件夹路径!"
|
|||
|
|
If String.IsNullOrEmpty(Application.StartupPath) Or IO.Directory.Exists(Application.StartupPath) Then
|
|||
|
|
dlg.SelectedPath = My.Settings.FileDir
|
|||
|
|
Else
|
|||
|
|
dlg.SelectedPath = Application.StartupPath
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
If dlg.ShowDialog <> DialogResult.OK Then Return
|
|||
|
|
|
|||
|
|
Label1.Text = dlg.SelectedPath
|
|||
|
|
|
|||
|
|
End Using
|
|||
|
|
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub cbo_HotelList_DropDown(sender As Object, e As EventArgs)
|
|||
|
|
GetGetHotelList()
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Function GetRoomMAC() As List(Of String)
|
|||
|
|
Dim result As List(Of String) = New List(Of String)()
|
|||
|
|
If Roomlist.ContainsKey(cbo_HotelList.Text) Then
|
|||
|
|
Dim strbuf() As String = cbo_HotelList.Text.Split("|")
|
|||
|
|
Dim jsonString As String = HttpMothod.PostData("http://blv-rd.tech:19055/api/LowerMachineLog/GetHostList", $"hotel_code={strbuf(0)}&createDate={Roomlist.Item(cbo_HotelList.Text) }")
|
|||
|
|
If String.IsNullOrWhiteSpace(jsonString) Then Throw New Exception($"用户鉴权异常,请联系管理员")
|
|||
|
|
|
|||
|
|
Dim login As LoginReturn1 = JsonConvert.DeserializeObject(Of LoginReturn1)(jsonString)
|
|||
|
|
If login Is Nothing Then Throw New Exception($"解析用户权限错误!")
|
|||
|
|
|
|||
|
|
If login.isok Then
|
|||
|
|
For Each item In login.response
|
|||
|
|
If String.IsNullOrEmpty(item.mac) Then Continue For
|
|||
|
|
result.Add($"{item.roomno}|{item.mac.Replace("-", "")}|{item.roomtypeid}")
|
|||
|
|
Next
|
|||
|
|
Else
|
|||
|
|
MsgBox("API获取酒店项目失败!")
|
|||
|
|
Return result
|
|||
|
|
End If
|
|||
|
|
Return result
|
|||
|
|
Else
|
|||
|
|
MsgBox("请先选择酒店!")
|
|||
|
|
Return result
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
End Function
|
|||
|
|
|
|||
|
|
Private Sub ComboBox2_DragDrop(sender As Object, e As EventArgs) Handles ComboBox2.DropDown
|
|||
|
|
'GetRoomMAC()
|
|||
|
|
ComboBox2.Items.Clear()
|
|||
|
|
ComboBox2.Items.AddRange(GetRoomMAC().ToArray)
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Private Sub ComboBox2_TextChanged(sender As Object, e As EventArgs) Handles ComboBox2.TextChanged
|
|||
|
|
Dim strbuf() As String = ComboBox2.Text.Split("|")
|
|||
|
|
Dim strbuf1() As String = cbo_HotelList.Text.Split("|")
|
|||
|
|
Grid_config.Cell(3, 2).Text = strbuf(1).Substring(4)
|
|||
|
|
'获取数据指定房型配置的无卡取电回路别名
|
|||
|
|
Dim GdbConnStr = "Server=blv-cloud-db.mysql.rds.aliyuncs.com;Port=3307;Database=blv_rcu_db;Uid=blv_rcu;Pwd=fnadiaJDIJ7546;charset=utf8;"
|
|||
|
|
Dim wherestsre As String = $"{strbuf1(0)}_{strbuf(2)}"
|
|||
|
|
Dim selectstr As String = $"SELECT *
|
|||
|
|
FROM `blv_rcu_db`.`tbl_rcu_virtualcard_looplogs`
|
|||
|
|
where Combination_ID='{wherestsre}' "
|
|||
|
|
Dim dt As DataTable
|
|||
|
|
Try
|
|||
|
|
Using db As New DbExecutor(DbExecutor.DbTypeEnum.Mysql, GdbConnStr)
|
|||
|
|
db.Open()
|
|||
|
|
dt = db.ExecuteDataTable(selectstr)
|
|||
|
|
If IsNothing(dt) OrElse dt.Rows.Count = 0 OrElse dt.Columns.Count = 0 Then
|
|||
|
|
'MsgBox($"数据查询失败!!!{vbCrLf }原因:{vbCrLf }数据查询语句异常:{selectstr}")
|
|||
|
|
Else
|
|||
|
|
g_Macconfig.Item2.Clear()
|
|||
|
|
g_Macconfig.Item1 = Grid_config.Cell(3, 2).Text
|
|||
|
|
For i = 0 To dt.Rows.Count - 1
|
|||
|
|
For j = 0 To dt.Columns.Count - 1
|
|||
|
|
'获取列名和对应键值
|
|||
|
|
g_Macconfig.Item2.Add(dt.Columns(j).ColumnName, dt(i)(j).ToString)
|
|||
|
|
Next
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
db.Close()
|
|||
|
|
|
|||
|
|
End Using
|
|||
|
|
Catch ex As Exception
|
|||
|
|
|
|||
|
|
' MsgBox($"数据查询失败!!!{vbCrLf }原因:{vbCrLf }{ex.Message }")
|
|||
|
|
Return
|
|||
|
|
End Try
|
|||
|
|
|
|||
|
|
|
|||
|
|
'g_Macconfig
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
Private Sub ToolStripButton8_Click(sender As Object, e As EventArgs) Handles ToolStripButton8.Click
|
|||
|
|
'If String.IsNullOrEmpty(Label1.Text) Then
|
|||
|
|
' MsgBox("未选择日志目录")
|
|||
|
|
' Return
|
|||
|
|
'End If
|
|||
|
|
'If Not IO.Directory.Exists(Label1.Text) Then
|
|||
|
|
' MsgBox("日志目录不存在")
|
|||
|
|
' Return
|
|||
|
|
'End If
|
|||
|
|
|
|||
|
|
Dim filrpath As String = Grid_config.Cell(3, 2).Text.Trim
|
|||
|
|
'If String.IsNullOrEmpty(filrpath) Then
|
|||
|
|
' MsgBox("目标机型为空")
|
|||
|
|
' Return
|
|||
|
|
'End If
|
|||
|
|
'Dim mubdir As String = $"{Label1.Text}\{filrpath}"
|
|||
|
|
'If Not IO.Directory.Exists(mubdir) Then
|
|||
|
|
' MsgBox("目标机型目录不存在")
|
|||
|
|
' Return
|
|||
|
|
'End If
|
|||
|
|
If IO.Directory.Exists($"{Label1.Text}\ParsingLog\{filrpath}\") Then
|
|||
|
|
Dim filename() As String = IO.Directory.GetFiles($"{Label1.Text}\ParsingLog\{filrpath}\")
|
|||
|
|
For i = 0 To filename.Length - 1
|
|||
|
|
Dim node As String = filename(i)
|
|||
|
|
Dim index As String = node.Substring(node.LastIndexOf("\") + 1)
|
|||
|
|
If index.Contains(".dat") Then
|
|||
|
|
Try
|
|||
|
|
IO.File.Copy($"{Label1.Text}\ParsingLog\{filrpath}\{index}", $"{Label1.Text}\{filrpath}\{index}")
|
|||
|
|
Catch ex As Exception
|
|||
|
|
Continue For
|
|||
|
|
End Try
|
|||
|
|
End If
|
|||
|
|
|
|||
|
|
|
|||
|
|
Next
|
|||
|
|
|
|||
|
|
End If
|
|||
|
|
If IO.File.Exists($"{Label1.Text}\ParsingLog\{filrpath}\Tftp_Log.db") Then
|
|||
|
|
IO.File.Delete($"{Label1.Text}\ParsingLog\{filrpath}\Tftp_Log.db")
|
|||
|
|
'Return
|
|||
|
|
End If
|
|||
|
|
ToolStripButton6_Click(Nothing, Nothing)
|
|||
|
|
'If MsgBox("清空数据库将丢失更早之前解析的数据!", MsgBoxStyle.SystemModal.OkCancel) = MsgBoxResult.Ok Then
|
|||
|
|
' IO.File.Delete($"{Label1.Text}\ParsingLog\{filrpath}\Tftp_Log.db")
|
|||
|
|
'End If
|
|||
|
|
End Sub
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
Private Sub TreeView1_NodeMouseDoubleClick(sender As Object, e As TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseDoubleClick
|
|||
|
|
'Console.WriteLine(e.Node.Level)
|
|||
|
|
If e.Node.Level <> 2 OrElse IsNothing(_curTool) Then Return
|
|||
|
|
|
|||
|
|
Dim text() As String = e.Node.Text.Split("|")
|
|||
|
|
Dim dt As DateTime = DateTime.ParseExact(text(0), "yyyy-MM-dd HH:mm:ss", Nothing)
|
|||
|
|
_curTool.XValue = dt.ToOADate
|
|||
|
|
End Sub
|
|||
|
|
End Class
|