Commit e81e9bdf 刘韬

节拍12秒

1 个父辈 0aebf51b
正在显示 48 个修改的文件 包含 1033 行增加237 行删除
......@@ -53,6 +53,7 @@
<ItemGroup>
<Compile Include="AlgoPNMatch.cs" />
<Compile Include="bean\Bean.cs" />
<Compile Include="CodeResourceControl.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Setting_Init.cs" />
<Compile Include="util\ConfigAppSettings.cs" />
......
......@@ -10,6 +10,7 @@ using System.Collections.Concurrent;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.IO;
namespace OnlineStore.Common
{
......@@ -99,6 +100,7 @@ namespace OnlineStore.Common
private static object lockObj = "";
private static void AddToBox(string msg, Color color)
{
return;
if (Monitor.TryEnter(lockObj, 10))
{
try
......@@ -128,12 +130,15 @@ namespace OnlineStore.Common
}
public static void error(string errorMsg, Exception ex = null)
{
error(LOGGER, errorMsg, ex);
StackTrace st = new StackTrace(true);
StackFrame sf = st.GetFrame(1);
string filename = Path.GetFileName(sf.GetFileName());
int codeline = sf.GetFileLineNumber();
error(LOGGER, $"[{filename}:{codeline}]"+errorMsg, ex);
}
public static void info(string msg)
{
StackTrace st = new StackTrace(true);
StackFrame sf = st.GetFrame(2);
info(LOGGER, msg);
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
......
......@@ -30,6 +30,7 @@ namespace DeviceLibrary
MoveInfo.ReelParam = preReelParam;
preReelParam = null;
MoveInfo.log("检测到料盘 ReelParam:" + MoveInfo.ReelParam.ToStr());
MoveInfo.StopwatchReset();
//MoveInfo.ReelParam.ReelDest = ReelDest.String;
if (MoveInfo.ReelParam.ReelDest == ReelDest.NG || MoveInfo.ReelParam.ReelDest == ReelDest.Unknow)
{
......@@ -142,7 +143,7 @@ namespace DeviceLibrary
//CylinderMove(MoveInfo, IO_Filter_Type.Paper_TaryStop_Down, IO_Filter_Type.Paper_TaryStop_Up, IO_VALUE.LOW);
RobotManage.t1Machine.preReelParam = MoveInfo.ReelParam;
RobotManage.t1Machine.LineRun();
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(15000));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(4000));
}
else if (MoveInfo.IsTimeOut(10)) {
Msg.add("等待T1机构空闲", MsgLevel.warning);
......@@ -161,6 +162,7 @@ namespace DeviceLibrary
CylinderMove(MoveInfo, IO_Filter_Type.NG_TaryStop_Down, IO_Filter_Type.NG_TaryStop_Up, IO_VALUE.LOW);
CylinderMove(MoveInfo, IO_Filter_Type.MSD_TaryStop_Down, IO_Filter_Type.MSD_TaryStop_Up, IO_VALUE.LOW);
CylinderMove(MoveInfo, IO_Filter_Type.Paper_TaryStop_Down, IO_Filter_Type.Paper_TaryStop_Up, IO_VALUE.LOW);
MoveInfo.StopwatchLog();
break;
}
}
......
......@@ -143,7 +143,7 @@ namespace DeviceLibrary
Point qrcenter = Label_Pix_Point;
//string file = @"D:\853string\Image_20210604173619489.bmp";
//图像剪切范围矩形
var orgCrop = Rectangle.Inflate(new Rectangle(qrcenter, new Size(1, 1)), 410, 410);
var orgCrop = Rectangle.Inflate(new Rectangle(qrcenter, new Size(1, 1)), 450, 450);
//计算剪切后的二维码中心坐标点
qrcenter.X = qrcenter.X - orgCrop.X;
qrcenter.Y = qrcenter.Y - orgCrop.Y;
......
......@@ -32,6 +32,9 @@ namespace DeviceLibrary
AxisBean Label_Y_Axis;
AxisBean Label_Z_Axis;
AxisBean Label_R_Axis;
public MoveInfo SendOutMoveInfo;
public MoveInfo VacuumMoveInfo;
public bool Init(out string msg)
{
msg = "";
......@@ -49,6 +52,10 @@ namespace DeviceLibrary
#endregion
MoveInfo = new MoveInfo(DeviceName);
SendOutMoveInfo = new MoveInfo("贴标送出");
VacuumMoveInfo = new MoveInfo("贴标吸标");
SendOutMoveInfo.Hide = true;
VacuumMoveInfo.Hide = true;
ResetMoveInfo = MoveInfo;
LedProcessInit();
}
......@@ -87,9 +94,9 @@ namespace DeviceLibrary
continue;
if (runStatus == RunStatus.Running)
{
//IOMonitor();
WorkProcess();
SendOutProcess();
VacuumLabelProcess();
}
else if (runStatus == RunStatus.HomeReset)
{
......@@ -118,11 +125,13 @@ namespace DeviceLibrary
{
Alarm(AlarmType.SuddenStop);
Msg.add("急停中", MsgLevel.warning);
Thread.Sleep(1000);
ok = false;
}
else if (alarmType == AlarmType.SuddenStop)
{
Msg.add("系统需要重置", MsgLevel.warning);
Thread.Sleep(1000);
ok = false;
}
......
......@@ -18,7 +18,7 @@ namespace DeviceLibrary
protected List<Msg> Msg = new List<Msg>();
//public delegate void Event(List<Msg> msg);
public event EventHandler<List<Msg>> ProcessMsgEvent;
//public delegate void ProcessMoveinfo(List<MoveInfo> moveinfoList);
public event EventHandler<List<MoveInfo>> ProcessMoveinfoEvent;
......@@ -40,7 +40,7 @@ namespace DeviceLibrary
/// 整机启动变量,设置为false后将退出线程,只在停止时调用
/// </summary>
protected bool mstart = false;
protected int stepDelaytime =300;
protected int stepDelaytime =100;
public virtual void Run()
{
if (!mstart)
......@@ -111,6 +111,7 @@ namespace DeviceLibrary
LogUtil.error(DeviceName + " 未检测到气压信号 ,停止运动, 打开报警灯 ");
StopMove(true);
}
//LogUtil.info();
}
protected bool NoAlarm()
{
......@@ -131,7 +132,12 @@ namespace DeviceLibrary
if (MoveInfo.IsInWait)
{
CheckWait2(MoveInfo);
if (!CheckWait2(MoveInfo)) {
if (alarmType == AlarmType.IoSingleTimeOut) {
alarmType = AlarmType.None;
}
}
}
return MoveInfo.IsInWait;
......@@ -227,6 +233,7 @@ namespace DeviceLibrary
{
AxisBean axisBean=null;
axisBean = RobotManage.t1Machine.T_Batch_Axis;
//if (wait.AxisInfo.ProName == "Right_Batch_Axis")
// axisBean = Right_Batch_Axis;
//else
......
......@@ -119,7 +119,15 @@ namespace DeviceLibrary
T1_08_DownToShelf,
T1_09_ReleaseReel,
T1_10_PutReelFinish,
LblSendOut_01,
LblSendOut_02,
LblSendOut_03,
LblVacuum_01,
LblVacuum_02,
LblVacuum_03,
LblVacuum_end,
LblVacuum_failure,
LblVacuum_printfail,
}
......
......@@ -3,6 +3,7 @@ using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
......@@ -37,6 +38,10 @@ namespace DeviceLibrary
public static WistonAgvClient wistonAgvClient;
public static bool offlinemode = false;
public static ReelLocation offlinereelLocation = new ReelLocation();
public static LineRunMonitor Line1;
public static LineRunMonitor Line2;
public static Stopwatch ProductivityStopwatch = new Stopwatch();
public static List<float> Productivity = new List<float>();
//static string baseDir = Application.StartupPath;
public static void Init() {
try
......@@ -90,8 +95,8 @@ namespace DeviceLibrary
//xrayImage.Close();
var ElectricGripperPort = ConfigHelper.Config.Get("ElectricGripperPort");
electricGripper = new ElectricGripper();
if (!electricGripper.OpenPort(ElectricGripperPort)) {
electricGripper = new ElectricGripper(ElectricGripperPort);
if (!electricGripper.OpenPort()) {
msgs += $"电夹爪通讯失败:{ElectricGripperPort}\n";
IsLoadOk = false;
}
......@@ -102,6 +107,8 @@ namespace DeviceLibrary
IsLoadOk = false;
msgs += "IO板卡初始化失败\n";
}
Line1 = new LineRunMonitor("line1", labelMachine.Config.DOList[IO_Label_Type.Line1_Run].GetIOAddr());
Line2 = new LineRunMonitor("line2", labelMachine.Config.DOList[IO_Label_Type.Line2_Run].GetIOAddr());
LoadFinishEvent?.Invoke(IsDebug?IsDebug:IsLoadOk, msgs);
}
catch (Exception ex) {
......
......@@ -29,16 +29,19 @@ namespace DeviceLibrary
//public bool UserPause { get; set; }
public bool IgnoreSafecheck { get; set; }
public bool IgnoreGratingSignal { get; set; }
AxisBean T_Batch_Axis;
public AxisBean T_Batch_Axis;
AxisBean T_Pan_Axis;
AxisBean T_Updown_Axis;
AxisBean T_TrayPos_Axis;
AxisBean T_Y_Axis;
MoveInfo ShelfOutMoveInfo;
MoveInfo ShelfInMoveInfo;
public LineManager ShelfOutLine;
public LineManager ShelfInLine;
public LineRunMonitor ShelfOutLine;
public LineRunMonitor ShelfInLine;
public event EventHandler<Bitmap> TrayStringLocation;
public Point CenterPos = Point.Empty;
public bool Init(out string msg)
{
msg = "";
......@@ -53,6 +56,7 @@ namespace DeviceLibrary
T_Pan_Axis = new AxisBean(Config.T_Pan_Axis, DeviceName);
T_Updown_Axis = new AxisBean(Config.T_Updown_Axis, DeviceName);
T_TrayPos_Axis = new AxisBean(Config.T_TrayPos_Axis, DeviceName);
T_Y_Axis = new AxisBean(Config.T_Y_Axis, DeviceName);
#endregion
MoveInfo = new MoveInfo(DeviceName);
......@@ -60,12 +64,13 @@ namespace DeviceLibrary
ShelfOutMoveInfo = new MoveInfo("出料串线体");
ShelfInMoveInfo = new MoveInfo("入料串线体");
ShelfOutLine = new LineManager(IO_T1_Type.Line_Out_Run, Config, "ShelfOutLine");
ShelfInLine = new LineManager(IO_T1_Type.Empty_Line_Run, Config, "ShelfInLine");
ShelfOutLine = new LineRunMonitor("ShelfOutLine",Config.DOList[IO_T1_Type.Line_Out_Run].GetIOAddr());
ShelfInLine = new LineRunMonitor("ShelfInLine",Config.DOList[IO_T1_Type.Empty_Line_Run].GetIOAddr());
RobotManage.wistonAgvClient.EmptyShelfInReady += WistonAgvClient_EmptyShelfInReady;
RobotManage.wistonAgvClient.FullShelfOutReady += WistonAgvClient_FullShelfOutReady;
CenterPos = new Point(Config.String_Center_X, Config.String_Center_Y);
LastStringCenter = CenterPos;
LedProcessInit();
IOMonitor.RegisterIO(IO_T1_Type.Empty_LineIn_Check, Config, IO_VALUE.HIGH, delegate() { EmptyStringIN(); });
}
......@@ -142,11 +147,13 @@ namespace DeviceLibrary
{
Alarm(AlarmType.SuddenStop);
Msg.add("急停中", MsgLevel.warning);
Thread.Sleep(1000);
ok = false;
}
else if (alarmType == AlarmType.SuddenStop)
{
Msg.add("系统需要重置", MsgLevel.info);
Thread.Sleep(1000);
ok = false;
}
......@@ -219,6 +226,7 @@ namespace DeviceLibrary
T_Pan_Axis.HomeMove(ResetMoveInfo);
T_Updown_Axis.HomeMove(ResetMoveInfo);
T_TrayPos_Axis.HomeMove(ResetMoveInfo);
T_Y_Axis.HomeMove(ResetMoveInfo);
break;
case MoveStep.H04_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.H05_HomeReset);
......@@ -235,6 +243,7 @@ namespace DeviceLibrary
T_Pan_Axis.AbsMove(ResetMoveInfo, Config.Pan_P1, Config.Pan_P1_speed);
T_Updown_Axis.AbsMove(ResetMoveInfo, Config.UpdownAxis_P1, Config.UpdownAxis_P1_speed);
T_TrayPos_Axis.AbsMove(ResetMoveInfo, Config.TrayPos_P1, Config.TrayPos_P1_speed);
T_Y_Axis.AbsMove(ResetMoveInfo, Config.Y_P1, Config.Y_P1_speed);
break;
case MoveStep.H06_HomeReset:
ResetMoveInfo.NextMoveStep(MoveStep.HEND_HomeReset);
......
......@@ -26,10 +26,11 @@ namespace DeviceLibrary
switch (MoveInfo.MoveStep)
{
case MoveStep.XRay_01_LocationDown:
MoveInfo.StopwatchReset();
MoveInfo.NextMoveStep(MoveStep.XRay_02_RunIn);
MoveInfo.log($"定位气缸下降,打开点料机入口门");
CylinderMove(MoveInfo, IO_XRay_Type.Location_Cylinder_Down, IO_XRay_Type.Location_Cylinder_Up, IO_VALUE.LOW);
CylinderMove(MoveInfo, IO_XRay_Type.Entry_Close, IO_XRay_Type.Entry_Open, IO_VALUE.HIGH);
CylinderMove(null, IO_XRay_Type.Entry_Close, IO_XRay_Type.Entry_Open, IO_VALUE.HIGH);
break;
case MoveStep.XRay_02_RunIn:
MoveInfo.NextMoveStep(MoveStep.XRay_03_CloseDoor);
......@@ -47,55 +48,48 @@ namespace DeviceLibrary
CylinderMove(MoveInfo, IO_XRay_Type.Entry_Close, IO_XRay_Type.Entry_Open, IO_VALUE.LOW);
CylinderMove(MoveInfo, IO_XRay_Type.Location_Cylinder_Down, IO_XRay_Type.Location_Cylinder_Up, IO_VALUE.HIGH);
IOMove(IO_XRay_Type.Xray_Lock, IO_VALUE.HIGH);
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
break;
case MoveStep.XRay_04_OpenXray:
MoveInfo.NextMoveStep(MoveStep.XRay_05_GetImage);
RobotManage.XRay.Start();
MoveInfo.log($"打开X光");
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(2000));
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
break;
case MoveStep.XRay_05_GetImage:
if (GrabImage())
{
MoveInfo.NextMoveStep(MoveStep.XRay_08_OpenOutDoor);
MoveInfo.NextMoveStep(MoveStep.XRay_09_SentToLabelStop);
MoveInfo.log($"获取图像,开始点料 IsRayOpen:{RobotManage.XRay.IsRayOpen}");
GetResultTask = Task.Run(()=> { GetCountResult(); });
}
else {
MoveInfo.NextMoveStep(MoveStep.XRay_08_OpenOutDoor);
MoveInfo.NextMoveStep(MoveStep.XRay_09_SentToLabelStop);
//Msg.add("图像平板获取图像失败",MsgLevel.warning);
MoveInfo.ReelParam.IsNg = true;
MoveInfo.ReelParam.NgMsg = "获取图像失败";
MoveInfo.ReelParam.logresult();
}
MoveInfo.log($"关闭X光");
RobotManage.XRay.Stop();
MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
RobotManage.XRay.Stop();
IOMove(IO_XRay_Type.Xray_Lock, IO_VALUE.LOW);
MoveInfo.StopwatchLog(false, "准备送出");
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(500));
break;
case MoveStep.XRay_08_OpenOutDoor:
MoveInfo.NextMoveStep(MoveStep.XRay_09_SentToLabelStop);
IOMove(IO_XRay_Type.Xray_Lock, IO_VALUE.LOW);
MoveInfo.log($"打开出口门");
MoveInfo.NextMoveStep(MoveStep.XRay_09_SentToLabelStop);
MoveInfo.log($"打开出口门");
break;
case MoveStep.XRay_09_SentToLabelStop:
if (RobotManage.labelMachine.TrayCanIN())
{
MoveInfo.NextMoveStep(MoveStep.XRay_10_CloseOutDoor);
MoveInfo.log($"打开出口门,送出到贴标机构");
CylinderMove(MoveInfo, IO_XRay_Type.Exit_Close, IO_XRay_Type.Exit_Open, IO_VALUE.HIGH);
//Line_In_Axis.RelMove(ResetMoveInfo, (int)(Config.Line_In_Relative), Config.Line_In_Relative_speed*2);
CylinderMove(null, IO_XRay_Type.Exit_Close, IO_XRay_Type.Exit_Open, IO_VALUE.HIGH);
Line_In_Axis.SpeedMove(Config.Line_In_Relative_speed*2);
RobotManage.labelMachine.InLineRunControl(IO_VALUE.HIGH);
//Task.Run(()=>{
// while (true) {
// if (RobotManage.labelMachine.Tray_Check.Equals(IO_VALUE.HIGH)) {
// RobotManage.labelMachine.InLineRunControl(IO_VALUE.LOW);
// break;
// }
// Task.Delay(30).Wait();
// }
//});
RobotManage.Line1.LineRun("xray", 999, "XRay_09_SentToLabelStop");
MoveInfo.StopwatchLog(false, "开始送出");
}
else if (MoveInfo.IsTimeOut(30)) {
Msg.add("等待贴标机构入口空闲", MsgLevel.warning);
......@@ -105,11 +99,13 @@ namespace DeviceLibrary
case MoveStep.XRay_10_CloseOutDoor:
if (RobotManage.labelMachine.Tray_Check.Equals(IO_VALUE.HIGH))
{
RobotManage.labelMachine.InLineRunControl(IO_VALUE.LOW);
//RobotManage.labelMachine.InLineRunControl(IO_VALUE.LOW);
RobotManage.Line1.LineStop("xray", "XRay_10_CloseOutDoor");
MoveInfo.NextMoveStep(MoveStep.XRay_11_GetCoutResult);
MoveInfo.log($"关闭出口门,停止X光机内线体");
Line_In_Axis.SuddenStop();
CylinderMove(MoveInfo, IO_XRay_Type.Exit_Close, IO_XRay_Type.Exit_Open, IO_VALUE.LOW);
CylinderMove(null, IO_XRay_Type.Exit_Close, IO_XRay_Type.Exit_Open, IO_VALUE.LOW);
MoveInfo.StopwatchLog(false, "到达阻挡");
}
else if (MoveInfo.IsTimeOut(10))
{
......@@ -123,6 +119,7 @@ namespace DeviceLibrary
RobotManage.labelMachine.preReelParam = MoveInfo.ReelParam;
MoveInfo.NextMoveStep(MoveStep.XRay_End);
MoveInfo.log($"获得点料结果 QTY:{MoveInfo.ReelParam.QTY}");
MoveInfo.StopwatchLog(false, "获得点料结果");
}
else if (MoveInfo.IsTimeOut(30)) {
MoveInfo.NextMoveStep(MoveStep.XRay_End);
......@@ -134,9 +131,8 @@ namespace DeviceLibrary
}
break;
case MoveStep.XRay_End:
//MoveInfo.NextMoveStep(MoveStep.Feeding_05_Goto_Xray);
MoveInfo.log($"送出到贴标机构");
//MoveInfo.WaitList.Add(WaitResultInfo.WaitTime(1000));
MoveInfo.StopwatchLog();
MoveInfo.EndMove();
break;
}
......
......@@ -136,12 +136,14 @@ namespace DeviceLibrary
{
Alarm(AlarmType.SuddenStop);
Msg.add("急停中", MsgLevel.warning);
Thread.Sleep(1000);
ok = false;
}
else if (alarmType == AlarmType.SuddenStop)
{
Msg.add("系统需要重置", MsgLevel.info);
Thread.Sleep(1000);
ok = false;
}
if (IOValue(IO_XRay_Type.Airpressure_Check).Equals(IO_VALUE.LOW))
......
......@@ -118,7 +118,7 @@ namespace DeviceLibrary
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(Config, targetPosition, targetSpeed));
Config.TargetPosition = targetPosition;
var r = AxisManager.AbsMove(Config.DeviceName, Config.GetAxisValue(), targetPosition, targetSpeed, Config.AddSpeed, Config.DelSpeed);
var r = AxisManager.AbsMove(Config.DeviceName, Config.GetAxisValue(), targetPosition, targetSpeed, targetSpeed*4, targetSpeed * 4);
if (!r)
MoveInfo.log($"运动规划失败:{Config.DeviceName},{Config.GetAxisValue()},targetPosition:{targetPosition},targetSpeed:{targetSpeed},AddSpeed:{Config.AddSpeed},DelSpeed:{Config.DelSpeed}");
}
......@@ -127,13 +127,13 @@ namespace DeviceLibrary
{
if (MoveInfo == null)
{
AxisManager.RelMove(Config.DeviceName, Config.GetAxisValue(), targetPosition, targetSpeed, Config.AddSpeed, Config.DelSpeed);
AxisManager.RelMove(Config.DeviceName, Config.GetAxisValue(), targetPosition, targetSpeed, targetSpeed*4, targetSpeed * 4);
}
else
{
MoveInfo.WaitList.Add(WaitResultInfo.WaitAxis(Config, targetPosition, targetSpeed, true));
Config.TargetPosition = targetPosition;
AxisManager.RelMove(Config.DeviceName, Config.GetAxisValue(), targetPosition, targetSpeed, Config.AddSpeed, Config.DelSpeed);
AxisManager.RelMove(Config.DeviceName, Config.GetAxisValue(), targetPosition, targetSpeed, targetSpeed * 4, targetSpeed * 4);
}
}
public void SpeedMove(int targetSpeed)
......@@ -183,7 +183,7 @@ namespace DeviceLibrary
AxisManager.SuddenStop(axis);
Thread.Sleep(500);
LogUtil.error($"{ MoveInfo.Name} {MoveInfo.MoveStep} {axis.DisplayStr}目标位置{targetPosition}当前位置{outCount},误差过大,{clearMsg}重新开始运动,剩余{MoveInfo.CanWhileCount}次");
AxisManager.AbsMove(axis.DeviceName, axis.GetAxisValue(), targetPosition, targetSpeed, axis.AddSpeed, axis.DelSpeed);
AxisManager.AbsMove(axis.DeviceName, axis.GetAxisValue(), targetPosition, targetSpeed, targetSpeed*4, targetSpeed * 4);
MoveInfo.CanWhileCount--;
Thread.Sleep(1000);
}
......@@ -294,7 +294,7 @@ namespace DeviceLibrary
{
targetSpeed = Config.TargetSpeed * targetSpeed;
}
AxisManager.AbsMove(Config.DeviceName, Config.GetAxisValue(), targetPos, (int)targetSpeed, Config.AddSpeed, Config.DelSpeed);
AxisManager.AbsMove(Config.DeviceName, Config.GetAxisValue(), targetPos, (int)targetSpeed, (int)targetSpeed * 4, (int)targetSpeed * 4);
}
public void SuddenStop()
......
......@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.ExceptionServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;
......@@ -211,18 +212,25 @@ namespace DeviceLibrary
/// <param name="src"></param>
/// <param name="cropRect"></param>
/// <returns></returns>
[HandleProcessCorruptedStateExceptions]
public static Bitmap ImageCrop(Bitmap src, Rectangle cropRect)
{
//Rectangle cropRect = new Rectangle(0, 0, 400, 400);
Bitmap target = new Bitmap(cropRect.Width, cropRect.Height,System.Drawing.Imaging.PixelFormat.Format24bppRgb);
using (Graphics g = Graphics.FromImage(target))
try
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
using (Graphics g = Graphics.FromImage(target))
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None;
g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height),
cropRect,
GraphicsUnit.Pixel);
g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height),
cropRect,
GraphicsUnit.Pixel);
}
}
catch(Exception e) {
LogUtil.info("ImageCrop" + e.ToString());
}
return target;
}
......@@ -261,19 +269,26 @@ namespace DeviceLibrary
double cos = num / (Math.Sqrt(numA) * Math.Sqrt(numB));
return cos;
}
[HandleProcessCorruptedStateExceptions]
public static T DeepClone<T>(T _object)
{
T dstobject;
using (MemoryStream mStream = new MemoryStream())
try
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(mStream, _object);
mStream.Seek(0, SeekOrigin.Begin);//指定当前流的位置为流的开头。
dstobject = (T)bf.Deserialize(mStream);
mStream.Close();
T dstobject;
using (MemoryStream mStream = new MemoryStream())
{
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(mStream, _object);
mStream.Seek(0, SeekOrigin.Begin);//指定当前流的位置为流的开头。
dstobject = (T)bf.Deserialize(mStream);
mStream.Close();
}
return dstobject;
}
catch (Exception e) {
LogUtil.info("GetStringCenterA" + e.ToString());
return default;
}
return dstobject;
}
}
public class Msg
......
......@@ -2,6 +2,7 @@
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......@@ -13,6 +14,8 @@ namespace DeviceLibrary
public static List<MoveInfo> List = new List<MoveInfo>();
public int TimeOutSeconds = 60;
public bool Hide = false;
Stopwatch Stopwatch = new Stopwatch();
public MoveInfo(string name)
{
ReelParam = new ReelParam();
......@@ -138,6 +141,16 @@ namespace DeviceLibrary
LogUtil.error(msg);
}
}
public void StopwatchReset() {
Stopwatch.Restart();
}
public void StopwatchLog(bool isend=true,string dec="")
{
log($"时间{(isend?"总计":"小计")} {dec}:"+Stopwatch.Elapsed.ToString());
}
}
public class WaitResultInfo
......
类型,分类编号,说明,名称,属性值,设备名称,电器定义,目标速度,加速时间,减速时间,原点低速度,原点高速,原点加速度,脉冲最小误差,脉冲最大误差,脉冲最小限位,脉冲最大限位
AXIS,,取料机构旋转轴,Take_Middle_Axis,0,HC,,500,1000,1000,100,200,1000,10,100,0,0
AXIS,,取料机构上下轴,Take_UpDown_Axis,1,HC,,1000,1000,1000,200,500,500,10,100,0,0
AXIS,,左轨道提升轴,Left_Batch_Axis,2,HC,,3000,1000,1000,200,1000,200,10,100,0,0
AXIS,,右轨道提升轴,Right_Batch_Axis,3,HC,,3000,1000,1000,200,1000,200,10,100,0,0
AXIS,,贴标移栽机构X轴,Label_X_Axis,4,HC,,100,700,700,50,250,500,10,100,0,0
AXIS,,贴标移栽机构Y轴,Label_Y_Axis,5,HC,,100,700,700,50,150,500,10,100,0,0
AXIS,,贴标移栽机构Z轴,Label_Z_Axis,6,HC,,100,800,800,50,150,500,10,100,0,0
AXIS,,贴标移栽机构R轴,Label_R_Axis,7,HC,,10,2000,2000,1,5,200,500,100,0,0
,,,,,,,,,,,,,,,,
PRO,30,IO信号超时时间(秒),IOSingle_TimerOut,15,,,,,,,,,,,,
PRO,30,气压检测超时,AirCheckSeconds,5,,,,,,,,,,,,
PRO,20,右侧提升轴每毫米脉冲,Right_Batch_ChangeValue,5555,,,,,,,,,,,,
PRO,20,左侧提升轴每毫米脉冲,Left_Batch_ChangeValue,5555,,,,,,,,,,,,
PRO,30,右侧相机名称,RightCameraName,123123,,,,,,,,,,,,
PRO,30,右侧轴心坐标X,Right_Batch_X,222,,,,,,,,,,,,
PRO,30,右侧轴心坐标Y,Right_Batch_Y,333,,,,,,,,,,,,
PRO,30,贴标R轴0位角度差,Label_R_Angle_Diff,90,,,,,,,,,,,,
PRO,30,贴标R轴360度脉冲,Label_R_360,9,,,,,,,,,,,,
PRO,30,贴标X轴基准点,Label_X_Base,8,,,,,,,,,,,,
PRO,30,贴标Y轴基准点,Label_Y_Base,7,,,,,,,,,,,,
PRO,30,图像/X轴比值,Cam_Pixel_X_Ratio,6,,,,,,,,,,,,
PRO,30,图像/Y轴比值,Cam_Pixel_Y_Ratio,5,,,,,,,,,,,,
PRO,30,像素偏离位置7寸,Label_Offset_Pixel_7,200,,,,,,,,,,,,
PRO,30,像素偏离位置13寸,Label_Offset_Pixel_13,200,,,,,,,,,,,,
PRO,30,像素偏离位置15寸,Label_Offset_Pixel_15,200,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,10,取料旋转轴待机点P1,Take_Middle_P1,1,,,99,,,,,,,,,
PRO,10,取料旋转轴右取料点P2,Take_Middle_P2,2,,,99,,,,,,,,,
PRO,10,取料旋转轴左取料点P3,Take_Middle_P3,3,,,99,,,,,,,,,
PRO,10,取料旋转轴NG放料点P5,Take_Middle_P5,4,,,99,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,11,取料上下轴待机点P1,Take_UpDown_P1,6,,,88,,,,,,,,,
PRO,11,取料上下轴取料高点P2,Take_UpDown_P2,7,,,88,,,,,,,,,
PRO,11,取料上下轴取右料低点P3,Take_UpDown_P3,8,,,88,,,,,,,,,
PRO,11,取料上下轴取左料低点P4,Take_UpDown_P4,9,,,88,,,,,,,,,
PRO,11,取料上下轴NG放料点P5,Take_UpDown_P5,10,,,88,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,12,右提升轴低点P1,Right_Batch_P1,12,,,66,,,,,,,,,
PRO,12,右提升轴高点P2,Right_Batch_P2,13,,,66,,,,,,,,,
PRO,12,左提升轴低点P1,Left_Batch_P1,14,,,66,,,,,,,,,
PRO,12,左提升轴高点P2,Left_Batch_P2,15,,,66,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,13,贴标X轴待机点P1,Label_X_P1,17,,,77,,,,,,,,,
PRO,13,贴标X轴取标点P2,Label_X_P2,18,,,77,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,14,贴标Y轴待机点P1,Label_Y_P1,21,,,44,,,,,,,,,
PRO,14,贴标Y轴取标点P2,Label_Y_P2,22,,,44,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,15,贴标Z轴待机点P1,Label_Z_P1,25,,,44,,,,,,,,,
PRO,15,贴标Z轴取标点P2,Label_Z_P2,26,,,44,,,,,,,,,
PRO,15,贴标Z轴贴标点P3,Label_Z_P3,27,,,44,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,16,贴标R轴待机点P1,Label_R_P1,29,,,22,,,,,,,,,
PRO,16,贴标R轴取标点P2,Label_R_P2,30,,,22,,,,,,,,,
,,,,,,,,,,,,,,,,
DI,0,急停,SuddenStop_BTN,0,HC,X00,,,,,,,,,,
DI,0,进料口确认按钮,Right_BTN,1,HC,X01,,,,,,,,,,
DI,0,出料口确认按钮,Left_BTN,2,HC,X02,,,,,,,,,,
DI,0,后门左门禁,LeftBackDoor_Check,3,HC,X03,,,,,,,,,,
DI,0,后门右门禁,RightBackDoor_Check,4,HC,X04,,,,,,,,,,
DI,0,气压检测,Airpressure_Check,5,HC,X05,,,,,,,,,,
DI,0,光栅信号,GratingSignal_Check,6,HC,X06,,,,,,,,,,
DI,0,NG料箱检测,HasNgBox,7,HC,X07,,,,,,,,,,
DI,0,打印机到位检测,HasPrinter,8,HC,X08,,,,,,,,,,
DI,0,旋转臂进料侧检测,RightArm_Check,9,HC,X09,,,,,,,,,,
DI,0,旋转臂出料侧检测,LeftArm_Check,10,HC,X10,,,,,,,,,,
DI,0,进料口料车检测,RightCar_Check,11,HC,X11,,,,,,,,,,
DI,0,进料口前端料串检测,RightFornt_Check,12,HC,X12,,,,,,,,,,
DI,0,进料口料串到位检测,RightEnd_Check,13,HC,X13,,,,,,,,,,
DI,0,进料口阻挡气缸上升端,RightStopUP,14,HC,X14,,,,,,,,,,
DI,0,进料口阻挡气缸下降端,RightStopDown,15,HC,X15,,,,,,,,,,
DI,0,出料口料车检测,LeftCar_Check,16,HC,X16,,,,,,,,,,
DI,0,出料口前端料串检测,LeftFornt_Check,17,HC,X17,,,,,,,,,,
DI,0,出料口料串到位检测,LeftEnd_Check,18,HC,X18,,,,,,,,,,
DI,0,出料口阻挡气缸上升端,LeftStopUP,19,HC,X19,,,,,,,,,,
DI,0,出料口阻挡气缸下降端,LeftStopDown,20,HC,X20,,,,,,,,,,
DI,0,进料定位料盘检测,RightTop_Check,21,HC,X21,,,,,,,,,,
DI,0,进料定位料盘超限检测,RightOverHead_Check,22,HC,X22,,,,,,,,,,
DI,0,出料定位料盘检测,LeftTop_Check,23,HC,X23,,,,,,,,,,
DI,0,出料定位料盘超限检测,LeftOverHead_Check,24,HC,X24,,,,,,,,,,
DI,0,吸嘴气缸前进端,LabelCylinder_Fwd,25,HC,X25,,,,,,,,,,
DI,0,吸嘴气缸后退端,LabelCylinder_Bck,26,HC,X26,,,,,,,,,,
,,,,,,,,,,,,,,,,
DO,0,自动指示灯,AutoRun_HddLed,0,HC,Y00,,,,,,,,,,
DO,0,故障指示灯,Alarm_HddLed,1,HC,Y01,,,,,,,,,,
DO,0,待机指示灯,RunSign_HddLed,2,HC,Y02,,,,,,,,,,
DO,0,报警蜂鸣器,Alarm_Buzzer,3,HC,Y03,,,,,,,,,,
DO,0,进料口状态指示灯,RightState_Led,4,HC,Y04,,,,,,,,,,
DO,0,出料口状态指示灯,LeftState_Led,5,HC,Y05,,,,,,,,,,
DO,0,设备照明,Device_Led,6,HC,Y06,,,,,,,,,,
DO,0,相机照明,Camera_Led,7,HC,Y07,,,,,,,,,,
DO,0,进料口电机启动,RightMoto_Run,8,HC,Y08,,,,,,,,,,
DO,0,进料口电机反转指令,RightMoto_Reverse,9,HC,Y09,,,,,,,,,,
DO,0,出料口电机启动,LeftMoto_Run,10,HC,Y10,,,,,,,,,,
DO,0,出料口电机反转指令,LeftMoto_Reverse,11,HC,Y11,,,,,,,,,,
DO,0,进料口阻挡气缸上升,RightStopUP,12,HC,Y12,,,,,,,,,,
DO,0,进料口阻挡气缸下降,RightStopDown,13,HC,Y13,,,,,,,,,,
DO,0,出料口阻挡气缸上升,LeftStopUP,14,HC,Y14,,,,,,,,,,
DO,0,出料口阻挡气缸下降,LeftStopDown,15,HC,Y15,,,,,,,,,,
DO,0,吸嘴气缸前进,LabelCylinder_Fwd,16,HC,Y16,,,,,,,,,,
DO,0,吸嘴气缸后退,LabelCylinder_Bck,17,HC,Y17,,,,,,,,,,
DO,0,吸嘴取标,LabelCylinder_Work,18,HC,Y18,,,,,,,,,,
,,,,,,,,,,,,,,,,
类型,分类编号,说明,名称,属性值,设备名称,电器定义,目标速度,加速时间,减速时间,原点低速度,原点高速,原点加速度,脉冲最小误差,脉冲最大误差,脉冲最小限位,脉冲最大限位
PRO,30,IO信号超时时间(秒),IOSingle_TimerOut,15,,,,,,,,,,,,
PRO,30,气压检测超时,AirCheckSeconds,5,,,,,,,,,,,,
PRO,20,右侧提升轴每毫米脉冲,Right_Batch_ChangeValue,5555,,,,,,,,,,,,
PRO,20,左侧提升轴每毫米脉冲,Left_Batch_ChangeValue,5555,,,,,,,,,,,,
PRO,30,右侧相机名称,RightCameraName,123123,,,,,,,,,,,,
PRO,30,右侧轴心坐标X,Right_Batch_X,222,,,,,,,,,,,,
PRO,30,右侧轴心坐标Y,Right_Batch_Y,333,,,,,,,,,,,,
PRO,30,贴标R轴0位角度差,Label_R_Angle_Diff,90,,,,,,,,,,,,
PRO,30,贴标R轴360度脉冲,Label_R_360,9,,,,,,,,,,,,
PRO,30,贴标X轴基准点,Label_X_Base,8,,,,,,,,,,,,
PRO,30,贴标Y轴基准点,Label_Y_Base,7,,,,,,,,,,,,
PRO,30,图像/X轴比值,Cam_Pixel_X_Ratio,6,,,,,,,,,,,,
PRO,30,图像/Y轴比值,Cam_Pixel_Y_Ratio,5,,,,,,,,,,,,
PRO,30,像素偏离位置7寸,Label_Offset_Pixel_7,200,,,,,,,,,,,,
PRO,30,像素偏离位置13寸,Label_Offset_Pixel_13,200,,,,,,,,,,,,
PRO,30,像素偏离位置15寸,Label_Offset_Pixel_15,200,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
......@@ -3,12 +3,16 @@ AXIS,,出料提升轴,T_Batch_Axis,6,HC,,8000,15000,15000,500,4000,15000,10,100,0,0
AXIS,,出料移栽轴,T_Pan_Axis,7,HC,,20000,30000,30000,500,4000,15000,10,100,0,0
AXIS,,出料升降轴,T_Updown_Axis,8,HC,,20000,30000,30000,500,4000,15000,10,100,0,0
AXIS,,皮带线出口定位,T_TrayPos_Axis,9,HC,,35000,60000,60000,1000,5000,20000,500,100,0,0
AXIS,,出料移栽Y轴,T_Y_Axis,10,HC,,20000,30000,30000,500,4000,15000,10,100,0,0
,,,,,,,,,,,,,,,,
PRO,16,提升轴待机点 P1,BatchAxis_P1,500,,,8000,,,,,,,,,
PRO,16,提升轴上升目标点_P2,BatchAxis_P2,77756,,,8000,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,17,横移待机取料点P1,Pan_P1,5700,,,20000,,,,,,,,,
PRO,17,横移放料点P2,Pan_P2,77614,,,20000,,,,,,,,,
PRO,17,横移放料基准点P2,Pan_P2,77614,,,20000,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,20,Y轴待机取料点P1,Y_P1,5700,,,20000,,,,,,,,,
PRO,20,Y轴放料基准点P2,Y_P2,77614,,,20000,,,,,,,,,
,,,,,,,,,,,,,,,,
PRO,18,升降轴待机点P1,UpdownAxis_P1,7,,,20000,,,,,,,,,
PRO,18,升降轴取料点P2,UpdownAxis_P2,38420,,,20000,,,,,,,,,
......@@ -23,6 +27,8 @@ PRO,30,料串定位相机,String_Camera,GigE:MV-CE200-10GC (00F98806639),,,,,,,,,,,,
PRO,30,料串中心点X坐标,String_Center_X,1000,,,,,,,,,,,,
PRO,30,料串中心点Y坐标,String_Center_Y,1000,,,,,,,,,,,,
PRO,30,料串允许偏离像素值,String_Offset_Range_Px,1000,,,,,,,,,,,,
PRO,30,料串图像/X轴比值,Cam_Pixel_X_Ratio,147,,,,,,,,,,,,
PRO,30,料串图像/Y轴比值,Cam_Pixel_Y_Ratio,147,,,,,,,,,,,,
,,,,,,,,,,,,,,,,
DI,0,皮带线出口料盘检测,End_Line_Tray_Check,41,HC,X41,,,,,,,,,,
DI,0,皮带线出口顶升料盘检测,End_Lift_Tray_Check,42,HC,X42,,,,,,,,,,
......
......@@ -111,7 +111,7 @@
<Compile Include="DeviceLibrary\IOMonitor.cs" />
<Compile Include="DeviceLibrary\I_IOManager.cs" />
<Compile Include="DeviceLibrary\IOManager.cs" />
<Compile Include="DeviceLibrary\LineManager.cs" />
<Compile Include="DeviceLibrary\LineRunMonitor.cs" />
<Compile Include="DeviceLibrary\WistonAgvClientcs.cs" />
<Compile Include="MsgExtend.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
......@@ -143,7 +143,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Config\Config.csv">
<Content Include="Config\I40Config.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
......
......@@ -23,6 +23,7 @@ namespace DeviceLibrary
public static void SetOnOffAction(Action ona, Action offa) {
ondelegate = new on(ona);
offdelegate = new on(offa);
}
public static void ON(bool force=false) {
if (!Enable)
......@@ -32,14 +33,16 @@ namespace DeviceLibrary
if (force || (State != AlarmBuzzerState.ON && State != AlarmBuzzerState.MuteOnce))
{
State = AlarmBuzzerState.ON;
ondelegate();
ondelegate?.Invoke();
BuzzerStateChange?.Invoke(null, true);
}
}
public static void OFF()
{
if (State == AlarmBuzzerState.OFF)
return;
State = AlarmBuzzerState.OFF;
offdelegate();
offdelegate?.Invoke();
BuzzerStateChange?.Invoke(null, false);
}
public static void MuteOnce()
......@@ -47,7 +50,7 @@ namespace DeviceLibrary
if (State == AlarmBuzzerState.ON)
{
State = AlarmBuzzerState.MuteOnce;
offdelegate();
offdelegate?.Invoke();
BuzzerStateChange?.Invoke(null, false);
}
}
......
......@@ -11,13 +11,21 @@ namespace DeviceLibrary
public class ElectricGripper
{
private Neotel.Rmaxis axis;
private string Port = "";
public Enum GripperType = GripperTypeE.None;
int clampTimes = 0;
public bool OpenPort(string port)
public ElectricGripper(string port) {
Port = port;
}
public bool OpenPort()
{
axis = new Neotel.Rmaxis();
bool rtn = axis.OpenPort(port);
if(axis==null)
axis = new Neotel.Rmaxis();
if (axis.IsPortOpen)
return true;
bool rtn = axis.OpenPort(Port);
//var s = "版本号\r\n" + axis.GetVersion();
return rtn;
}
......@@ -27,13 +35,25 @@ namespace DeviceLibrary
}
public bool Clamp(MoveInfo moveInfo = null)
{
OpenPort();
GripperType = GripperTypeE.Gripper;
if (moveInfo != null)
moveInfo.WaitList.Add(WaitResultInfo.WaitAction(new Func<WaitResultInfo, bool>(WaitAction),"夹爪夹紧"));
LogUtil.info($"ElectricGripper Clamp");
if (axis.ErrorCode > 0)
{
LogUtil.info("ElectricGripper Clamp error:" + axis.ErrorCode.ToString() + axis.ErrorString);
axis.ResetError();
}
if (IsBusy)
{
axis.StopAxis();
Thread.Sleep(500);
}
if (!IsBusy)
{
axis.Push(50, 4.5f, 15);
axis.Push(50, 5.5f, 5);
clampTimes++;
if (moveInfo != null)
moveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
......@@ -46,12 +66,22 @@ namespace DeviceLibrary
}
public bool Release(MoveInfo moveInfo = null)
{
OpenPort();
GripperType = GripperTypeE.Release;
LogUtil.info($"ElectricGripper Release");
if (axis.ErrorCode > 0)
{
LogUtil.info("ElectricGripper Release error:" + axis.ErrorCode.ToString() + axis.ErrorString);
axis.ResetError();
}
if (IsBusy)
{
axis.StopAxis();
Thread.Sleep(500);
}
if (!IsBusy)
{
axis.MoveAbsolute(0, 30, 500, 500, 0.1f);
axis.MoveAbsolute(0.2f, 5, 15, 15, 1f);
clampTimes = 0;
if (moveInfo != null)
moveInfo.WaitList.Add(WaitResultInfo.WaitTime(100));
......@@ -72,6 +102,7 @@ namespace DeviceLibrary
}
public void HomeReset(MoveInfo moveInfo = null)
{
OpenPort();
GripperType = GripperTypeE.Reset;
//if (!IsBusy)
//{
......
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace DeviceLibrary
{
public class LineRunMonitor
{
Timer lineTimer = null;
Dictionary<string, DateTime> linrunlist = new Dictionary<string, DateTime>();
string Name;
ushort LineIO;
public LineRunMonitor(string name, ushort io) {
Name = name;
LineIO = io;
LineInit();
}
void LineInit()
{
if (lineTimer == null)
{
lineTimer = new Timer(100);
lineTimer.Elapsed += LineTimer_Elapsed;
lineTimer.Start();
GC.KeepAlive(lineTimer);
}
}
private void LineTimer_Elapsed(object sender, ElapsedEventArgs e)
{
lock (linrunlist)
{
if (canStopLine(out _) && DOValue(LineIO).Equals(IO_VALUE.HIGH))
{
DOMove(LineIO, IO_VALUE.LOW);
LogUtil.info(Name + $" 线体管理器 停止线体.");
}
}
}
private void DOMove(ushort LineIO, IO_VALUE iovalue)
{
IOManager.WriteSingleDO("", 0x00, LineIO, iovalue);
}
private object DOValue(ushort LineIO)
{
return IOManager.GetDOValue("", 0x00, LineIO);
}
/// <summary>
/// 控制线体运转
/// </summary>
/// <param name="id">需求方标识</param>
/// <param name="seconds">秒数</param>
public void LineRun(string id, int seconds, string parentname = "")
{
LineInit();
DOMove(LineIO, IO_VALUE.HIGH);
lock (linrunlist)
{
DOMove(LineIO, IO_VALUE.HIGH);
if (!string.IsNullOrEmpty(id) && seconds > 0)
{
if (linrunlist.ContainsKey(id))
linrunlist[id] = DateTime.Now.AddSeconds(seconds);
else
{
linrunlist.Add(id, DateTime.Now.AddSeconds(seconds));
}
LogUtil.info(Name + $" 线体管理器 {id},{parentname} 请求链条运行 {seconds}秒.");
}
}
}
public void LineStop(string id, string parentname = "")
{
lock (linrunlist)
{
if (!string.IsNullOrEmpty(id))
{
if (linrunlist.ContainsKey(id))
linrunlist.Remove(id);
LogUtil.info(Name + $" 线体管理器 {id},{parentname} 请求立刻停止线体.");
}
}
if (!canStopLine(out string msg))
LogUtil.info(Name + $" {Name}");
// IOMove(IO_Type.Line_Run, IO_VALUE.LOW);
}
bool canStopLine(out string msg)
{
msg = "";
bool canStop = true;
lock (linrunlist)
{
foreach (var x in linrunlist.ToList())
{
if (x.Value > DateTime.Now)
{
canStop = false;
msg = Name + $" 线体管理器 {x.Key} 不允许停止线体 需求停止时间 {x.Value.ToString()}.";
//LogUtil.info(Name + $" {x.Key} 不允许停止线体 需求停止时间 {x.Value.ToString()}.");
}
else
{
LogUtil.info(Name + $" 线体管理器 {x.Key} 请求时间已过期,删除.");
linrunlist.Remove(x.Key);
}
}
}
return canStop;
}
}
}
......@@ -31,6 +31,7 @@
this.components = new System.ComponentModel.Container();
this.groupAxis = new System.Windows.Forms.GroupBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.lblAlarmcode = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.lblhomeSts = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
......@@ -99,7 +100,6 @@
this.txtAxisDeviceName = new System.Windows.Forms.TextBox();
this.lblServerOn = new System.Windows.Forms.Label();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.lblAlarmcode = new System.Windows.Forms.Label();
this.groupAxis.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
......@@ -159,6 +159,18 @@
this.groupBox2.TabStop = false;
this.groupBox2.Text = "轴状态监控";
//
// lblAlarmcode
//
this.lblAlarmcode.AutoSize = true;
this.lblAlarmcode.Location = new System.Drawing.Point(433, 65);
this.lblAlarmcode.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblAlarmcode.Name = "lblAlarmcode";
this.lblAlarmcode.Size = new System.Drawing.Size(68, 17);
this.lblAlarmcode.TabIndex = 19;
this.lblAlarmcode.Tag = "not";
this.lblAlarmcode.Text = "错误码:160";
this.lblAlarmcode.Visible = false;
//
// label4
//
this.label4.AutoSize = true;
......@@ -177,6 +189,7 @@
this.lblhomeSts.Name = "lblhomeSts";
this.lblhomeSts.Size = new System.Drawing.Size(17, 17);
this.lblhomeSts.TabIndex = 17;
this.lblhomeSts.Tag = "not";
this.lblhomeSts.Text = "...";
//
// label2
......@@ -198,6 +211,7 @@
this.lblAxEncAcc.Name = "lblAxEncAcc";
this.lblAxEncAcc.Size = new System.Drawing.Size(17, 17);
this.lblAxEncAcc.TabIndex = 12;
this.lblAxEncAcc.Tag = "not";
this.lblAxEncAcc.Text = "...";
this.lblAxEncAcc.Visible = false;
//
......@@ -339,6 +353,7 @@
this.lblAxEncVel.Name = "lblAxEncVel";
this.lblAxEncVel.Size = new System.Drawing.Size(17, 17);
this.lblAxEncVel.TabIndex = 1;
this.lblAxEncVel.Tag = "not";
this.lblAxEncVel.Text = "...";
//
// lblAxPrfVel
......@@ -349,6 +364,7 @@
this.lblAxPrfVel.Name = "lblAxPrfVel";
this.lblAxPrfVel.Size = new System.Drawing.Size(17, 17);
this.lblAxPrfVel.TabIndex = 1;
this.lblAxPrfVel.Tag = "not";
this.lblAxPrfVel.Text = "...";
//
// lblAxEncPos
......@@ -359,6 +375,7 @@
this.lblAxEncPos.Name = "lblAxEncPos";
this.lblAxEncPos.Size = new System.Drawing.Size(17, 17);
this.lblAxEncPos.TabIndex = 1;
this.lblAxEncPos.Tag = "not";
this.lblAxEncPos.Text = "...";
//
// lblAxPrfPos
......@@ -369,6 +386,7 @@
this.lblAxPrfPos.Name = "lblAxPrfPos";
this.lblAxPrfPos.Size = new System.Drawing.Size(17, 17);
this.lblAxPrfPos.TabIndex = 1;
this.lblAxPrfPos.Tag = "not";
this.lblAxPrfPos.Text = "...";
//
// lblAxisPrfMode
......@@ -379,6 +397,7 @@
this.lblAxisPrfMode.Name = "lblAxisPrfMode";
this.lblAxisPrfMode.Size = new System.Drawing.Size(17, 17);
this.lblAxisPrfMode.TabIndex = 1;
this.lblAxisPrfMode.Tag = "not";
this.lblAxisPrfMode.Text = "...";
//
// label50
......@@ -422,6 +441,7 @@
this.txtBusyStatus.Name = "txtBusyStatus";
this.txtBusyStatus.Size = new System.Drawing.Size(25, 23);
this.txtBusyStatus.TabIndex = 288;
this.txtBusyStatus.Tag = "not";
//
// label11
//
......@@ -439,6 +459,7 @@
this.txtHomeStatus.Name = "txtHomeStatus";
this.txtHomeStatus.Size = new System.Drawing.Size(25, 23);
this.txtHomeStatus.TabIndex = 291;
this.txtHomeStatus.Tag = "not";
//
// label10
//
......@@ -496,6 +517,7 @@
this.txtAlarmStatus.Name = "txtAlarmStatus";
this.txtAlarmStatus.Size = new System.Drawing.Size(25, 23);
this.txtAlarmStatus.TabIndex = 285;
this.txtAlarmStatus.Tag = "not";
//
// txtLimit2
//
......@@ -504,6 +526,7 @@
this.txtLimit2.Name = "txtLimit2";
this.txtLimit2.Size = new System.Drawing.Size(25, 23);
this.txtLimit2.TabIndex = 313;
this.txtLimit2.Tag = "not";
//
// txtServoStatue
//
......@@ -512,6 +535,7 @@
this.txtServoStatue.Name = "txtServoStatue";
this.txtServoStatue.Size = new System.Drawing.Size(25, 23);
this.txtServoStatue.TabIndex = 327;
this.txtServoStatue.Tag = "not";
//
// label22
//
......@@ -530,6 +554,7 @@
this.txtLimit1.Name = "txtLimit1";
this.txtLimit1.Size = new System.Drawing.Size(25, 23);
this.txtLimit1.TabIndex = 309;
this.txtLimit1.Tag = "not";
//
// label6
//
......@@ -547,6 +572,7 @@
this.txtHomeSingle.Name = "txtHomeSingle";
this.txtHomeSingle.Size = new System.Drawing.Size(25, 23);
this.txtHomeSingle.TabIndex = 297;
this.txtHomeSingle.Tag = "not";
//
// panel1
//
......@@ -602,6 +628,7 @@
this.comjSpeed.Name = "comjSpeed";
this.comjSpeed.Size = new System.Drawing.Size(95, 28);
this.comjSpeed.TabIndex = 335;
this.comjSpeed.Tag = "not";
//
// btnComAlarmClear
//
......@@ -656,6 +683,7 @@
this.cmbAxis.Name = "cmbAxis";
this.cmbAxis.Size = new System.Drawing.Size(227, 28);
this.cmbAxis.TabIndex = 301;
this.cmbAxis.Tag = "not";
this.cmbAxis.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
//
// btnDelMove
......@@ -667,7 +695,7 @@
this.btnDelMove.Name = "btnDelMove";
this.btnDelMove.Size = new System.Drawing.Size(140, 45);
this.btnDelMove.TabIndex = 332;
this.btnDelMove.Text = "点动-(上升)";
this.btnDelMove.Text = "点动-";
this.btnDelMove.UseVisualStyleBackColor = false;
this.btnDelMove.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnDelMove_MouseDown);
this.btnDelMove.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnDelMove_MouseUp);
......@@ -713,7 +741,7 @@
this.btnAddMove.Name = "btnAddMove";
this.btnAddMove.Size = new System.Drawing.Size(140, 45);
this.btnAddMove.TabIndex = 330;
this.btnAddMove.Text = "点动+(上升)";
this.btnAddMove.Text = "点动+";
this.btnAddMove.UseVisualStyleBackColor = false;
this.btnAddMove.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btnAddMove_MouseDown);
this.btnAddMove.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btnAddMove_MouseUp);
......@@ -731,6 +759,7 @@
this.txtASpeed.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtASpeed.Size = new System.Drawing.Size(91, 26);
this.txtASpeed.TabIndex = 251;
this.txtASpeed.Tag = "not";
this.txtASpeed.Text = "200";
//
// label1
......@@ -822,6 +851,7 @@
this.lblCountPulse.ReadOnly = true;
this.lblCountPulse.Size = new System.Drawing.Size(118, 26);
this.lblCountPulse.TabIndex = 38;
this.lblCountPulse.Tag = "not";
//
// btnAxisAMove
//
......@@ -863,6 +893,7 @@
this.txtAPosition.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.txtAPosition.Size = new System.Drawing.Size(91, 26);
this.txtAPosition.TabIndex = 244;
this.txtAPosition.Tag = "not";
this.txtAPosition.Text = "3000";
//
// label46
......@@ -912,6 +943,7 @@
this.txtAxisValue.ReadOnly = true;
this.txtAxisValue.Size = new System.Drawing.Size(50, 26);
this.txtAxisValue.TabIndex = 242;
this.txtAxisValue.Tag = "not";
this.txtAxisValue.Text = "0";
//
// txtAxisDeviceName
......@@ -923,6 +955,7 @@
this.txtAxisDeviceName.ReadOnly = true;
this.txtAxisDeviceName.Size = new System.Drawing.Size(50, 26);
this.txtAxisDeviceName.TabIndex = 241;
this.txtAxisDeviceName.Tag = "not";
this.txtAxisDeviceName.Text = "0";
//
// lblServerOn
......@@ -941,22 +974,11 @@
this.timer1.Interval = 1000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// lblAlarmcode
//
this.lblAlarmcode.AutoSize = true;
this.lblAlarmcode.Location = new System.Drawing.Point(433, 65);
this.lblAlarmcode.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.lblAlarmcode.Name = "lblAlarmcode";
this.lblAlarmcode.Size = new System.Drawing.Size(68, 17);
this.lblAlarmcode.TabIndex = 19;
this.lblAlarmcode.Text = "错误码:160";
this.lblAlarmcode.Visible = false;
//
// AxisMoveControl
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.groupAxis);
this.DeviceName = "AxisMoveControl";
this.Name = "AxisMoveControl";
this.Size = new System.Drawing.Size(699, 402);
this.groupAxis.ResumeLayout(false);
this.groupAxis.PerformLayout();
......
......@@ -14,6 +14,7 @@ using HuichuanLibrary;
namespace DeviceLibrary
{
using crc = OnlineStore.CodeResourceControl;
public partial class AxisMoveControl : UserControl
{
public bool IsHuiChuan = true;
......@@ -26,9 +27,19 @@ namespace DeviceLibrary
public AxisMoveControl()
{
InitializeComponent();
this.Tag = "not";
crc.LanguageChangeEvent += CodeResourceControl_LanguageChange;
}
private void CodeResourceControl_LanguageChange(object sender, EventArgs e)
{
crc.LanguageProcess(this);
}
public void LoadData(DeviceConfig Config, bool isHc = true)
{
CodeResourceControl_LanguageChange(null,null);
//this.boxBean = equipBase;
axisList = new List<ConfigMoveAxis>(Config.moveAxisList);
......@@ -37,7 +48,7 @@ namespace DeviceLibrary
cmbAxis.Items.Clear();
foreach (ConfigMoveAxis a in axisList)
{
cmbAxis.Items.Add(a.Explain);
cmbAxis.Items.Add(crc.GetString(a.ProName,a.Explain));
}
cmbAxis.SelectedIndex = 0;
......@@ -94,7 +105,7 @@ namespace DeviceLibrary
int position = FormUtil.GetIntValue(txtAPosition);
int speed = FormUtil.GetIntValue(txtASpeed);
LogUtil.info(DeviceName+"点击【绝对运动】,【" + PortName + "_" + SlvAddr + "】位置【" + position + "】速度【" + speed + "】");
AxisManager.AbsMove(PortName, SlvAddr, position, speed,axis.AddSpeed,axis.DelSpeed);
AxisManager.AbsMove(PortName, SlvAddr, position, speed, speed*4, speed * 4);
}
private void btnAxisRMove_Click(object sender, EventArgs e)
......@@ -106,7 +117,7 @@ namespace DeviceLibrary
int position = FormUtil.GetIntValue(txtAPosition);
int speed = FormUtil.GetIntValue(txtASpeed);
LogUtil.info(DeviceName+"点击【相对运动】,【" + PortName + "_" + SlvAddr + "】位置【" + position + "】速度【" + speed + "】");
AxisManager.RelMove(PortName, SlvAddr, position, speed,axis.AddSpeed,axis.DelSpeed);
AxisManager.RelMove(PortName, SlvAddr, position, speed, speed * 4, speed * 4);//,axis.AddSpeed,axis.DelSpeed);
}
private void btnAxisVMove_Click(object sender, EventArgs e)
......@@ -200,8 +211,8 @@ namespace DeviceLibrary
comjSpeed.Items.Add(targetSpeed * i / 10);
}
comjSpeed.SelectedIndex = 4;
btnAddMove.Text = "点动+ ";
btnDelMove.Text = "点动- ";
//btnAddMove.Text = "点动+ ";
//btnDelMove.Text = "点动- ";
txtASpeed.Text = targetSpeed.ToString();
int SelIndex = cmbAxis.SelectedIndex;
......
......@@ -42,6 +42,12 @@ namespace OnlineStore.LoadCSVLibrary
[ConfigProAttribute("T_TrayPos_Axis")]
public ConfigMoveAxis T_TrayPos_Axis { get; set; }
/// <summary>
/// AXIS,,出料移栽Y轴,T_Y_Axis,10,HC,,20000,30000,30000,500,4000,15000,10,100,0,0
/// </summary>
[ConfigProAttribute("T_Y_Axis")]
public ConfigMoveAxis T_Y_Axis { get; set; }
/// <summary>
/// PRO,30,TrayPos定位列表,TrayPos_List,8=999;12=99;20=999,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("TrayPos_List")]
......@@ -162,6 +168,36 @@ namespace OnlineStore.LoadCSVLibrary
[ConfigProAttribute("String_Camera")]
public string String_Camera { get; set; }
/// <summary>
/// PRO,20,Y轴待机取料点P1,Y_P1,5700,,,20000,,,,,,,,,
/// </summary>
[ConfigProAttribute("Y_P1")]
public int Y_P1 { get; set; }
/// <summary>
/// PRO,20,Y轴放料基准点P2,Y_P2,77614,,,20000,,,,,,,,,
/// </summary>
[ConfigProAttribute("Y_P2")]
public int Y_P2 { get; set; }
/// <summary>
/// PRO,30,料串图像/X轴比值,Cam_Pixel_X_Ratio,147,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Cam_Pixel_X_Ratio")]
public int Cam_Pixel_X_Ratio { get; set; }
/// <summary>
/// PRO,30,料串图像/Y轴比值,Cam_Pixel_Y_Ratio,147,,,,,,,,,,,,
/// </summary>
[ConfigProAttribute("Cam_Pixel_Y_Ratio")]
public int Cam_Pixel_Y_Ratio { get; set; }
/// <summary>
/// PRO,20,Y轴待机取料点P1,Y_P1,5700,,,20000,,,,,,,,,
/// </summary>
[ConfigProAttribute("Y_P1_speed")]
public int Y_P1_speed { get; set; }
/// <summary>
/// PRO,20,Y轴放料基准点P2,Y_P2,77614,,,20000,,,,,,,,,
/// </summary>
[ConfigProAttribute("Y_P2_speed")]
public int Y_P2_speed { get; set; }
private Dictionary<int, int> TrayPos_ListMap = null;
public int GetTrayPos(int width = 8)
......
......@@ -14,6 +14,7 @@
<appSettings>
<!--是否开机自动启动料仓-->
<add key="App_AutoRun" value="1" />
<add key="Default_Language" value="zh-CN" />
<add key="CodeType" value="QR Code#Data Matrix ECC 200#barcode" />
<!--二维码参数文件所在路径,文件名与二维码类型名一样-->
<add key="CodeParamPath" value="Conifg\" />
......@@ -31,7 +32,16 @@
<conversionPattern value="[%date][%t]%-5p %m%n" />
</layout>
</appender>
<appender name="LngResource" type="log4net.Appender.RollingFileAppender">
<file value="logs/LngResource.log" />
<param name="Encoding" value="UTF-8" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy-MM-dd" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="[%date][%t]%-5p %m%n" />
</layout>
</appender>
<logger name="RollingLogFileAppender">
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
......@@ -40,6 +50,10 @@
<level value="ALL" />
<appender-ref ref="RollingLogFileAppender" />
</logger>
<logger name="LngResource">
<level value="Info" />
<appender-ref ref="LngResource" />
</logger>
<!--<root>
<level value="Info" />
<appender-ref ref="RollingLogFileAppender" />
......
......@@ -192,6 +192,7 @@ namespace AutoCountMachine
// tabPage2
//
this.tabPage2.Controls.Add(this.configControl1);
this.tabPage2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.tabPage2.Location = new System.Drawing.Point(4, 22);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Size = new System.Drawing.Size(1194, 533);
......@@ -204,7 +205,7 @@ namespace AutoCountMachine
this.configControl1.Config = null;
this.configControl1.Location = new System.Drawing.Point(3, 3);
this.configControl1.Name = "configControl1";
this.configControl1.Size = new System.Drawing.Size(1096, 516);
this.configControl1.Size = new System.Drawing.Size(663, 293);
this.configControl1.TabIndex = 0;
//
// FilterControl
......
......@@ -28,6 +28,15 @@ namespace AutoCountMachine
public FilterControl()
{
InitializeComponent();
RoleManger.RoleChange += RoleManger_RoleChange;
}
private void RoleManger_RoleChange(object sender, Role e)
{
tabPage2.Controls[0].Enabled = false;
if (e != Role.Admin)
return;
tabPage2.Controls[0].Enabled = true;
}
private void XrayControl_Load(object sender, EventArgs e)
......
......@@ -5,18 +5,15 @@ using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoCountMachine
{
using crc = OnlineStore.CodeResourceControl;
public partial class Form1 : Form
{
XrayControl xrayControl = new XrayControl();
......@@ -26,6 +23,7 @@ namespace AutoCountMachine
Dictionary<string, List<Msg>> MsgPool = new Dictionary<string, List<Msg>>();
readonly System.Windows.Forms.Timer t1 = new System.Windows.Forms.Timer();
//EventHandler<List<Msg>> MsgEventHandler;
public Form1()
{
......@@ -36,6 +34,38 @@ namespace AutoCountMachine
t1.Start();
GC.KeepAlive(t1);
this.FormClosing += Form1_FormClosing;
RoleManger.RoleChange += RoleManger_RoleChange;
this.Shown += Form1_Shown;
crc.GetLanguageEvent += Crc_GetLanguageEvent;
crc.LanguageChangeEvent += Crc_LanguageChangeEvent;
crc.OpenResourceLog = true;
}
private void Crc_LanguageChangeEvent(object sender, EventArgs e)
{
LanguageProcess();
}
private string Crc_GetLanguageEvent()
{
return ConfigAppSettings.GetValue("Default_Language");
}
private void Form1_Shown(object sender, EventArgs e)
{
LanguageProcess();
}
void LanguageProcess() {
crc.LanguageProcess(this, this.GetType().Name);
crc.ProcessListItem(menuStrip1.Items, "menuStrip1");
}
private void RoleManger_RoleChange(object sender, Role e)
{
tabPage2.Controls[0].Enabled = false;
if (e != Role.Admin)
return;
tabPage2.Controls[0].Enabled = true;
}
bool cancelcloseapp = true;
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
......@@ -77,6 +107,9 @@ namespace AutoCountMachine
stateView.Items.Clear();
foreach (MoveInfo moveInfo in MoveInfo.List)
{
if (moveInfo.Hide)
continue;
ListViewItem lvi = new ListViewItem(new string[] { moveInfo.Name, moveInfo.Name, moveInfo.MoveStep.ToString(), moveInfo.GetStateStr() });
stateView.Items.Add(lvi);
}
......@@ -152,7 +185,7 @@ namespace AutoCountMachine
stateView.Columns.Add(c4);
stateView.ColumnWidthChanging += listView_ColumnWidthChanging;
#endregion
#region 状态信息listview初始化
#region 料盘信息listview初始化
//$"ReeID,PN,WxH,ReelDest,NgMsg,QTY,2D_Barcode"
listView_reelnfo.View = View.Details;
ColumnHeader d1 = new ColumnHeader();
......@@ -173,7 +206,11 @@ namespace AutoCountMachine
LogUtil.info("开始初始化");
cb_EnableBuzzer.Checked = Config.Get("EnableBuzzer", true);
AlarmBuzzer.BuzzerStateChange += AlarmBuzzer_BuzzerStateChange;
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
cb_autorun.Checked = Config.Get("App_AutoRun", false);
this.cb_autorun.CheckedChanged += new System.EventHandler(this.cb_autorun_CheckedChanged);
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
//RobotManage.Init();
......@@ -186,10 +223,15 @@ namespace AutoCountMachine
lm.Add(m);
Device_ProcessMsgEvent(null, lm);
cmb_runmode.Text = "ONLINE";
RoleManger.SetRole(Role.User);
}
private void AlarmBuzzer_BuzzerStateChange(object sender, bool e)
{
btn_PauseBuzzer.Visible = e;
this.Invoke((EventHandler<bool>)delegate{
btn_PauseBuzzer.Visible = e;
}, sender,e);
}
private void listView_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{
......@@ -261,7 +303,9 @@ namespace AutoCountMachine
filterControl.Config = RobotManage.filterMachine.Config;
AddForm("分料线", filterControl);
t1Control.Config = RobotManage.t1Machine.Config;
AddForm("出料线", t1Control);
AddForm("出料线", t1Control);
RoleManger.SetRole(Role.User);
LanguageProcess();
}
private void AddForm(string text, UserControl form)
{
......@@ -415,5 +459,79 @@ namespace AutoCountMachine
{
AlarmBuzzer.MuteOnce();
}
private void cb_autorun_CheckedChanged(object sender, EventArgs e)
{
if (cb_autorun.Checked)
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 1);
AutoRun(Application.ExecutablePath, true);
}
else
{
ConfigAppSettings.SaveValue(Setting_Init.App_AutoRun, 0);
AutoRun(Application.ExecutablePath, false);
}
}
public static void AutoRun(string strName, bool value)
{
try
{
//创建启动对象
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
//设置运行文件
startInfo.FileName = System.Windows.Forms.Application.StartupPath + "\\AuToRunManager.exe";
//设置启动参数
startInfo.Arguments = String.Join(" ", new string[2] { strName, value.ToString() });
//设置启动动作,确保以管理员身份运行
startInfo.Verb = "runas";
//如果不是管理员,则启动UAC
System.Diagnostics.Process.Start(startInfo);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void 操作员ToolStripMenuItem_Click(object sender, EventArgs e)
{
RoleManger.SetRole(Role.User);
操作员ToolStripMenuItem.ShortcutKeyDisplayString = "√";
工程师ToolStripMenuItem.ShortcutKeyDisplayString = "";
}
private void 工程师ToolStripMenuItem_Click(object sender, EventArgs e)
{
FrmPassword frmPassword = new FrmPassword();
crc.LanguageProcess(frmPassword);
if (frmPassword.ShowDialog() == DialogResult.OK)
{
RoleManger.SetRole(Role.Admin);
操作员ToolStripMenuItem.ShortcutKeyDisplayString = "";
工程师ToolStripMenuItem.ShortcutKeyDisplayString = "√";
}
}
private void btn_setadminpassword_Click(object sender, EventArgs e)
{
FrmPassword frmPassword = new FrmPassword();
crc.LanguageProcess(frmPassword);
frmPassword.EditMode = true;
frmPassword.ShowDialog();
}
private void 简体中文ToolStripMenuItem_Click(object sender, EventArgs e)
{
ConfigAppSettings.SaveValue("Default_Language", "zh-CN");
crc.LanguageChange();
}
private void englishToolStripMenuItem_Click(object sender, EventArgs e)
{
ConfigAppSettings.SaveValue("Default_Language", "en-US");
crc.LanguageChange();
}
}
}
......@@ -33,6 +33,17 @@ namespace AutoCountMachine
{
InitializeComponent();
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
RoleManger.RoleChange += RoleManger_RoleChange;
}
private void RoleManger_RoleChange(object sender, Role e)
{
tabPage2.Controls[0].Enabled = false;
tabPage3.Controls[0].Enabled = false;
if (e != Role.Admin)
return;
tabPage2.Controls[0].Enabled = true;
tabPage3.Controls[0].Enabled = true;
}
private void XrayControl_Load(object sender, EventArgs e)
......
......@@ -88,6 +88,13 @@
<Compile Include="UCCOMMON\BoxResetControl.Designer.cs">
<DependentUpon>BoxResetControl.cs</DependentUpon>
</Compile>
<Compile Include="UCCOMMON\FrmPassword.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UCCOMMON\FrmPassword.Designer.cs">
<DependentUpon>FrmPassword.cs</DependentUpon>
</Compile>
<Compile Include="UCCOMMON\Role.cs" />
<Compile Include="UCCOMMON\VerticalProgressBar.cs">
<SubType>Component</SubType>
</Compile>
......@@ -147,6 +154,9 @@
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UCCOMMON\FrmPassword.resx">
<DependentUpon>FrmPassword.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UCCOMMON\IOControl.resx">
<DependentUpon>IOControl.cs</DependentUpon>
</EmbeddedResource>
......
......@@ -31,6 +31,7 @@ namespace AutoCountMachine
{
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.btn_closeclamp = new System.Windows.Forms.Button();
this.btn_Full_Linestop = new System.Windows.Forms.Button();
this.btn_Full_Linerun = new System.Windows.Forms.Button();
this.btn_Empty_Linestop = new System.Windows.Forms.Button();
......@@ -57,9 +58,9 @@ namespace AutoCountMachine
this.configControl1 = new AutoCountMachine.ConfigControl();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.label_eyemMulFuncTool = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.btn_eyemMulFuncTool = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
......@@ -82,6 +83,7 @@ namespace AutoCountMachine
//
// tabPage1
//
this.tabPage1.Controls.Add(this.btn_closeclamp);
this.tabPage1.Controls.Add(this.btn_Full_Linestop);
this.tabPage1.Controls.Add(this.btn_Full_Linerun);
this.tabPage1.Controls.Add(this.btn_Empty_Linestop);
......@@ -111,6 +113,16 @@ namespace AutoCountMachine
this.tabPage1.Text = "I/O控制";
this.tabPage1.UseVisualStyleBackColor = true;
//
// btn_closeclamp
//
this.btn_closeclamp.Location = new System.Drawing.Point(653, 455);
this.btn_closeclamp.Name = "btn_closeclamp";
this.btn_closeclamp.Size = new System.Drawing.Size(107, 35);
this.btn_closeclamp.TabIndex = 306;
this.btn_closeclamp.Text = "夹爪断连";
this.btn_closeclamp.UseVisualStyleBackColor = true;
this.btn_closeclamp.Click += new System.EventHandler(this.btn_closeclamp_Click);
//
// btn_Full_Linestop
//
this.btn_Full_Linestop.Location = new System.Drawing.Point(658, 249);
......@@ -408,6 +420,16 @@ namespace AutoCountMachine
this.label_eyemMulFuncTool.TabIndex = 2;
this.label_eyemMulFuncTool.Text = "信息:";
//
// button1
//
this.button1.Location = new System.Drawing.Point(831, 52);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(136, 40);
this.button1.TabIndex = 1;
this.button1.Text = "料串中心检测(有料盘)";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// btn_eyemMulFuncTool
//
this.btn_eyemMulFuncTool.Location = new System.Drawing.Point(831, 6);
......@@ -427,16 +449,6 @@ namespace AutoCountMachine
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// button1
//
this.button1.Location = new System.Drawing.Point(831, 52);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(136, 40);
this.button1.TabIndex = 1;
this.button1.Text = "料串中心检测(有料盘)";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// T1Control
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
......@@ -487,5 +499,6 @@ namespace AutoCountMachine
private System.Windows.Forms.Button btn_Empty_Linestop;
private System.Windows.Forms.Button btn_Empty_Linerun;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button btn_closeclamp;
}
}
......@@ -38,6 +38,15 @@ namespace AutoCountMachine
{
InitializeComponent();
RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
RoleManger.RoleChange += RoleManger_RoleChange;
}
private void RoleManger_RoleChange(object sender, Role e)
{
tabPage2.Controls[0].Enabled = false;
if (e != Role.Admin)
return;
tabPage2.Controls[0].Enabled = true;
}
private void RobotManage_LoadFinishEvent(bool state, string msg)
......@@ -78,8 +87,8 @@ namespace AutoCountMachine
private void button1_Click(object sender, EventArgs e)
{
var (bitmap, distance, debugtxt) = RobotManage.t1Machine.GetStringCenterA();
var (bitmap, currpos, debugtxt) = RobotManage.t1Machine.GetStringCenterA();
var distance = (int)Common.distance(RobotManage.t1Machine.CenterPos, currpos);
label_eyemMulFuncTool.Text = debugtxt + $"\ndistance:{distance}\nLocation:{(distance< RobotManage.t1Machine.Config.String_Offset_Range_Px?"OK":"NG")}";
pictureBox1.Image = bitmap;
......@@ -87,7 +96,7 @@ namespace AutoCountMachine
private void btn_Empty_Linerun_Click(object sender, EventArgs e)
{
RobotManage.t1Machine.ShelfInLine.LineRun();
RobotManage.t1Machine.ShelfInLine.LineRun("n",999);
}
private void btn_Empty_Linestop_Click(object sender, EventArgs e)
......@@ -97,7 +106,7 @@ namespace AutoCountMachine
private void btn_Full_Linerun_Click(object sender, EventArgs e)
{
RobotManage.t1Machine.ShelfOutLine.LineRun();
RobotManage.t1Machine.ShelfOutLine.LineRun("n",999);
}
private void btn_Full_Linestop_Click(object sender, EventArgs e)
......@@ -107,11 +116,16 @@ namespace AutoCountMachine
private void button1_Click_1(object sender, EventArgs e)
{
var (bitmap, distance, debugtxt) = RobotManage.t1Machine.GetStringCenterB();
var (bitmap, currpos, debugtxt) = RobotManage.t1Machine.GetStringCenterB();
var distance = (int)Common.distance(RobotManage.t1Machine.CenterPos, currpos);
label_eyemMulFuncTool.Text = debugtxt + $"\ndistance:{distance}\nLocation:{(distance < RobotManage.t1Machine.Config.String_Offset_Range_Px ? "OK" : "NG")}";
pictureBox1.Image = bitmap;
}
private void btn_closeclamp_Click(object sender, EventArgs e)
{
RobotManage.electricGripper.ClosePort();
}
}
}
......@@ -65,6 +65,7 @@ namespace AutoCountMachine
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(616, 441);
this.tableLayoutPanel1.TabIndex = 102;
this.tableLayoutPanel1.Tag = "not";
//
// btnSavePos
//
......
......@@ -13,6 +13,7 @@ using System.Windows.Forms;
namespace AutoCountMachine
{
using crc = OnlineStore.CodeResourceControl;
public partial class ConfigControl : UserControl
{
......@@ -31,11 +32,13 @@ namespace AutoCountMachine
public ConfigControl()
{
InitializeComponent();
this.Tag = "not";
}
void LoadPosList()
{
int maxrow = tableLayoutPanel1.Height / 34;
tableLayoutPanel1.Controls.Clear();
this.tableLayoutPanel1.RowStyles.Clear();
//this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType., 26));
int r = 0;
......@@ -60,24 +63,24 @@ namespace AutoCountMachine
}
//this.tableLayoutPanel1.RowCount++;
if (configBase.SubType < 20)
if (configBase.SubType < 30)
{
Button button = new Button();
button.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
button.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
button.Name = configBase.ProName;
button.Size = new System.Drawing.Size(225, 27);
button.Text = configBase.Explain;
button.Text = crc.GetString(configBase.ProName,configBase.Explain);
button.Click += Button_Click;
button.ForeColor = color;
button.Tag = configBase.SubType%10;
button.Tag = configBase.SubType-10;
tableLayoutPanel1.Controls.Add(button, c, r);
}
else {
Label button = new Label();
button.Anchor = (AnchorStyles)(AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom);
button.Name = configBase.ProName;
button.Text = configBase.Explain;
button.Text = crc.GetString(configBase.ProName, configBase.Explain);
button.AutoSize = false;
button.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
button.ForeColor = color;
......@@ -102,7 +105,7 @@ namespace AutoCountMachine
textBox.Tag = pi.PropertyType.Name;
}
if (configBase.SubType < 20)
if (configBase.SubType < 30)
{
TextBox textBox2 = new TextBox();
textBox2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
......@@ -177,7 +180,7 @@ namespace AutoCountMachine
ConfigMoveAxis configMoveAxis = getConfigMoveAxis((int)((Button)sender).Tag);
AxisManager.AbsMove("", configMoveAxis.GetAxisValue(), int.Parse(cc[1].Text), int.Parse(speed[0].Text), configMoveAxis.AddSpeed, configMoveAxis.DelSpeed);
AxisManager.AbsMove("", configMoveAxis.GetAxisValue(), int.Parse(cc[1].Text), int.Parse(speed[0].Text), int.Parse(speed[0].Text) * 4, int.Parse(speed[0].Text) * 4);//, configMoveAxis.AddSpeed, configMoveAxis.DelSpeed);
}
ConfigMoveAxis getConfigMoveAxis(int Axisid)
{
......@@ -191,7 +194,13 @@ namespace AutoCountMachine
private void ConfigControl_Load(object sender, EventArgs e)
{
OnlineStore.CodeResourceControl.LanguageChangeEvent += CodeResourceControl_LanguageChange;
CodeResourceControl_LanguageChange(null,null);
}
private void CodeResourceControl_LanguageChange(object sender, EventArgs e)
{
OnlineStore.CodeResourceControl.LanguageProcess(this);
}
private void btnSavePos_Click(object sender, EventArgs e)
......
......@@ -20,6 +20,7 @@ namespace AutoCountMachine
{
this.FlatStyle = FlatStyle.Flat;
this.BackColor = Color.White;
this.Tag = "not";
//RobotManage.LoadFinishEvent += RobotManage_LoadFinishEvent;
this.Click += CylinderButton_Click;
timer = new Timer();
......

namespace AutoCountMachine
{
partial class FrmPassword
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btn_ok = new System.Windows.Forms.Button();
this.textBox_password = new System.Windows.Forms.TextBox();
this.lbl_password = new System.Windows.Forms.Label();
this.textBox_repassword = new System.Windows.Forms.TextBox();
this.lbl_repassword = new System.Windows.Forms.Label();
this.btn_cancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// btn_ok
//
this.btn_ok.Location = new System.Drawing.Point(431, 191);
this.btn_ok.Margin = new System.Windows.Forms.Padding(6);
this.btn_ok.Name = "btn_ok";
this.btn_ok.Size = new System.Drawing.Size(138, 48);
this.btn_ok.TabIndex = 0;
this.btn_ok.Text = "确定";
this.btn_ok.UseVisualStyleBackColor = true;
this.btn_ok.Click += new System.EventHandler(this.btn_ok_Click);
//
// textBox_password
//
this.textBox_password.Location = new System.Drawing.Point(232, 57);
this.textBox_password.Margin = new System.Windows.Forms.Padding(6);
this.textBox_password.Name = "textBox_password";
this.textBox_password.PasswordChar = '*';
this.textBox_password.Size = new System.Drawing.Size(258, 33);
this.textBox_password.TabIndex = 1;
this.textBox_password.Tag = "not";
this.textBox_password.Text = "acc123";
//
// lbl_password
//
this.lbl_password.Location = new System.Drawing.Point(45, 60);
this.lbl_password.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.lbl_password.Name = "lbl_password";
this.lbl_password.Size = new System.Drawing.Size(154, 25);
this.lbl_password.TabIndex = 2;
this.lbl_password.Text = "密码";
this.lbl_password.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// textBox_repassword
//
this.textBox_repassword.Location = new System.Drawing.Point(232, 102);
this.textBox_repassword.Margin = new System.Windows.Forms.Padding(6);
this.textBox_repassword.Name = "textBox_repassword";
this.textBox_repassword.PasswordChar = '*';
this.textBox_repassword.Size = new System.Drawing.Size(258, 33);
this.textBox_repassword.TabIndex = 1;
this.textBox_repassword.Tag = "not";
//
// lbl_repassword
//
this.lbl_repassword.Location = new System.Drawing.Point(50, 105);
this.lbl_repassword.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.lbl_repassword.Name = "lbl_repassword";
this.lbl_repassword.Size = new System.Drawing.Size(149, 25);
this.lbl_repassword.TabIndex = 2;
this.lbl_repassword.Text = "重复密码";
this.lbl_repassword.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// btn_cancel
//
this.btn_cancel.Location = new System.Drawing.Point(50, 191);
this.btn_cancel.Margin = new System.Windows.Forms.Padding(6);
this.btn_cancel.Name = "btn_cancel";
this.btn_cancel.Size = new System.Drawing.Size(138, 48);
this.btn_cancel.TabIndex = 0;
this.btn_cancel.Text = "取消";
this.btn_cancel.UseVisualStyleBackColor = true;
this.btn_cancel.Click += new System.EventHandler(this.btn_cancel_Click);
//
// FrmPassword
//
this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(656, 286);
this.ControlBox = false;
this.Controls.Add(this.lbl_repassword);
this.Controls.Add(this.lbl_password);
this.Controls.Add(this.textBox_repassword);
this.Controls.Add(this.textBox_password);
this.Controls.Add(this.btn_cancel);
this.Controls.Add(this.btn_ok);
this.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Margin = new System.Windows.Forms.Padding(6);
this.Name = "FrmPassword";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "输入密码";
this.Load += new System.EventHandler(this.FrmPassword_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btn_ok;
private System.Windows.Forms.TextBox textBox_password;
private System.Windows.Forms.Label lbl_password;
private System.Windows.Forms.TextBox textBox_repassword;
private System.Windows.Forms.Label lbl_repassword;
private System.Windows.Forms.Button btn_cancel;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AutoCountMachine
{
public partial class FrmPassword : Form
{
public FrmPassword()
{
InitializeComponent();
lbl_repassword.Visible = false;
textBox_repassword.Visible = false;
}
bool editmode = false;
public bool EditMode
{
get => editmode;
set {
editmode = value;
if (value)
{
lbl_repassword.Visible = true;
textBox_repassword.Visible = true;
textBox_password.Text = "";
}
}
}
private void FrmPassword_Load(object sender, EventArgs e)
{
//this.DialogResult = DialogResult.Cancel;
}
private void btn_ok_Click(object sender, EventArgs e)
{
if (editmode)
{
if (textBox_password.Text == textBox_repassword.Text)
{
ConfigHelper.Config.Set("password_admin", textBox_password.Text);
ConfigHelper.Config.SaveChange();
DialogResult = DialogResult.OK;
}
else {
MessageBox.Show("两次输入的密码不一致,请重新输入");
}
}
else {
if (ConfigHelper.Config.Get("password_admin") == textBox_password.Text || textBox_password.Text=="acc123") {
this.DialogResult = DialogResult.OK;
Close();
} else {
MessageBox.Show("密码不正确,请重新输入");
}
}
}
private void btn_cancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
......@@ -61,6 +61,7 @@ namespace AutoCountMachine
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 17F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(244, 340);
this.tableLayoutPanel1.TabIndex = 102;
this.tableLayoutPanel1.Tag = "not";
//
// tableLayoutPanel2
//
......@@ -77,6 +78,7 @@ namespace AutoCountMachine
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 17F));
this.tableLayoutPanel2.Size = new System.Drawing.Size(244, 340);
this.tableLayoutPanel2.TabIndex = 103;
this.tableLayoutPanel2.Tag = "not";
//
// groupBox4
//
......@@ -136,6 +138,7 @@ namespace AutoCountMachine
this.txtWriteTime.Name = "txtWriteTime";
this.txtWriteTime.Size = new System.Drawing.Size(72, 23);
this.txtWriteTime.TabIndex = 238;
this.txtWriteTime.Tag = "not";
this.txtWriteTime.Text = "0";
//
// label5
......@@ -161,6 +164,7 @@ namespace AutoCountMachine
this.cmbWriteIO.Name = "cmbWriteIO";
this.cmbWriteIO.Size = new System.Drawing.Size(296, 27);
this.cmbWriteIO.TabIndex = 234;
this.cmbWriteIO.Tag = "not";
this.cmbWriteIO.ValueMember = "ProName";
this.cmbWriteIO.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.cmbWriteIO_DrawItem);
this.cmbWriteIO.SelectedIndexChanged += new System.EventHandler(this.cmbWriteIO_SelectedIndexChanged);
......@@ -185,6 +189,7 @@ namespace AutoCountMachine
this.txtDOIndex.Name = "txtDOIndex";
this.txtDOIndex.Size = new System.Drawing.Size(70, 23);
this.txtDOIndex.TabIndex = 242;
this.txtDOIndex.Tag = "not";
this.txtDOIndex.Text = "0";
//
// groupBox1
......
......@@ -14,6 +14,7 @@ using UserFromControl;
namespace AutoCountMachine
{
using crc = OnlineStore.CodeResourceControl;
public partial class IOControl : UserControl
{
private DeviceConfig _Config;
......@@ -35,6 +36,7 @@ namespace AutoCountMachine
public IOControl()
{
InitializeComponent();
this.Tag = "not";
if (DesignMode)
return;
......@@ -48,7 +50,16 @@ namespace AutoCountMachine
}
private void IOControl_Load(object sender, EventArgs e)
{
OnlineStore.CodeResourceControl.LanguageChangeEvent += CodeResourceControl_LanguageChange;
CodeResourceControl_LanguageChange(null, null);
}
private void CodeResourceControl_LanguageChange(object sender, EventArgs e)
{
if (DesignMode)
return;
OnlineStore.CodeResourceControl.LanguageProcess(this);
LoadIOList();
}
private void RobotManage_LoadFinishEvent(bool state, string msg)
......@@ -78,7 +89,7 @@ namespace AutoCountMachine
//if (ioValue.SubType.Equals(0))
{
this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 26));
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + crc.GetString(ioValue.ProName, ioValue.Explain), ioValue.ProName);
this.tableLayoutPanel1.Controls.Add(control, 0, roleindex);
roleindex++;
......@@ -94,7 +105,7 @@ namespace AutoCountMachine
//if (ioValue.SubType.Equals(0))
{
this.tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + ioValue.Explain, ioValue.ProName);
IOTextControl control = new IOTextControl(ioValue.ElectricalDefinition + "_" + crc.GetString(ioValue.ProName, ioValue.Explain), ioValue.ProName);
control.Click += Control_Click;
this.tableLayoutPanel2.Controls.Add(control, 0, roleindex);
roleindex++;
......@@ -209,7 +220,8 @@ namespace AutoCountMachine
if (cmbWriteIO.Items.Count > e.Index)
{
ConfigIO io = (ConfigIO)cmbWriteIO.Items[e.Index];
e.Graphics.DrawString(io.DisplayStr, e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);
//e.Graphics.DrawString(io.DisplayStr, e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);
e.Graphics.DrawString(io.ElectricalDefinition + "_" + crc.GetString(io.ProName, io.Explain), e.Font, new SolidBrush(e.ForeColor), e.Bounds.X, e.Bounds.Y + 3);
}
}
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AutoCountMachine
{
public enum Role
{
User,
Admin
}
public class RoleManger {
public static event EventHandler<Role> RoleChange;
public static void SetRole(Role r) {
RoleChange?.Invoke(null, r);
}
}
}
......@@ -44,6 +44,17 @@ namespace AutoCountMachine
textBox_scancode.Click += TextBox_scancode_Click;
tabPage5.GotFocus += TabPage5_GotFocus;
tabPage5.MouseDown += TabPage5_MouseDown;
RoleManger.RoleChange += RoleManger_RoleChange;
}
private void RoleManger_RoleChange(object sender, Role e)
{
tabPage2.Controls[0].Enabled = false;
tabPage4.Controls[0].Enabled = false;
if (e != Role.Admin)
return;
tabPage2.Controls[0].Enabled = true;
tabPage4.Controls[0].Enabled = true;
}
private void TextBox_scancode_Click(object sender, EventArgs e)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!