@ -14,12 +14,19 @@ using System.Linq;
using System.Text ;
using System.Threading.Tasks ;
using static DyeingComputer . UserClass . SqliteHelper ;
using ScottPlot.Hatches ;
using System.Windows.Controls ;
using ScottPlot ;
using System.Windows.Threading ;
using ScottPlot.Statistics ;
using System.Management.Instrumentation ;
namespace DyeingComputer.ViewModel
{
public partial class HistoryRecordsViewModel : ObservableObject
{
public ISeries [ ] Series { get ; set ; }
public static ISeries [ ] Series { get ; set ; }
//x轴时间格式
public Axis [ ] XAxes { get ; set ; } =
{
@ -97,34 +104,70 @@ namespace DyeingComputer.ViewModel
//new AnimatableAxisBounds
} ;
private readonly Random _ r = new Random ( ) ;
private readonly ObservableCollection < DateTimePoint > MTT_values ;
private readonly ObservableCollection < DateTimePoint > MTL_values ;
private readonly ObservableCollection < DateTimePoint > MTH_values ;
private readonly ObservableCollection < DateTimePoint > MST_values ;
private readonly ObservableCollection < DateTimePoint > MUT_values ;
private readonly ObservableCollection < DateTimePoint > STTA_values ;
private readonly ObservableCollection < DateTimePoint > STLA_values ;
private readonly ObservableCollection < DateTimePoint > STTB_values ;
private readonly ObservableCollection < DateTimePoint > STLB_values ;
private readonly ObservableCollection < DateTimePoint > STTC_values ;
private readonly ObservableCollection < DateTimePoint > STLC_values ;
private Random _ r = new Random ( ) ;
private ObservableCollection < DateTimePoint > MTT_values ;
private ObservableCollection < DateTimePoint > MTL_values ;
private ObservableCollection < DateTimePoint > MTH_values ;
private ObservableCollection < DateTimePoint > MST_values ;
private ObservableCollection < DateTimePoint > MUT_values ;
private ObservableCollection < DateTimePoint > STTA_values ;
private ObservableCollection < DateTimePoint > STLA_values ;
private ObservableCollection < DateTimePoint > STTB_values ;
private ObservableCollection < DateTimePoint > STLB_values ;
private ObservableCollection < DateTimePoint > STTC_values ;
private ObservableCollection < DateTimePoint > STLC_values ;
private SQLiteHelper SQLiteHelpers = null ; //定义数据库
private readonly string ChartAdress = Environment . CurrentDirectory + "\\DataBase\\Chart.db" ; //数据库路径
DataTable CDB = new DataTable ( ) ;
public DataTable CDB = new DataTable ( ) ;
private int CDB_Count ; //长度
public HistoryRecordsViewModel ( )
{
if ( MainWindowViewModel . WorkNumder . ToString ( ) ! = "----------" )
string Sys_Time = DateTime . Now . AddDays ( - 2 ) . ToString ( "yyyy/MM/dd HH:mm:ss" ) ;
SQLiteHelpers = new SQLiteHelper ( ChartAdress ) ; //数据库连接路径
SQLiteHelpers . Open ( ) ; //打开数据库
CDB = SQLiteHelpers . ExecuteDataSet ( "select * from Chart where Time > '" + Sys_Time + "'order by Time" , null ) . Tables [ 0 ] ;
SQLiteHelpers . Close ( ) ;
CDB_Count = CDB . Rows . Count ;
Chart_View ( ) ;
CountDown ( ) ;
}
public static bool history_ = false ;
public static string name ;
public static string stime ;
public static string etime ;
public void History ( )
{
SQLiteHelpers = new SQLiteHelper ( ChartAdress ) ; //数据库连接路径
SQLiteHelpers . Open ( ) ; //打开数据库
CDB = SQLiteHelpers . ExecuteDataSet ( "select * from Chart where DYELOT = '" + MainWindowViewModel . WorkNumder + "'order by Time" , null ) . Tables [ 0 ] ;
CDB = SQLiteHelpers . ExecuteDataSet ( "select * from Chart where DYELOT = '" + na me + "'order by Time" , null ) . Tables [ 0 ] ;
SQLiteHelpers . Close ( ) ;
CDB_Count = CDB . Rows . Count ;
Chart_View ( ) ;
}
public void CountDown ( )
{
DispatcherTimer timer1s = new DispatcherTimer //初始化循环,每1秒调用一次Tick
{
Interval = TimeSpan . FromSeconds ( 1 ) //秒
} ;
timer1s . Tick + = Tick_Event_1S ;
timer1s . Start ( ) ;
}
void Tick_Event_1S ( object sender , EventArgs e ) //Tick_Event周期执行事件1S
{
if ( history_ )
{
History ( ) ;
history_ = false ;
}
}
public void Chart_View ( )
{
var MTT_items = new List < DateTimePoint > ( ) ;
var MTL_items = new List < DateTimePoint > ( ) ;
var MTH_items = new List < DateTimePoint > ( ) ;
@ -308,4 +351,3 @@ namespace DyeingComputer.ViewModel
}
}
}
}