You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs

199 lines
7.3 KiB
C#

using System;
using System.Collections.Generic;
1 year ago
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Core;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMachinaryStateMonitor;
using Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMachinery;
using Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.InstrumentDataStateMonitor;
using Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.MotorInitStateMonitor;
using Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.NewFolder1;
using Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ParametersWithPCStateMonitor;
using Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ValveStateControl;
using Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ValveStateMonitor;
using Mesnac.Action.ChemicalWeighing.Entity;
using Mesnac.Action.ChemicalWeighing.LjMetageFormula;
1 year ago
using Mesnac.Action.ChemicalWeighing.LjMixFormula;
1 year ago
using Mesnac.Action.ChemicalWeighing.LjMixManager;
using Mesnac.Action.ChemicalWeighing.LjPlanning;
using Mesnac.Action.ChemicalWeighing.LjProdcutLine;
using Mesnac.Basic;
1 year ago
using Mesnac.Codd.Session;
using Mesnac.Controls.Base;
using Mesnac.Controls.Default;
namespace Mesnac.Action.ChemicalWeighing.Test
{
public class TestAction : DatabaseAction, IAction
{
1 year ago
public void timer1EventProcessor(object source, EventArgs e)
{
this.startdate.MCValue = DateTime.Now.ToString();
}
List<DbMCControl> mcControllist;
1 year ago
IBaseControl startdate;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
1 year ago
//int adsa = BasePlcHelper.Instance.BU1BLT01_Alarm.NowValue.ToInt();
int value = BasePlcHelper.Instance.BU1BLT01_Set.NowValue.ToInt();
1 year ago
string sql = "insert into ActionCode values (13,'test','',1) select @@IDENTITY";
1 year ago
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
if (dbHelper == null)
{
throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError);
}
1 year ago
// dbHelper.ClearParameter();
// dbHelper.CommandType = CommandType.Text;
// dbHelper.CommandText = sql;
var s1 = BasePlcHelper.Instance.dryerA_dos0_eqNo.LastValue.ToInt();
int[] ssss = new int [] { };
var ss2s = BasePlcHelper.Instance.PlcReadByRunName("BU1BLT01_Set", out ssss);
mcControllist = GetAllDbMCControlsByOption(DbOptionTypes.None);//获取所有待初始化控件
1 year ago
startdate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "MCLabel153".ToLower()).FirstOrDefault().BaseControl;
Timer timer1 = new Timer();
timer1.Interval = 1000;
timer1.Enabled = true;
timer1.Tick += new EventHandler(timer1EventProcessor);//添加事件
//ParametersWithPc.B1.FirstWord 256 768
//badc1el26587193265870
1 year ago
1 year ago
1 year ago
//
// var instanceDryer0Speeds = BasePlcHelper.Instance.Dryer0_speed;
//
// var instanceRecipeName0 = BasePlcHelper.Instance.recipeName0;
//
// //badc1e 2
// var read = BasePlcHelper.Instance.PlcRead(instanceRecipeName0, out int[] ss);
1 year ago
1 year ago
//192.168.153.100
// var firstWordNowValue = BasePlcHelper.Instance.test;
// var a = BasePlcHelper.Instance.tst0;
// var b = BasePlcHelper.Instance.tst1;
// var bs = BasePlcHelper.Instance.tst2;
1 year ago
// var bo = BasePlcHelper.Instance.PlcRead("ParametersWithPc", "3", 2, 2, out short[] f);
// var a2 = Mesnac.Basic.DataProcessor.Swap(f[0]); //注意西门子PLC需要高低位转换
//
// bo = BasePlcHelper.Instance.PlcRead("ParametersWithPc", "3", 0, 1, out short[] aaaaa);
// var aa = Mesnac.Basic.DataProcessor.Swap(aaaaa[0]); //注意西门子PLC需要高低位转换
// var qq = Convert.ToBoolean(aa);
1 year ago
//
//
//
//
// var aa = Mesnac.Basic.DataProcessor.Swap(aaaaa[0]); //注意西门子PLC需要高低位转换
//
// var bytesa = BitConverter.GetBytes(aa);
//
// bool[] bitsa = new bool[8];
//
// for (int i = 0; i < 8; i++)
// {
// bitsa[i] = (bytesa[0] & (1 << i)) != 0;
// }
1 year ago
1 year ago
// var plcReadds = BasePlcHelper.Instance.PlcRead("ParametersWithPc", "3", 1, 1, out short[] bbbb);
// var bSwap = Mesnac.Basic.DataProcessor.Swap(bbbb[0]); //注意西门子PLC需要高低位转换
//
// var bytesa = BitConverter.GetBytes(bSwap);
//
// bool[] bits = new bool[8];
//
// for (int i = 0; i <8; i++)
// {
// bits[i] = (bytesa[0] & (1 << i)) != 0;
//
// }
// bool[] bits2 = new bool[8];
//
// for (int i = 0; i <8; i++)
// {
// bits2[i] = (bytesa[1] & (1 << i)) != 0;
//
// }
//
// var ss = "asdf";
//
// short test = ssss[0];
// var bytes = BitConverter.GetBytes(test);
1 year ago
// DataKeyValue dataKeyRecipePause = new DataKeyValue("RecipePause");
1 year ago
//
1 year ago
// var swap = DataProcessor.Swap(ghPcSave3ThActs[0]);
// DataProcessor.ParseBinaryValue()
// var recipePause = BasePlcHelper.Instance.RecipePause.NowValue.ToInt();
1 year ago
//ParametersWithPc.B1.RecipePause
// 768 怎么调佣函数 怎么通过代码去写入
//或者调用控件
1 year ago
//Mesnac.Basic.DataProcessor.ToSiemen sInt32();
// var i = BasePlcHelper.Instance.Spare4.NowValue.ToInt();
// bool Spare4 = BasePlcHelper.Instance.PlcRead(BasePlcHelper.Instance.Spare4, out int[] spare4s);
//
//256 default-bit(11
// DbMCControl binGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "MCLabel153").FirstOrDefault();
//
//
// var comboBox1 = base.GetControlById("MCButton1") as System.Windows.Forms.Button;
// var comboBox1s = base.GetControlById("MCButton1") as Mesnac.Controls.Default.Button;
// List<DbMCControl> mcControllist = GetAllDbMCControlsByOption(DbOptionTypes.Query);//获取所有待初始化控件
// IBaseControl startdate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "startdate").FirstOrDefault().BaseControl;
// var firstWordNowValue = BasePlcHelper.Instance.FirstWord.NowValue.ToInt();
//
// BasePlcHelper.Instance.PlcWriteByDataKey(BasePlcHelper.Instance.FirstWord, new object[] {1});
//
// var plcHelp = BasePlcHelper.Instance;
1 year ago
// ShowMsg("小料Action1事件测试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}