Merge branch 'master' of http://www.scserverddns.top:13000/sc/DyeingComputer
This commit is contained in:
commit
6f4d43c412
2 files changed
+97
-18
No files matched your search
+61
-17
@@ -1,6 +1,8 @@
|
|||||||
using DyeingComputer.View;
|
using DyeingComputer.View;
|
||||||
using DyeingComputer.ViewModel;
|
using DyeingComputer.ViewModel;
|
||||||
|
using OpenTK.Audio.OpenAL;
|
||||||
using ScottPlot.Colormaps;
|
using ScottPlot.Colormaps;
|
||||||
|
using ScottPlot.TickGenerators.TimeUnits;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@@ -8,6 +10,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Forms;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using static DyeingComputer.UserClass.SqliteHelper;
|
using static DyeingComputer.UserClass.SqliteHelper;
|
||||||
|
|
||||||
@@ -15,31 +18,35 @@ namespace DyeingComputer.UserClass
|
|||||||
{
|
{
|
||||||
public class APILog
|
public class APILog
|
||||||
{
|
{
|
||||||
|
static bool QueueT=false;
|
||||||
private static SQLiteHelper SQLiteHelpers = null; //定义数据库
|
private static SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||||
private readonly static string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
private readonly static string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
|
||||||
private readonly static string LOGAddress = Environment.CurrentDirectory + "\\DataBase\\LOG.db"; //数据库路径
|
private readonly static string LOGAddress = Environment.CurrentDirectory + "\\DataBase\\LOG.db"; //数据库路径
|
||||||
|
public class QueueString
|
||||||
public async static void DBlog(string Name ,string ID ,string Api,string MESSAGE)
|
|
||||||
{
|
{
|
||||||
await Task.Run(() =>
|
public string ID { get; set; }
|
||||||
|
public Dictionary<string, object> DAT { get; set; }
|
||||||
|
}
|
||||||
|
public static class Queue
|
||||||
|
{
|
||||||
|
public static string ID { get; set; }
|
||||||
|
public static Dictionary<string, object> DAT { get; set; }
|
||||||
|
}
|
||||||
|
// 创建一个字符串类型的队列
|
||||||
|
public static Queue<QueueString> DBQueue = new Queue<QueueString>();
|
||||||
|
|
||||||
|
public static void DBlog(string Name, string ID, string Api, string MESSAGE)
|
||||||
{
|
{
|
||||||
Dictionary<string, object> API_LOG = new Dictionary<string, object>();//缓存函数
|
Dictionary<string, object> API_LOG = new Dictionary<string, object>();//缓存函数
|
||||||
API_LOG.Add("NAME",Name);
|
API_LOG.Add("NAME", Name);
|
||||||
API_LOG.Add("ID", ID);
|
API_LOG.Add("ID", ID);
|
||||||
API_LOG.Add("API", Api);
|
API_LOG.Add("API", Api);
|
||||||
API_LOG.Add("MESSAGE", MESSAGE);
|
API_LOG.Add("MESSAGE", MESSAGE);
|
||||||
API_LOG.Add("TIME", MainWindowViewModel.SYSTime);
|
API_LOG.Add("TIME", MainWindowViewModel.SYSTime);
|
||||||
|
LOGDB("SERVER", API_LOG);//行插入
|
||||||
SQLiteHelpers = new SQLiteHelper(LOGAddress); //数据库连接路径
|
|
||||||
SQLiteHelpers.Open(); //打开数据库
|
|
||||||
SQLiteHelpers.InsertData("SERVER", API_LOG);//行插入
|
|
||||||
SQLiteHelpers.Close(); //关闭连接
|
|
||||||
API_LOG.Clear();
|
API_LOG.Clear();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
public async static void LOGlog(string WorkOrder, string TYPE, string Command, string MESSAGE)
|
public static void LOGlog(string WorkOrder, string TYPE, string Command, string MESSAGE)
|
||||||
{
|
|
||||||
await Task.Run(() =>
|
|
||||||
{
|
{
|
||||||
Dictionary<string, object> API_LOG = new Dictionary<string, object>();//缓存函数
|
Dictionary<string, object> API_LOG = new Dictionary<string, object>();//缓存函数
|
||||||
API_LOG.Add("WorkOrder", WorkOrder);
|
API_LOG.Add("WorkOrder", WorkOrder);
|
||||||
@@ -47,14 +54,51 @@ namespace DyeingComputer.UserClass
|
|||||||
API_LOG.Add("Command", Command);
|
API_LOG.Add("Command", Command);
|
||||||
API_LOG.Add("MESSAGE", MESSAGE);
|
API_LOG.Add("MESSAGE", MESSAGE);
|
||||||
API_LOG.Add("TIME", MainWindowViewModel.SYSTime);
|
API_LOG.Add("TIME", MainWindowViewModel.SYSTime);
|
||||||
|
LOGDB("OperationLog", API_LOG);//行插入
|
||||||
|
API_LOG.Clear();
|
||||||
|
}
|
||||||
|
public static void IOlog(string IOName, string TYPE_ , object dat, string ID="0000", string PLC = "0000")
|
||||||
|
{
|
||||||
|
Dictionary<string, object> API_LOG = new Dictionary<string, object>();//缓存函数
|
||||||
|
API_LOG.Add("IOName", IOName);
|
||||||
|
API_LOG.Add("type", TYPE_);
|
||||||
|
if(TYPE_ == "M") API_LOG.Add("Value", dat);
|
||||||
|
if ((TYPE_ == "AI") ||(TYPE_ == "AO")) API_LOG.Add("AIO", dat);
|
||||||
|
if ((TYPE_ == "DQ") || (TYPE_ == "DO")) API_LOG.Add("DIO", dat);
|
||||||
|
API_LOG.Add("ID", ID);
|
||||||
|
API_LOG.Add("PLC", PLC);
|
||||||
|
API_LOG.Add("TIME", MainWindowViewModel.SYSTime);
|
||||||
|
LOGDB("IOLog", API_LOG);//行插入
|
||||||
|
API_LOG.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LOGDB(string NAME, Dictionary<string, object> dat)
|
||||||
|
{
|
||||||
|
DBQueue.Enqueue(new QueueString
|
||||||
|
{
|
||||||
|
ID = NAME,
|
||||||
|
DAT = dat
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!QueueT)
|
||||||
|
{
|
||||||
|
QueueT = true;
|
||||||
|
LOGDB();
|
||||||
|
}
|
||||||
|
if(DBQueue.Count==0) QueueT=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void LOGDB()
|
||||||
|
{
|
||||||
SQLiteHelpers = new SQLiteHelper(LOGAddress); //数据库连接路径
|
SQLiteHelpers = new SQLiteHelper(LOGAddress); //数据库连接路径
|
||||||
SQLiteHelpers.Open(); //打开数据库
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
SQLiteHelpers.InsertData("OperationLog", API_LOG);//行插入
|
while (DBQueue.Count > 0)//信息发送队列
|
||||||
|
{
|
||||||
|
QueueString t = DBQueue.Dequeue();
|
||||||
|
SQLiteHelpers.InsertData(t.ID, t.DAT);//行插入
|
||||||
|
}
|
||||||
SQLiteHelpers.Close(); //关闭连接
|
SQLiteHelpers.Close(); //关闭连接
|
||||||
API_LOG.Clear();
|
QueueT = false;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,6 +122,8 @@ namespace DyeingComputer.ViewModel
|
|||||||
execute:ProgramgroupView_run_ );//开始/暂停事件
|
execute:ProgramgroupView_run_ );//开始/暂停事件
|
||||||
ProgramgroupView_stop = new RelayCommand(
|
ProgramgroupView_stop = new RelayCommand(
|
||||||
execute: ProgramgroupView_stop_);//结束事件
|
execute: ProgramgroupView_stop_);//结束事件
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataTable dt_con = new DataTable();
|
DataTable dt_con = new DataTable();
|
||||||
@@ -240,6 +242,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
|
|
||||||
SK5 = Selet_sys("SK5");//
|
SK5 = Selet_sys("SK5");//
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProgramgroupView_run_()////运行/暂停
|
private void ProgramgroupView_run_()////运行/暂停
|
||||||
{
|
{
|
||||||
if (WORK_RUN == 2)
|
if (WORK_RUN == 2)
|
||||||
@@ -1856,8 +1859,11 @@ namespace DyeingComputer.ViewModel
|
|||||||
dt_ParameterSet = SQLiteHelpers.ExecuteDataSet("select * from Parameters order by ParameterID asc", null).Tables[0];
|
dt_ParameterSet = SQLiteHelpers.ExecuteDataSet("select * from Parameters order by ParameterID asc", null).Tables[0];
|
||||||
dt_SysSet = SQLiteHelpers.ExecuteDataSet("select * from System order by ParameterID asc", null).Tables[0];
|
dt_SysSet = SQLiteHelpers.ExecuteDataSet("select * from System order by ParameterID asc", null).Tables[0];
|
||||||
dt_TP = SQLiteHelpers.ExecuteDataSet("select * from RUN", null).Tables[0];
|
dt_TP = SQLiteHelpers.ExecuteDataSet("select * from RUN", null).Tables[0];
|
||||||
|
|
||||||
SQLiteHelpers.Close();
|
SQLiteHelpers.Close();
|
||||||
|
|
||||||
|
dt_d.RowChanged += new DataRowChangeEventHandler(ROW_changed_D);
|
||||||
|
dt_a.RowChanged += new DataRowChangeEventHandler(ROW_changed_A);
|
||||||
|
|
||||||
//创建dt_d主建
|
//创建dt_d主建
|
||||||
DataColumn[] dt_dcols =new DataColumn[] { dt_d.Columns["ID"] };
|
DataColumn[] dt_dcols =new DataColumn[] { dt_d.Columns["ID"] };
|
||||||
dt_d.PrimaryKey = dt_dcols;
|
dt_d.PrimaryKey = dt_dcols;
|
||||||
@@ -1935,6 +1941,35 @@ namespace DyeingComputer.ViewModel
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private static void ROW_changed_D(object sender, DataRowChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int MD = int.Parse(e.Row.Field<string>("ID"));
|
||||||
|
if (MD < 3001 || MD > 3004)
|
||||||
|
{
|
||||||
|
APILog.IOlog(e.Row.Field<string>("IOName")
|
||||||
|
, e.Row.Field<string>("type")
|
||||||
|
, e.Row.Field<bool>("DIO")
|
||||||
|
, e.Row.Field<string>("ID")
|
||||||
|
, e.Row.Field<string>("PLC"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
}
|
||||||
|
private static void ROW_changed_A(object sender, DataRowChangeEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
APILog.IOlog(e.Row.Field<string>("IOName")
|
||||||
|
, e.Row.Field<string>("type")
|
||||||
|
, e.Row.Field<int>("AIO")
|
||||||
|
, e.Row.Field<string>("ID")
|
||||||
|
, e.Row.Field<string>("PLC"));
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
}
|
||||||
|
|
||||||
public static double Selet_dtm(string key)//M寄存器
|
public static double Selet_dtm(string key)//M寄存器
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in new issue
Block a user