Commit 5bc9fae6 LN

1.门口料盘状态发送给服务器doorReelSignal。

2.合并墨西哥料仓机器人对接功能。
3.光栅被遮挡时不扫码.
4.循环点位测试功能。
1 个父辈 86f90bf4
...@@ -50,13 +50,8 @@ namespace OnlineStore.ACSingleStore ...@@ -50,13 +50,8 @@ namespace OnlineStore.ACSingleStore
foreach (ConfigIO ioValue in boxBean.Config.StoreDIList.Values) foreach (ConfigIO ioValue in boxBean.Config.StoreDIList.Values)
{ {
this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 28)); this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
IOTextControl control = new IOTextControl(); IOTextControl control = new IOTextControl(ioValue.DisplayName, ioValue.ProName);
control.IOName = ioValue.ElectricalDefinition + "_" + ResourceCulture.GetString(ioValue.ElectricalDefinition, ioValue.Explain); control.Click += Control_Click;
control.IOValue = 0;
control.isCanClick = false;
control.Name = "IO_" + ioValue.ProName;
control.Size = new System.Drawing.Size(200, 25);
control.TabIndex = 0;
this.tableLayoutPanel1.Controls.Add(control, 0, roleindex); this.tableLayoutPanel1.Controls.Add(control, 0, roleindex);
roleindex++; roleindex++;
DIControlList.Add(ioValue.ProName, control); DIControlList.Add(ioValue.ProName, control);
...@@ -68,14 +63,8 @@ namespace OnlineStore.ACSingleStore ...@@ -68,14 +63,8 @@ namespace OnlineStore.ACSingleStore
foreach (ConfigIO ioValue in boxBean.Config.StoreDOList.Values) foreach (ConfigIO ioValue in boxBean.Config.StoreDOList.Values)
{ {
this.tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 28)); this.tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Absolute, 28));
IOTextControl control = new IOTextControl(); IOTextControl control = new IOTextControl(ioValue.DisplayName, ioValue.ProName);
control.IOName = ioValue.ElectricalDefinition + "_" + ResourceCulture.GetString(ioValue.ElectricalDefinition, ioValue.Explain); control.Click += Control_Click;
control.IOValue = 0;
control.isCanClick = true;
//control.Location = new System.Drawing.Point(0, 25*roleindex);
control.Name = "IO_" + ioValue.ProName;
control.Size = new System.Drawing.Size(200, 25);
control.TabIndex = 0;
this.tableLayoutPanel2.Controls.Add(control, 0, roleindex); this.tableLayoutPanel2.Controls.Add(control, 0, roleindex);
roleindex++; roleindex++;
DOControlList.Add(ioValue.ProName, control); DOControlList.Add(ioValue.ProName, control);
...@@ -87,6 +76,17 @@ namespace OnlineStore.ACSingleStore ...@@ -87,6 +76,17 @@ namespace OnlineStore.ACSingleStore
cmbWriteIO.DisplayMember = "DisplayStr"; cmbWriteIO.DisplayMember = "DisplayStr";
cmbWriteValue.SelectedIndex = 0; cmbWriteValue.SelectedIndex = 0;
} }
private void Control_Click(object sender, EventArgs e)
{
IOTextControl control = (IOTextControl)sender;
string name = control.Name.Substring(3, control.Name.Length - 3);
List<string> keyList = new List<string>(DOControlList.Keys);
int index = keyList.IndexOf(name);
if (index >= 0)
{
cmbWriteIO.SelectedIndex = index;
}
}
private void timer1_Tick(object sender, EventArgs e) private void timer1_Tick(object sender, EventArgs e)
{ {
...@@ -149,10 +149,12 @@ namespace OnlineStore.ACSingleStore ...@@ -149,10 +149,12 @@ namespace OnlineStore.ACSingleStore
{ {
// txtIp.Text = io.DeviceName; // txtIp.Text = io.DeviceName;
txtDOIndex.Text = io.GetIOAddr().ToString(); txtDOIndex.Text = io.GetIOAddr().ToString();
txtDoName.Text = io.DeviceName; txtDoName.Text = io.IO_IP;
txtSlaveId.Text = io.SlaveID.ToString();
IOTextControl newControl = DOControlList[io.ProName]; IOTextControl newControl = DOControlList[io.ProName];
if (selectControl != null) { selectControl.BackColor = Color.White; }
newControl.BackColor = Color.SkyBlue;
selectControl = newControl; selectControl = newControl;
} }
} }
} }
...@@ -160,6 +162,16 @@ namespace OnlineStore.ACSingleStore ...@@ -160,6 +162,16 @@ namespace OnlineStore.ACSingleStore
private void FrmStoreIOStatus_Load(object sender, EventArgs e) private void FrmStoreIOStatus_Load(object sender, EventArgs e)
{ {
AIManager.Instance.NeedShow = true; AIManager.Instance.NeedShow = true;
if (boxBean.Config.StoreDOList.ContainsKey(IO_Type.Device_Led))
{
btnDevideLed.Visible = true;
btnCDLed.Visible = true;
}
else
{
btnDevideLed.Visible = false;
btnCDLed.Visible = false;
}
} }
private void cmbWriteIO_DrawItem(object sender, DrawItemEventArgs e) private void cmbWriteIO_DrawItem(object sender, DrawItemEventArgs e)
...@@ -259,11 +271,13 @@ namespace OnlineStore.ACSingleStore ...@@ -259,11 +271,13 @@ namespace OnlineStore.ACSingleStore
} }
private void btnOpenDoor_Click(object sender, EventArgs e) private void btnOpenDoor_Click(object sender, EventArgs e)
{ {
LogUtil.info("点击按钮:" + btnOpenDoor.Text);
IOManager.IOMove(IO_Type.Door_Up, IO_VALUE.HIGH); IOManager.IOMove(IO_Type.Door_Up, IO_VALUE.HIGH);
IOManager.IOMove(IO_Type.Door_Down, IO_VALUE.LOW); IOManager.IOMove(IO_Type.Door_Down, IO_VALUE.LOW);
} }
private void btnCloseDoor_Click(object sender, EventArgs e) private void btnCloseDoor_Click(object sender, EventArgs e)
{ {
LogUtil.info("点击按钮:" + btnCloseDoor.Text);
IOManager.IOMove(IO_Type.Door_Down, IO_VALUE.HIGH); IOManager.IOMove(IO_Type.Door_Down, IO_VALUE.HIGH);
IOManager.IOMove(IO_Type.Door_Up, IO_VALUE.LOW); IOManager.IOMove(IO_Type.Door_Up, IO_VALUE.LOW);
} }
...@@ -297,5 +311,22 @@ namespace OnlineStore.ACSingleStore ...@@ -297,5 +311,22 @@ namespace OnlineStore.ACSingleStore
{ {
IOManager.IOMove(IO_Type.Camera_Led, IO_VALUE.LOW); IOManager.IOMove(IO_Type.Camera_Led, IO_VALUE.LOW);
} }
private void btnDevideLed_Click(object sender, EventArgs e)
{
IOManager.IOMove(IO_Type.Device_Led, IO_VALUE.HIGH);
}
private void btnCDLed_Click(object sender, EventArgs e)
{
IOManager.IOMove(IO_Type.Device_Led, IO_VALUE.LOW);
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
} }
} }
...@@ -78,7 +78,6 @@ ...@@ -78,7 +78,6 @@
this.txtPwd.PasswordChar = '*'; this.txtPwd.PasswordChar = '*';
this.txtPwd.Size = new System.Drawing.Size(215, 33); this.txtPwd.Size = new System.Drawing.Size(215, 33);
this.txtPwd.TabIndex = 276; this.txtPwd.TabIndex = 276;
this.txtPwd.Text = "123456";
this.txtPwd.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtPwd_KeyDown); this.txtPwd.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtPwd_KeyDown);
// //
// FrmPwd // FrmPwd
......
...@@ -45,7 +45,7 @@ namespace OnlineStore.ACSingleStore ...@@ -45,7 +45,7 @@ namespace OnlineStore.ACSingleStore
LogUtil.error(LOGGER, "找不到对应的料仓"); LogUtil.error(LOGGER, "找不到对应的料仓");
return; return;
} }
ACStorePosition ktkPosition = null; ACStorePosition ktkPosition = null;
if (store.PositionNumList.Count > 0) if (store.PositionNumList.Count > 0)
...@@ -161,6 +161,9 @@ namespace OnlineStore.ACSingleStore ...@@ -161,6 +161,9 @@ namespace OnlineStore.ACSingleStore
} }
this.tabControl1.TabPages.Remove(tabPage3); this.tabControl1.TabPages.Remove(tabPage3);
groupCode.Visible = false; groupCode.Visible = false;
loadTest();
tabControl1.TabPages.Remove(tabPage7);
} }
private string WaitStart = ResourceCulture.GetString("等待启动"); private string WaitStart = ResourceCulture.GetString("等待启动");
private string dooropen = ResourceCulture.GetString("前门未关"); private string dooropen = ResourceCulture.GetString("前门未关");
...@@ -183,6 +186,7 @@ namespace OnlineStore.ACSingleStore ...@@ -183,6 +186,7 @@ namespace OnlineStore.ACSingleStore
{ {
return; return;
} }
showTestMsg();
lblTempStr.Text = store.currTempStr; lblTempStr.Text = store.currTempStr;
ShowMsg(); ShowMsg();
//ReadPosistion(); //ReadPosistion();
...@@ -952,7 +956,8 @@ namespace OnlineStore.ACSingleStore ...@@ -952,7 +956,8 @@ namespace OnlineStore.ACSingleStore
{ {
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.notifyIcon1.Visible = true; this.notifyIcon1.Visible = true;
this.Hide(); //this.Hide();
this.WindowState = FormWindowState.Minimized ;
DebugStatus(false); DebugStatus(false);
} }
private void FrmStoreBox_FormClosed(object sender, FormClosedEventArgs e) private void FrmStoreBox_FormClosed(object sender, FormClosedEventArgs e)
...@@ -1096,6 +1101,7 @@ namespace OnlineStore.ACSingleStore ...@@ -1096,6 +1101,7 @@ namespace OnlineStore.ACSingleStore
ConfigAppSettings.SaveValue(Setting_Init.UseBuzzer, 0); ConfigAppSettings.SaveValue(Setting_Init.UseBuzzer, 0);
store.UseBuzzer = false; store.UseBuzzer = false;
LogUtil.info("去掉:启用蜂鸣器"); LogUtil.info("去掉:启用蜂鸣器");
IOManager.IOMove(IO_Type.Alarm_Buzzer, IO_VALUE.LOW);
} }
} }
...@@ -1190,5 +1196,151 @@ namespace OnlineStore.ACSingleStore ...@@ -1190,5 +1196,151 @@ namespace OnlineStore.ACSingleStore
StoreManager.UpdateBoxConfig(store.Config); StoreManager.UpdateBoxConfig(store.Config);
} }
} }
private void loadTest()
{
List<ConfigMoveAxis> axisList = new List<ConfigMoveAxis>(store.moveAxisList);
if (axisList.Count > 0)
{
cmbTest.Items.Clear();
foreach (ConfigMoveAxis a in axisList)
{
cmbTest.Items.Add(a.DisplayStr);
}
cmbTest.SelectedIndex = 0;
PortName = axisList[0].DeviceName;
SlvAddr = axisList[0].GetAxisValue();
}
}
private string PortName = "";
private int SlvAddr = 0;
private bool StartTest = false;
private string testInfo = "";
private string currInfo = "";
private int moveCount = 0;
private int speed = 1000;
private int A;
private int B;
private void btnTStart_Click(object sender, EventArgs e)
{
if (cmbTest.SelectedIndex >= 0)
{
DialogResult result=MessageBox.Show("确定开始循环测试?","确定提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if (!result.Equals(DialogResult.Yes))
{
return;
}
ConfigMoveAxis axis = store.moveAxisList[cmbTest.SelectedIndex];
PortName = axis.DeviceName;
SlvAddr = axis.GetAxisValue();
A = FormUtil.GetIntValue(txtA);
B=FormUtil.GetIntValue(txtB);
speed = FormUtil.GetIntValue(txtTSpeed);
moveCount = 0;
testInfo = DateTime.Now.ToString()+" "+ axis.DisplayStr + " 循环中:从 [" + A + "] 到 [" +B + "] " ;
LogUtil.info($"{cmbTest.Text} 开始测试:" + testInfo);
StartTest = true;
System.Threading.Tasks.Task.Run(() =>
{
TestRun();
});
FromStart(StartTest);
}
else
{
MessageBox.Show("请选择运动轴");
}
}
private void btnTStop_Click(object sender, EventArgs e)
{
StartTest = false;
FromStart(StartTest);
LogUtil.info($"{cmbTest.Text} 停止测试:" );
ACServerManager.SuddenStop(PortName, SlvAddr);
Thread.Sleep(200);
testInfo = "已停止测试";
currInfo = "";
}
private void TestRun()
{
while(StartTest)
{
try
{
Thread.Sleep(200);
if (!ACServerManager.ServerOnStatus(PortName, SlvAddr))
{
currInfo = DateTime.Now.ToString() + " " + $"第{moveCount}次移动,伺服还未打开,请先打开伺服";
}
else if (ACServerManager.GetAlarmStatus(PortName, SlvAddr) > 0)
{
currInfo = DateTime.Now.ToString() + " " + $"第{moveCount}次移动,伺服报警,请检查";
}
else
{
bool isOk = ACServerManager.GetBusyStatus(PortName, SlvAddr).Equals(0);
if (isOk)
{
bool useA = (moveCount % 2 == 0);
if (useA)
{
ACServerManager.AbsMove(PortName, SlvAddr, A, speed);
currInfo = DateTime.Now.ToString() + " " + $"第{moveCount}次移动,目标A点:{A}";
}
else
{
ACServerManager.AbsMove(PortName, SlvAddr, B, speed);
currInfo = DateTime.Now.ToString() + " " + $"第{moveCount}次移动,目标B点:{B}";
}
moveCount++;
LogUtil.info($"循环测试:{cmbTest.Text} " + currInfo);
}
}
}
catch(Exception ex)
{
LogUtil.error(" testRun 出错:" + ex.ToString());
}
}
}
private void FromStart(bool start)
{
cmbTest.Enabled = !start;
txtA.Enabled = !start;
txtB.Enabled = !start;
txtTSpeed.Enabled = !start;
btnTStart.Enabled = !start;
btnTStop.Enabled = start;
}
private void cmbTest_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmbTest.SelectedIndex >= 0)
{
ConfigMoveAxis axis = store.moveAxisList[cmbTest.SelectedIndex];
PortName = axis.DeviceName;
SlvAddr = axis.GetAxisValue();
txtTSpeed.Text = axis.TargetSpeed / 2+"";
}
}
private void showTestMsg()
{
lblTmsg.Text = testInfo + "\r\n" + currInfo;
}
} }
} }
...@@ -42,7 +42,7 @@ namespace OnlineStore ...@@ -42,7 +42,7 @@ namespace OnlineStore
LoadData(); LoadData();
} }
} }
private static char spilt = ','; private static char spilt = ',';
private static void LoadData() private static void LoadData()
{ {
ResourceControl.GetChinaStringEvent += GetChinaString; ResourceControl.GetChinaStringEvent += GetChinaString;
...@@ -51,12 +51,12 @@ namespace OnlineStore ...@@ -51,12 +51,12 @@ namespace OnlineStore
ResourceControl.GetStringEvent += GetString; ResourceControl.GetStringEvent += GetString;
CSVResourceControl.GetStrEvent += GetString; CSVResourceControl.GetStrEvent += GetString;
CSVResourceControl.GetStringEvent += GetString; CSVResourceControl.GetStringEvent += GetString;
// CodeLibrary.CodeResourceControl.GetLanguageEvent += CodeResourceControl_GetLanguageEvent; // CodeLibrary.CodeResourceControl.GetLanguageEvent += CodeResourceControl_GetLanguageEvent;
//string englishPath = Application.StartupPath + @"\resource\en-US.resource"; //string englishPath = Application.StartupPath + @"\resource\en-US.resource";
//string chinaPath = Application.StartupPath + @"\resource\zh-CN.resource"; //string chinaPath = Application.StartupPath + @"\resource\zh-CN.resource";
//Dictionary<string, string> ChinaMap = LoadDataMap(chinaPath); //Dictionary<string, string> ChinaMap = LoadDataMap(chinaPath);
//Dictionary<string, string> EnglishMap = LoadDataMap(englishPath); //Dictionary<string, string> EnglishMap = LoadDataMap(englishPath);
string rPath = Application.StartupPath + @"\resource\language.resource"; string rPath= Application.StartupPath + @"\resource\language.resource";
ResourceMap = new Dictionary<string, Dictionary<string, string>>(); ResourceMap = new Dictionary<string, Dictionary<string, string>>();
Dictionary<string, string> ChinaMap = new Dictionary<string, string>(); Dictionary<string, string> ChinaMap = new Dictionary<string, string>();
Dictionary<string, string> EnglishMap = new Dictionary<string, string>(); Dictionary<string, string> EnglishMap = new Dictionary<string, string>();
...@@ -100,13 +100,12 @@ namespace OnlineStore ...@@ -100,13 +100,12 @@ namespace OnlineStore
{ {
EnglishMap.Add(key, eng); EnglishMap.Add(key, eng);
} }
// EnglishMap.Add(key, eng); // EnglishMap.Add(key, eng);
} }
} }
} }catch(Exception ex)
catch (Exception ex)
{ {
LogUtil.error("读取文件【" + rPath + "】【" + line + "】出错:" + ex.ToString()); LogUtil.error("读取文件【"+ rPath + "】【"+ line + "】出错:" + ex.ToString());
} }
} }
} }
...@@ -139,7 +138,7 @@ namespace OnlineStore ...@@ -139,7 +138,7 @@ namespace OnlineStore
EnglishMap.Add(key, englistr); EnglishMap.Add(key, englistr);
} }
} }
string str = key + spilt + chinastr.Replace(spilt, '&') + spilt + englistr.Replace(spilt, '&'); string str = key + spilt + chinastr.Replace( spilt, '&') + spilt + englistr.Replace( spilt, '&');
allList.Add(str); allList.Add(str);
} }
if (isNeedUpE) if (isNeedUpE)
...@@ -164,17 +163,17 @@ namespace OnlineStore ...@@ -164,17 +163,17 @@ namespace OnlineStore
//FileUtil.SaveListToFile(allList.ToArray(), Application.StartupPath + "\\a.txt"); //FileUtil.SaveListToFile(allList.ToArray(), Application.StartupPath + "\\a.txt");
} }
private static Dictionary<string, string> LoadRMap() private static Dictionary<string,string> LoadRMap()
{ {
string path = Application.StartupPath + @"\resource\ResourceMap.csv"; string path = Application.StartupPath + @"\resource\ResourceMap.csv";
Dictionary<string, string> map = new Dictionary<string, string>(); Dictionary<string, string> map = new Dictionary<string, string>();
try try
{ {
if (!File.Exists(path)) if (!File.Exists(path))
{ {
return map; return map;
} }
string[] lines = File.ReadAllLines(path); string[] lines = File.ReadAllLines(path);
foreach (string line in lines) foreach (string line in lines)
{ {
if (String.IsNullOrEmpty(line)) if (String.IsNullOrEmpty(line))
...@@ -199,11 +198,11 @@ namespace OnlineStore ...@@ -199,11 +198,11 @@ namespace OnlineStore
{ {
LogUtil.error("加载 " + path + "[" + line + "] 出错:" + ex.ToString()); LogUtil.error("加载 " + path + "[" + line + "] 出错:" + ex.ToString());
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("加载 " + path + " 出错:" + ex.ToString()); LogUtil.error("加载 "+ path + " 出错:" + ex.ToString());
} }
return map; return map;
} }
...@@ -266,14 +265,14 @@ namespace OnlineStore ...@@ -266,14 +265,14 @@ namespace OnlineStore
public static string GetChinaString(string id, params object[] param) public static string GetChinaString(string id, params object[] param)
{ {
string strCurLanguage = gets(China, id); string strCurLanguage = gets(China, id);
return String.Format(strCurLanguage, param); return String.Format(strCurLanguage, param);
} }
public static string GetEnglishString(string id, params object[] param) public static string GetEnglishString(string id, params object[] param)
{ {
string strCurLanguage = gets(English, id); string strCurLanguage = gets(English, id);
return String.Format(strCurLanguage, param); return String.Format(strCurLanguage, param);
} }
private static string gets(string language, string id, string defaultStr = "") private static string gets(string language,string id,string defaultStr="")
{ {
if (String.IsNullOrEmpty(defaultStr)) if (String.IsNullOrEmpty(defaultStr))
{ {
...@@ -287,7 +286,7 @@ namespace OnlineStore ...@@ -287,7 +286,7 @@ namespace OnlineStore
{ {
if (ShowMsg) if (ShowMsg)
{ {
LogUtil.error("No Language Resources:[" + id + "], please add"); LogUtil.debug ("No Language Resources:[" + id + "], please add");
} }
return defaultStr; return defaultStr;
} }
...@@ -295,22 +294,21 @@ namespace OnlineStore ...@@ -295,22 +294,21 @@ namespace OnlineStore
{ {
if (ResourceMap[language].ContainsKey(id.Trim())) if (ResourceMap[language].ContainsKey(id.Trim()))
{ {
return ResourceMap[language][id]; return ResourceMap[language][id];
} }
else else
{ {
NoIdLog(id, defaultStr); NoIdLog(id, defaultStr);
} }
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
NoIdLog(id, defaultStr); NoIdLog(id, defaultStr);
} }return defaultStr;
return defaultStr;
} }
public static string GetString(string id, string defaultStr = "") public static string GetString(string id, string defaultStr="")
{ {
string strCurLanguage = defaultStr; string strCurLanguage = defaultStr;
if (string.IsNullOrEmpty(defaultStr)) if (string.IsNullOrEmpty(defaultStr))
...@@ -325,7 +323,7 @@ namespace OnlineStore ...@@ -325,7 +323,7 @@ namespace OnlineStore
{ {
if (ShowMsg) if (ShowMsg)
{ {
LogUtil.error("No Language Resources:[" + id + "], please add"); LogUtil.debug("No Language Resources:[" + id + "], please add");
} }
return defaultStr; return defaultStr;
} }
...@@ -361,9 +359,9 @@ namespace OnlineStore ...@@ -361,9 +359,9 @@ namespace OnlineStore
{ {
return; return;
} }
if (ShowMsg) // if (ShowMsg)
{ {
LogUtil.info("No id:[" + id + "], please add,use default string :" + defaultStr); LogUtil.debug("No id:[" + id + "], please add,use default string :" + defaultStr);
} }
if (!defaultMap.ContainsKey(id)) if (!defaultMap.ContainsKey(id))
{ {
...@@ -379,8 +377,8 @@ namespace OnlineStore ...@@ -379,8 +377,8 @@ namespace OnlineStore
foreach (string key in defaultMap.Keys) foreach (string key in defaultMap.Keys)
{ {
string value = defaultMap[key]; string value = defaultMap[key];
LogUtil.info("" + key + spilt + value + spilt + ""); LogUtil.info("" + key + spilt + value +spilt +"");
LogUtil.RLog("" + key + spilt + value.Replace(spilt, '&') + spilt + ""); LogUtil.RLog("" + key + spilt + value.Replace(spilt,'&') + spilt+"");
} }
LogUtil.info("结束打印缺少的文字配置"); LogUtil.info("结束打印缺少的文字配置");
...@@ -417,7 +415,7 @@ namespace OnlineStore ...@@ -417,7 +415,7 @@ namespace OnlineStore
string showMsg = ResourceCulture.GetString(msg, msg, param); string showMsg = ResourceCulture.GetString(msg, msg, param);
string showTitle = ResourceCulture.GetString("提示"); string showTitle = ResourceCulture.GetString("提示");
return MessageBox.Show(showMsg, showTitle); return MessageBox.Show( showMsg,showTitle);
} }
public static DialogResult Show(string msg, string title, MessageBoxButtons but, params object[] param) public static DialogResult Show(string msg, string title, MessageBoxButtons but, params object[] param)
{ {
......
...@@ -206,6 +206,10 @@ namespace OnlineStore.Common ...@@ -206,6 +206,10 @@ namespace OnlineStore.Common
/// <summary> /// <summary>
/// 温度报警值 /// 温度报警值
/// </summary> /// </summary>
public static string maxTemperature = "temp"; public static string maxTemperature = "temp";
/// <summary>
/// 门口料盘检测信号,1或者0
/// </summary>
public static string doorReelSignal = "doorReelSignal";
} }
} }
...@@ -128,26 +128,33 @@ namespace OnlineStore.DeviceLibrary ...@@ -128,26 +128,33 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("Box_AI_Changed_Event出错:" + ex.ToString()); LogUtil.error("Box_AI_Changed_Event出错:" + ex.ToString());
} }
} }
public override double GetAIValue(string ioiP, int index) public override double GetAIValue(string ioiP, int index)
{ {
if (AIValList != null && index >= 0 && AIValList.Count > index) for (int i = 1; i <= 3; i++)
{ {
return AIValList[index]; try
{
if (AIValList != null && index >= 0 && AIValList.Count > index)
{
return AIValList[index];
}
}
catch (Exception ex)
{
if (i > 1)
{
LogUtil.error("GetAIValue第【" + i + "】次获取 " + ioiP + "_" + index + "出错:" + ex.ToString());
}
}
Thread.Sleep(1);
} }
return 0; return 0;
} }
//public override double ConvertAI(double aiValue, double defaultValue)
//{
// double xishu = (double)ConfigAppSettings.GetNumValue(Setting_Init.AI_ConvertPosition);
// double result = Math.Round((aiValue - defaultValue) / xishu, 2);
// return result;
//}
} }
} }
...@@ -9,19 +9,17 @@ using OnlineStore.Common; ...@@ -9,19 +9,17 @@ using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary; using OnlineStore.LoadCSVLibrary;
using System.Threading.Tasks; using System.Threading.Tasks;
using Asa.IOModule; using Asa.IOModule;
using System.Collections.Concurrent;
namespace OnlineStore.DeviceLibrary namespace OnlineStore.DeviceLibrary
{ {
public class AIOBOXManager : IOManager public class AIOBOXManager : IOManager
{ {
//public static uint DefaultDICount = 16;
//public static uint DefaultDOCount = 16;
public readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public readonly ILog LOGGER = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public Dictionary<string, AIOBOX> AIOMap = new Dictionary<string, AIOBOX>(); public Dictionary<string, AIOBOX> AIOMap = new Dictionary<string, AIOBOX>();
public Dictionary<string, List<Box_Sta>> DIValueMap = new Dictionary<string, List<Box_Sta>>(); public ConcurrentDictionary<string, List<Box_Sta>> DIValueMap = new ConcurrentDictionary<string, List<Box_Sta>>();
public Dictionary<string, List<Box_Sta>> DOValueMap = new Dictionary<string, List<Box_Sta>>(); public ConcurrentDictionary<string, List<Box_Sta>> DOValueMap = new ConcurrentDictionary<string, List<Box_Sta>>();
private object DIMapLock = ""; private object DIMapLock = "";
private object DOMapLock = ""; private object DOMapLock = "";
...@@ -87,13 +85,14 @@ namespace OnlineStore.DeviceLibrary ...@@ -87,13 +85,14 @@ namespace OnlineStore.DeviceLibrary
} }
AIOMap.Remove(ioIp); AIOMap.Remove(ioIp);
} }
List<Box_Sta> list = new List<Box_Sta>();
if (DIValueMap.ContainsKey(ioIp)) if (DIValueMap.ContainsKey(ioIp))
{ {
DIValueMap.Remove(ioIp); DIValueMap.TryRemove(ioIp,out list);
} }
if (DOValueMap.ContainsKey(ioIp)) if (DOValueMap.ContainsKey(ioIp))
{ {
DOValueMap.Remove(ioIp); DOValueMap.TryRemove(ioIp, out list);
} }
int DIMS = ConfigAppSettings.GetIntValue("DIMS"); int DIMS = ConfigAppSettings.GetIntValue("DIMS");
if (DIMS < 20) if (DIMS < 20)
...@@ -220,15 +219,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -220,15 +219,7 @@ namespace OnlineStore.DeviceLibrary
needUpdate = true; needUpdate = true;
} }
else else
{ {
//foreach(Box_Sta s in sta)
//{
// updateDi += s.ToString() + ",";
//}
//if (ip.Equals("192.168.201.61"))
//{
// LogUtil.info(updateDi);
//}
for (int i = 0; i < newList.Count; i++) for (int i = 0; i < newList.Count; i++)
{ {
if (!(oldList[i].Equals(newList[i]))) if (!(oldList[i].Equals(newList[i])))
...@@ -240,13 +231,15 @@ namespace OnlineStore.DeviceLibrary ...@@ -240,13 +231,15 @@ namespace OnlineStore.DeviceLibrary
} }
if (needUpdate) if (needUpdate)
{ {
lock (DILock) // lock (DILock)
{ {
if (DIValueMap.ContainsKey(ip)) if (DIValueMap.ContainsKey(ip))
{ {
DIValueMap.Remove(ip); List<Box_Sta> s = new List<Box_Sta>();
DIValueMap.TryRemove(ip,out s);
} }
DIValueMap.Add(ip, newList); DIValueMap.TryAdd(ip, newList);
} }
} }
} }
...@@ -261,12 +254,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -261,12 +254,7 @@ namespace OnlineStore.DeviceLibrary
newList.AddRange(sta); newList.AddRange(sta);
List<Box_Sta> oldList = null; List<Box_Sta> oldList = null;
DOValueMap.TryGetValue(ip, out oldList); DOValueMap.TryGetValue(ip, out oldList);
//string result = "UpdateAllDO ip[" + ip + "], sta :";
//for (int i = 0; i < newList.Count; i++)
//{
// result += newList[i] + ",";
//}
//LogUtil.info(result);
if (oldList == null || oldList.Count.Equals(newList.Count).Equals(false)) if (oldList == null || oldList.Count.Equals(newList.Count).Equals(false))
{ {
needUpdate = true; needUpdate = true;
...@@ -284,27 +272,17 @@ namespace OnlineStore.DeviceLibrary ...@@ -284,27 +272,17 @@ namespace OnlineStore.DeviceLibrary
} }
if (needUpdate) if (needUpdate)
{ {
lock (DOLock) // lock (DOLock)
{ {
if (DOValueMap.ContainsKey(ip)) if (DOValueMap.ContainsKey(ip))
{ {
DOValueMap.Remove(ip); List<Box_Sta> list = new List<Box_Sta>();
DOValueMap.TryRemove(ip,out list);
} }
DOValueMap.Add(ip, newList); DOValueMap.TryAdd(ip, newList);
} }
} }
} }
//else
//{
// if (sta == null)
// {
// LogUtil.error("UpdateAllDO ip[" + ip + "], sta=null");
// }
// else
// {
// LogUtil.error(" UpdateAllDO ip[" + ip + "], sta.Length=" + sta.Length);
// }
//}
} }
...@@ -331,11 +309,18 @@ namespace OnlineStore.DeviceLibrary ...@@ -331,11 +309,18 @@ namespace OnlineStore.DeviceLibrary
public override void CloseAllConnection() public override void CloseAllConnection()
{ {
foreach (AIOBOX aio in AIOMap.Values) try
{
foreach (AIOBOX aio in AIOMap.Values)
{
aio.Close();
}
AIOMap.Clear();
}
catch (Exception ex)
{ {
aio.Close(); LogUtil.error("CloseAllConnection 出错:" + ex.ToString());
} }
AIOMap.Clear();
} }
public override void WriteSingleDO(string ioIp, byte slaveId, ushort StartAddress, IO_VALUE onOff) public override void WriteSingleDO(string ioIp, byte slaveId, ushort StartAddress, IO_VALUE onOff)
{ {
...@@ -422,7 +407,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -422,7 +407,7 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("ReadAllDI出错:" + ioIp); LogUtil.error("ReadAllDI [" + ioIp + "] 出错:" + ex.ToString());
} }
} }
public override void ReadAllDO(string ioIp, byte slaveId) public override void ReadAllDO(string ioIp, byte slaveId)
...@@ -439,36 +424,37 @@ namespace OnlineStore.DeviceLibrary ...@@ -439,36 +424,37 @@ namespace OnlineStore.DeviceLibrary
} }
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.error("ReadAllDO出错:" + ioIp); LogUtil.error("ReadAllDO ["+ioIp+"] 出错:" + ex.ToString());
} }
} }
public override IO_VALUE GetDOValue(string ioIP, byte slaveId, ushort StartAddress) public override IO_VALUE GetDOValue(string ioIP, byte slaveId, ushort StartAddress)
{ {
IO_VALUE value = IO_VALUE.LOW; IO_VALUE value = IO_VALUE.LOW;
try for (int i = 1; i <= 3; i++)
{ {
AIOBOX aioBox = getAIO(ioIP); try
if (aioBox != null)
{ {
Box_Sta sta = Box_Sta.Off; AIOBOX aioBox = getAIO(ioIP);
// Box_Addr addr = GetAddr(StartAddress); if (aioBox != null)
// int index = (int)StartAddress - (int)StoreManager.Config.GetDILength(ioIP);
if (DOValueMap.ContainsKey(ioIP) && DOValueMap[ioIP].Count > StartAddress)
{ {
sta = DOValueMap[ioIP][StartAddress]; Box_Sta sta = Box_Sta.Off;
} if (DOValueMap.ContainsKey(ioIP) && DOValueMap[ioIP].Count > StartAddress)
else {
{ sta = aioBox.ReadDO(StartAddress); } sta = DOValueMap[ioIP][StartAddress];
if (sta.Equals(Box_Sta.On)) }
{ else
value = IO_VALUE.HIGH; { sta = aioBox.ReadDO(StartAddress); }
if (sta.Equals(Box_Sta.On))
{
value = IO_VALUE.HIGH;
}
break;
} }
} }
} catch (Exception ex)
catch (Exception ex) {
{ LogUtil.error("GetDOValue [" + ioIP + "] [" + StartAddress + "] [" + i + "] 出错:" + ex.ToString());
LogUtil.error("GetDOValue 出错:" + ex.ToString()); }
} }
return value; return value;
} }
...@@ -476,31 +462,35 @@ namespace OnlineStore.DeviceLibrary ...@@ -476,31 +462,35 @@ namespace OnlineStore.DeviceLibrary
public override IO_VALUE GetDIValue(string ioIP, byte slaveId, ushort StartAddress) public override IO_VALUE GetDIValue(string ioIP, byte slaveId, ushort StartAddress)
{ {
IO_VALUE value = IO_VALUE.LOW; IO_VALUE value = IO_VALUE.LOW;
try for (int i = 1; i <= 3; i++)
{ {
AIOBOX aioBox = getAIO(ioIP); try
if (aioBox != null)
{ {
Box_Sta sta = Box_Sta.Off; AIOBOX aioBox = getAIO(ioIP);
// Box_Addr addr = GetAddr(StartAddress); if (aioBox != null)
int index = StartAddress;
if (DIValueMap.ContainsKey(ioIP) && DIValueMap[ioIP].Count > index)
{ {
sta = DIValueMap[ioIP][index]; Box_Sta sta = Box_Sta.Off;
} // Box_Addr addr = GetAddr(StartAddress);
else int index = StartAddress;
{ if (DIValueMap.ContainsKey(ioIP) && DIValueMap[ioIP].Count > index)
sta = aioBox.ReadDI(StartAddress); {
} sta = DIValueMap[ioIP][index];
if (sta.Equals(Box_Sta.On)) }
{ else
value = IO_VALUE.HIGH; {
sta = aioBox.ReadDI(StartAddress);
}
if (sta.Equals(Box_Sta.On))
{
value = IO_VALUE.HIGH;
}
break;
} }
} }
} catch (Exception ex)
catch (Exception ex) {
{ LogUtil.error("GetDIValue [" + ioIP + "] ["+StartAddress+"] [" + i+"] 出错:" + ex.ToString());
LogUtil.error("GetDIValue 出错:" + ex.ToString()); }
} }
return value; return value;
} }
......
...@@ -68,7 +68,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -68,7 +68,10 @@ namespace OnlineStore.DeviceLibrary
{ {
try try
{ {
scannerSocket.close(); if (scannerSocket != null)
{
scannerSocket.close();
}
isScannerRun = false; isScannerRun = false;
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -89,7 +89,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -89,7 +89,7 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
OutStoreExecute = 9, OutStoreExecute = 9,
/// <summary> /// <summary>
///10= 出仓位完成( 料盘已经放到Box门口) ///10= 出仓位完成 ,从仓位中拿走
/// </summary> /// </summary>
OutStoreBoxEnd = 10, OutStoreBoxEnd = 10,
/// <summary> /// <summary>
...@@ -104,6 +104,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -104,6 +104,10 @@ namespace OnlineStore.DeviceLibrary
/// 重置中(原点返回和重置都发此状态) /// 重置中(原点返回和重置都发此状态)
/// </summary> /// </summary>
ResetMove=13, ResetMove=13,
/// <summary>
/// 扫码入库失败
/// </summary>
InStoreError=14,
} }
/// <summary> /// <summary>
...@@ -121,10 +125,10 @@ namespace OnlineStore.DeviceLibrary ...@@ -121,10 +125,10 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
BOX_H_LocationCylinderBack=010, BOX_H_LocationCylinderBack=010,
/// <summary> ///// <summary>
/// 料仓原点返回和重置步骤,轴三先相对走3000 ///// 料仓原点返回和重置步骤,等待开始原点返回
/// </summary> ///// </summary>
BOX_H_InOutMove=011, //BOX_H_InOutMove=011,
/// <summary> /// <summary>
/// 料仓原点返回和重置步骤,,轴三进出轴先返回原点 /// 料仓原点返回和重置步骤,,轴三进出轴先返回原点
/// </summary> /// </summary>
...@@ -249,6 +253,11 @@ namespace OnlineStore.DeviceLibrary ...@@ -249,6 +253,11 @@ namespace OnlineStore.DeviceLibrary
/// </summary> /// </summary>
SO_15_WaitTake=115, SO_15_WaitTake=115,
/// <summary>
/// 料仓出库。。。等待200毫秒再次验证料盘是否拿走
/// </summary>
SO_16_CheckIsTake=116,
#endregion #endregion
#region 料仓内部入库步骤 #region 料仓内部入库步骤
...@@ -263,7 +272,7 @@ namespace OnlineStore.DeviceLibrary ...@@ -263,7 +272,7 @@ namespace OnlineStore.DeviceLibrary
/// <summary> /// <summary>
/// 入库。。进出轴(叉子)先返回P1 /// 入库。。进出轴(叉子)先返回P1
/// </summary> /// </summary>
SI_02_InOutAxisHome = 202, SI_02_OpenDoor = 202,
/// <summary> /// <summary>
/// 入库。。所有轴先回到待机点,轴2、轴1 动作到P1,,轴4动作至P3 /// 入库。。所有轴先回到待机点,轴2、轴1 动作到P1,,轴4动作至P3
/// </summary> /// </summary>
......
...@@ -253,6 +253,16 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -253,6 +253,16 @@ namespace OnlineStore.LoadCSVLibrary
{ {
} }
} }
public string DisplayName
{
get
{
return ElectricalDefinition + "_" + CSVResourceControl.GetString(ElectricalDefinition, Explain);
}
set
{
}
}
public override int GetValue() public override int GetValue()
{ {
return GetIOValue(); return GetIOValue();
......
...@@ -560,6 +560,12 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -560,6 +560,12 @@ namespace OnlineStore.LoadCSVLibrary
/// /// </summary> /// /// </summary>
[ConfigProAttribute("AI_ConvertPosition")] [ConfigProAttribute("AI_ConvertPosition")]
public int AI_ConvertPosition { get; set; } public int AI_ConvertPosition { get; set; }
/// <summary>
/// PRO,大盘宽度(13寸或15寸),Big_TrayWidth,15,,,,,,,
/// /// </summary>
[ConfigProAttribute("Big_TrayWidth",false)]
public int Big_TrayWidth { get; set; }
private Dictionary<string, string> CodeSizeMap =null ; private Dictionary<string, string> CodeSizeMap =null ;
private static char codeSpilt= '#'; private static char codeSpilt= '#';
......
...@@ -112,7 +112,11 @@ namespace OnlineStore.LoadCSVLibrary ...@@ -112,7 +112,11 @@ namespace OnlineStore.LoadCSVLibrary
/// <summary> /// <summary>
/// DO 相机照明开 Camera_Led Y10 /// DO 相机照明开 Camera_Led Y10
/// </summary> /// </summary>
public static string Camera_Led = "Camera_Led"; public static string Camera_Led = "Camera_Led";
/// <summary>
/// DO 设备照明开 Device_Led Y11
/// </summary>
public static string Device_Led = "Device_Led";
} }
public enum IO_VALUE public enum IO_VALUE
{ {
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
this.label1.Size = new System.Drawing.Size(53, 12); this.label1.Size = new System.Drawing.Size(53, 12);
this.label1.TabIndex = 0; this.label1.TabIndex = 0;
this.label1.Text = "测试一下"; this.label1.Text = "测试一下";
this.label1.Click += new System.EventHandler(this.label1_Click);
// //
// pictureBox1 // pictureBox1
// //
...@@ -57,6 +58,7 @@ ...@@ -57,6 +58,7 @@
this.pictureBox1.TabIndex = 1; this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
this.pictureBox1.DoubleClick += new System.EventHandler(this.pictureBox1_DoubleClick);
// //
// pictureBox2 // pictureBox2
// //
...@@ -69,6 +71,7 @@ ...@@ -69,6 +71,7 @@
this.pictureBox2.TabIndex = 2; this.pictureBox2.TabIndex = 2;
this.pictureBox2.TabStop = false; this.pictureBox2.TabStop = false;
this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click); this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
this.pictureBox2.DoubleClick += new System.EventHandler(this.pictureBox2_DoubleClick);
// //
// IOTextControl // IOTextControl
// //
......
...@@ -12,16 +12,16 @@ namespace UserFromControl ...@@ -12,16 +12,16 @@ namespace UserFromControl
{ {
public partial class IOTextControl : UserControl public partial class IOTextControl : UserControl
{ {
public string IOName { get; set; } public string IOName { get; set; }
public int IOValue { get; set; } public int IOValue { get; set; }
public Boolean isCanClick { get; set; } public Boolean isCanClick { get; set; }
public IOTextControl() public IOTextControl()
{ {
InitializeComponent(); InitializeComponent();
if (ImageManager.IsInit==false) if (ImageManager.IsInit == false)
{ {
ImageManager.Init(); ImageManager.Init();
} }
...@@ -31,21 +31,46 @@ namespace UserFromControl ...@@ -31,21 +31,46 @@ namespace UserFromControl
pictureBox2.Visible = false; pictureBox2.Visible = false;
isCanClick = false; isCanClick = false;
} }
public IOTextControl(string ioName, string name, int widht = 220, int height = 25, int ioValue = -1, bool canClick = false, int tabIndex = 0)
{
InitializeComponent();
if (ImageManager.IsInit == false)
{
ImageManager.Init();
}
this.pictureBox1.BackgroundImage = ImageManager.imgGrey;
this.pictureBox2.BackgroundImage = ImageManager.imgGreen;
pictureBox1.Visible = true;
pictureBox2.Visible = false;
isCanClick = false;
IOName = ioName;
IOValue = IOValue;
isCanClick = canClick;
Name = "IO_" + name;
Size = new System.Drawing.Size(widht, height);
TabIndex = tabIndex;
}
public void ShowData() public void ShowData()
{ {
label1.Text = IOName; label1.Text = IOName;
if (IOValue == 0) if (IOValue == 0)
{ {
pictureBox1.Visible = true; pictureBox1.Visible = true;
pictureBox2.Visible = false; pictureBox2.Visible = false;
} }
else else if (IOValue == 1)
{ {
pictureBox1.Visible = false; pictureBox1.Visible = false;
pictureBox2.Visible = true; pictureBox2.Visible = true;
} }
else
{
pictureBox1.Visible = false;
pictureBox2.Visible = false;
}
} }
private void IOStatusControl_Load(object sender, EventArgs e) private void IOStatusControl_Load(object sender, EventArgs e)
...@@ -55,20 +80,36 @@ namespace UserFromControl ...@@ -55,20 +80,36 @@ namespace UserFromControl
private void pictureBox2_Click(object sender, EventArgs e) private void pictureBox2_Click(object sender, EventArgs e)
{ {
if (isCanClick) this.OnClick(e);
{
pictureBox2.Visible = true;
pictureBox1.Visible = false;
}
} }
private void pictureBox1_Click(object sender, EventArgs e) private void pictureBox1_Click(object sender, EventArgs e)
{ {
if (isCanClick) this.OnClick(e);
{ }
pictureBox2.Visible = false;
pictureBox1.Visible = true; private void label1_DoubleClick(object sender, EventArgs e)
} {
this.OnDoubleClick(e);
}
private void pictureBox2_DoubleClick(object sender, EventArgs e)
{
this.OnDoubleClick(e);
}
private void pictureBox1_DoubleClick(object sender, EventArgs e)
{
this.OnDoubleClick(e);
}
private void label1_Click(object sender, EventArgs e)
{
this.OnClick(e);
} }
} }
} }
文件属性发生变化
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!