..
This commit is contained in:
@@ -22,6 +22,7 @@ namespace Project
|
||||
public static bool Automodeonreboot = false;
|
||||
public static bool AutRebootAlreay = false;
|
||||
public static bool DriveSpeed = false;
|
||||
public static AGVControl.MapControl mapctl;
|
||||
|
||||
#region "Hardware"
|
||||
|
||||
@@ -94,7 +95,7 @@ namespace Project
|
||||
voice.SpeakAsyncCancelAll();
|
||||
if (voice.State == SynthesizerState.Ready)
|
||||
voice.SpeakAsync(m);
|
||||
if (addlog) PUB.log.Add("SPEAK",m);
|
||||
if (addlog) PUB.log.Add("SPEAK", m);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -111,7 +112,7 @@ namespace Project
|
||||
VAR.BOOL[eVarBool.WAIT_COVER_DOWN] == false &&
|
||||
VAR.BOOL[eVarBool.WAIT_COVER_UP] == false)
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
@@ -188,13 +189,13 @@ namespace Project
|
||||
|
||||
public static void init()
|
||||
{
|
||||
|
||||
|
||||
Result = new CResult();
|
||||
|
||||
//state machine
|
||||
sm = new StateMachine.StateMachine();
|
||||
|
||||
path = new System.IO.DirectoryInfo(Util.CurrentPath);
|
||||
path = new System.IO.DirectoryInfo(UTIL.CurrentPath);
|
||||
|
||||
|
||||
|
||||
@@ -234,7 +235,7 @@ namespace Project
|
||||
}
|
||||
voice.SetOutputToDefaultAudioDevice();
|
||||
|
||||
var file_version = System.IO.Path.Combine(Util.CurrentPath, "version.txt");
|
||||
var file_version = System.IO.Path.Combine(UTIL.CurrentPath, "version.txt");
|
||||
if (System.IO.File.Exists(file_version))
|
||||
{
|
||||
PUB.PatchVersion = System.IO.File.ReadAllText(file_version, System.Text.Encoding.UTF8);
|
||||
@@ -242,16 +243,16 @@ namespace Project
|
||||
else PUB.PatchVersion = string.Empty;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Boolean CheckManualChargeMode(bool Prompt = true )
|
||||
|
||||
public static Boolean CheckManualChargeMode(bool Prompt = true)
|
||||
{
|
||||
if (VAR.BOOL[eVarBool.FLAG_CHARGEONM] == true)
|
||||
{
|
||||
string msg = "수동 충전 상태이므로 진행 할 수 없습니다";
|
||||
PUB.Speak(msg);
|
||||
if(Prompt)
|
||||
Util.MsgE(msg);
|
||||
if (Prompt)
|
||||
UTIL.MsgE(msg);
|
||||
return false;
|
||||
}
|
||||
else return true;
|
||||
@@ -334,13 +335,13 @@ namespace Project
|
||||
var step = PUB.sm.Step.ToString();
|
||||
var rtep = PUB.sm.RunStep.ToString();
|
||||
var mcid = PUB.setting.MCID;
|
||||
var path = System.IO.Path.Combine(Util.CurrentPath, "Status");
|
||||
var path = System.IO.Path.Combine(UTIL.CurrentPath, "Status");
|
||||
var file = System.IO.Path.Combine(path, $"{DateTime.Now.ToString("HHmmssfff")}_{step}_{rtep}.sql");
|
||||
var wdate = DateTime.Now;
|
||||
try
|
||||
{
|
||||
var sql = "insert into AGV_History(mcid,step,runstep,remark,ip,wdate) values('{0}','{1}','{2}','{3}','{4}','{5}')";
|
||||
sql = string.Format(sql, mcid, step, rtep, remark,IP,wdate.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
sql = string.Format(sql, mcid, step, rtep, remark, IP, wdate.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||
System.IO.File.WriteAllText(file, sql, System.Text.Encoding.Default);
|
||||
|
||||
//만들어진지 3분이 지난 파일은 삭제한다.
|
||||
@@ -354,7 +355,27 @@ namespace Project
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetResultCodeMessage(eResult err)
|
||||
{
|
||||
return err.ToString().ToUpper();
|
||||
}
|
||||
|
||||
|
||||
public static string GetErrorMessage(eECode err, params object[] values)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case eECode.NOTALLOWUP:
|
||||
return "상차 허용 위치가 아닙니다";
|
||||
case eECode.AGVCONN:
|
||||
return Lang.AGV연결실패;
|
||||
case eECode.PLCCONN:
|
||||
return Lang.PLC통신실패;
|
||||
|
||||
default:
|
||||
return err.ToString();
|
||||
}
|
||||
}
|
||||
public static string IP { get; set; }
|
||||
public static string MAC { get; set; }
|
||||
|
||||
@@ -448,23 +469,100 @@ namespace Project
|
||||
}
|
||||
});
|
||||
}
|
||||
public static string SelectSerialPort()
|
||||
{
|
||||
var f = new System.Windows.Forms.Form();
|
||||
f.WindowState = System.Windows.Forms.FormWindowState.Normal;
|
||||
f.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
f.Size = new System.Drawing.Size(800, 400);
|
||||
f.MaximizeBox = false;
|
||||
f.MinimizeBox = false;
|
||||
f.Text = "Select Port";
|
||||
f.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
var lst = new System.Windows.Forms.ListBox();
|
||||
lst.Font = new System.Drawing.Font("Consolas", 15, System.Drawing.FontStyle.Bold);
|
||||
lst.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
lst.DoubleClick += (s1, e1) =>
|
||||
{
|
||||
if (lst.SelectedItem != null) f.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
};
|
||||
using (var searcher = new ManagementObjectSearcher("SELECT * FROM WIN32_SerialPort"))
|
||||
{
|
||||
var portnames = System.IO.Ports.SerialPort.GetPortNames().OrderBy(t => t);
|
||||
var ports = searcher.Get().Cast<ManagementBaseObject>().ToList();
|
||||
foreach (var port in portnames)
|
||||
{
|
||||
var desc = "";
|
||||
var portInfo = ports.Where(t => t["DeviceId"].ToString() == port).FirstOrDefault();
|
||||
if (portInfo != null) desc = portInfo["Caption"].ToString();
|
||||
lst.Items.Add(string.Format("{0} - {1}", port, desc));
|
||||
}
|
||||
}
|
||||
f.Controls.Add(lst);
|
||||
if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
var name = lst.SelectedItem.ToString().Split('-');
|
||||
return name[0].Trim();
|
||||
}
|
||||
else return string.Empty;
|
||||
}
|
||||
|
||||
public static void SystemReboot(UInt16 timeout, bool setautomode = false)
|
||||
{
|
||||
System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
|
||||
si.FileName = @"c:\windows\system32\shutdown.exe";
|
||||
si.Arguments = "-r -t " + timeout.ToString();
|
||||
si.UseShellExecute = false;
|
||||
System.Diagnostics.Process prc = new System.Diagnostics.Process();
|
||||
prc.StartInfo = si;
|
||||
|
||||
PUB.AGV.AGVMoveStop("user reboot");
|
||||
|
||||
if (setautomode)
|
||||
{
|
||||
PUB.Automodeonreboot = true;
|
||||
PUB.setting.SetAutoModeOn = true;
|
||||
PUB.setting.AUtoRebootLastTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
PUB.setting.Save();
|
||||
}
|
||||
|
||||
|
||||
prc.Start();
|
||||
|
||||
}
|
||||
public static void SystemShutdown(UInt16 timeout)
|
||||
{
|
||||
//System.Text.StringBuilder sb = new StringBuilder();
|
||||
//sb.AppendLine("@echo off");
|
||||
//sb.AppendLine("echo System OFF After " + timeout.ToString() + "Seconds");
|
||||
//sb.AppendLine("shutdown -s -t " + timeout.ToString());
|
||||
//string bfile = AppDomain.CurrentDomain.BaseDirectory + "Shutdown.bat";
|
||||
//System.IO.File.WriteAllText(bfile, string.Format(sb.ToString(), AppDomain.CurrentDomain.BaseDirectory), System.Text.Encoding.Default);
|
||||
|
||||
System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
|
||||
si.FileName = @"c:\windows\system32\shutdown.exe";
|
||||
si.Arguments = "-s -t " + timeout.ToString();
|
||||
si.UseShellExecute = false;
|
||||
System.Diagnostics.Process prc = new System.Diagnostics.Process();
|
||||
prc.StartInfo = si;
|
||||
prc.Start();
|
||||
}
|
||||
|
||||
public static void ChangeUIPopup(System.Windows.Forms.NumericUpDown valueCtl)
|
||||
{
|
||||
var value = valueCtl.Value.ToString();
|
||||
var f = AR.UTIL.InputBox("input", value);// new Dialog.fInput(value);
|
||||
var f = UTIL.InputBox("input", value);// new Dialog.fInput(value);
|
||||
if (f.Item1)
|
||||
{
|
||||
var val = decimal.Parse(f.Item2);
|
||||
if (val < valueCtl.Minimum)
|
||||
{
|
||||
Util.MsgE(string.Format("최소 입력값은 {0} 입니다.", valueCtl.Minimum));
|
||||
UTIL.MsgE(string.Format("최소 입력값은 {0} 입니다.", valueCtl.Minimum));
|
||||
val = valueCtl.Minimum;
|
||||
}
|
||||
if (val > valueCtl.Maximum)
|
||||
{
|
||||
Util.MsgE(string.Format("최대 입력값은 {0} 입니다.", valueCtl.Maximum));
|
||||
UTIL.MsgE(string.Format("최대 입력값은 {0} 입니다.", valueCtl.Maximum));
|
||||
val = valueCtl.Maximum;
|
||||
}
|
||||
valueCtl.Value = val;
|
||||
|
||||
Reference in New Issue
Block a user