示例#1
0
 /// <summary>
 /// 开灯,拉带trayType,slot无效
 /// </summary>
 /// <param name="kangShiDaLightController"></param>
 /// <param name="threadName">线程名称</param>
 /// <param name="process">工序位置</param>
 /// <param name="slot">槽位,0代表空盘</param>
 private void SetLightBox(ATL_MC.KangShiDaLightController.KangShiDaLightController kangShiDaLightController, string threadName, EnumProcess process, EnumTrayType trayType, int slot = 0)
 {
     //先开灯
     PolicyTypeA.Execute(() =>
     {
         if (process == EnumProcess.MoveIn)
         {
             //拉带开灯
             if (1 == kangShiDaLightController.SetLightBox(GetProductParam <int>(p => p.MoveInLight_1), GetProductParam <int>(p => p.MoveInLight_2)))
             {
                 throw new Exception($"{threadName}:开灯失败");
             }
             SYS_IBG_LOG(DEBUGL1MSG, 0, 0, $"{threadName}:{process.ToString()}工序,开灯成功");
         }
         else
         {
             //tray盘开灯
             if (1 == kangShiDaLightController.SetLightBox(
                     GetProductParam <int>(p => p.ProductInfo(trayType, slot).Brightness_1),
                     GetProductParam <int>(p => p.ProductInfo(trayType, slot).Brightness_2),
                     GetProductParam <int>(p => p.ProductInfo(trayType, slot).Brightness_3),
                     GetProductParam <int>(p => p.ProductInfo(trayType, slot).Brightness_4)
                     ))
             {
                 throw new Exception($"{threadName}:{process.ToString()}工序,{slot}槽位开灯失败");
             }
             SYS_IBG_LOG(DEBUGL1MSG, 0, 0, $"{threadName}:{process.ToString()}工序,{slot}槽位开灯成功");
         }
     });
 }
示例#2
0
        public static void ExecuteWaitCommand(string command, string workingFolder, EnumProcess proc, bool IsCreateNoWindow = false)
        {
            int ExitCode;
            ProcessStartInfo ProcessInfo;
            Process          process;

            ProcessInfo = new ProcessStartInfo("cmd.exe", "/c " + command);
            ProcessInfo.CreateNoWindow   = IsCreateNoWindow;
            ProcessInfo.UseShellExecute  = false;
            ProcessInfo.WorkingDirectory = workingFolder;

            // *** Redirect the output ***

            //  ProcessInfo.RedirectStandardError = true;
            //  ProcessInfo.RedirectStandardOutput = true;

            ProcessInfo.RedirectStandardError  = false;
            ProcessInfo.RedirectStandardOutput = false;

            process = Process.Start(ProcessInfo);

            switch (proc)
            {
            case EnumProcess.NonGlobal:
                break;

            case EnumProcess.Designer:
                GlobalDef.CurrentDesigner.Process = process;
                break;

            case EnumProcess.Player:
                GlobalDef.ProcessPlayer = process;
                break;

            case EnumProcess.Receiver:
                GlobalDef.ProcessReceiver = process;
                break;

            case EnumProcess.Sender:
                GlobalDef.ProcessSender = process;
                break;

            default:
                break;
            }


            process.WaitForExit();

            // *** Read the streams ***
            //  string output = process.StandardOutput.ReadToEnd();
            //  string error = process.StandardError.ReadToEnd();

            ExitCode = process.ExitCode;

            if (ExitCode > 0)
            {
                BotHttpClient.Log("ERROR on " + proc.ToString(), true);
            }

            // MessageBox.Show("output>>" + (String.IsNullOrEmpty(output) ? "(none)" : output));
            // MessageBox.Show("error>>" + (String.IsNullOrEmpty(error) ? "(none)" : error));
            //  MessageBox.Show("ExitCode: " + ExitCode.ToString(), "ExecuteCommand");
            process.Close();

            process = null;

            switch (proc)
            {
            case EnumProcess.NonGlobal:
                break;

            case EnumProcess.Designer:
                GlobalDef.CurrentDesigner.Process = process;
                break;

            case EnumProcess.Player:
                GlobalDef.ProcessPlayer = process;
                break;

            case EnumProcess.Receiver:
                GlobalDef.ProcessReceiver = process;
                break;

            case EnumProcess.Sender:
                GlobalDef.ProcessSender = process;
                break;

            default:
                break;
            }


            #region EXAMPLE
            //// This will get the current WORKING directory (i.e. \bin\Debug)
            //string workingDirectory = Environment.CurrentDirectory;
            //// This will get the current PROJECT directory
            //string projectDirectory = Directory.GetParent(workingDirectory).Parent.FullName;
            //string commandToExecute = Path.Combine(projectDirectory, "TestSetup", "WreckersTestSetupQA.bat");
            //string workingFolder = Path.GetDirectoryName(commandToExecute);
            //commandToExecute = QuotesAround(commandToExecute);
            //ExecuteCommand(commandToExecute, workingFolder);

            #endregion
        }