private void btnCfgModify_Click(object sender, EventArgs e) { this.curCmd = EnumCmd.修改配置; this.panel2.Enabled = true; CfgFillClear(); presenter.BeginAddProductCfg(); }
/// <summary> /// Create a new FullStrategy object from file /// Filename : contains path to file to load /// PatternFilename : contains path to pattern file to load /// </summary> public FullStrategy(string Filename, string PatternFilename) { if ((Filename == null) || (PatternFilename == null)) { throw(new Exception("Invalid Filename/PatternFilename")); } // Read files StructuredFile StrategyFile = new StructuredFile(Filename); StrategyFile.Parse(PatternFilename); // Store data into private data // Store PATTERN_STRATEGY_NAME _StrategyName = StrategyFile.GetValue("PATTERN_STRATEGY_NAME", "Undefined"); _DefaultSpeed = StrategyFile.GetValue("PATTERN_DEFAULT_SPEED", "50"); // Store initial cmd (setpos) EnumCmd CurrentCmd = Command.GetCmdFromString(StrategyFile.GetValue("PATTERN_INIT_CMD", "App_SetNewPos")); EnumCmdType CurrentCmdType = Command.GetCmdTypeFromString(StrategyFile.GetValue("PATTERN_INIT_CMD_TYPE", "NonBlocking")); String ParamX = StrategyFile.GetValue("PATTERN_INIT_POS_X", "0"); String ParamY = StrategyFile.GetValue("PATTERN_INIT_POS_Y", "0"); String ParamAngle = StrategyFile.GetValue("PATTERN_INIT_POS_ANGLE", "0.0"); EnumStrategyFlag ActiveSensors = Command.GetSensorsFlagFromString(StrategyFile.GetValue("PATTERN_INIT_ACTIVE_SENSORS", "APP_PARAM_APPFLAG_NONE")); _InitialCmd = new Command(CurrentCmd, CurrentCmdType, null, ParamX, ParamY, ParamAngle, ActiveSensors); // Read other items (Loops) // Try to read all loops for (int iLoop = 0; iLoop <= StrategyFile.GetMaxLoopID(); iLoop++) { for (int iCount = 0; iCount <= StrategyFile.GetMaxGID(iLoop); iCount++) { // Read ActionID and NextActionID int ActionID = StrategyFile.GetActionID(iLoop, iCount); int NextActionID = StrategyFile.GetNextActionID(iLoop, iCount); int TimeoutID = StrategyFile.GetTimeoutID(iLoop, iCount); // If current action is valid if (ActionID >= 0) { // Read command data from StratgeyFile Command ReadCommand = StrategyFile.GetCommand(iLoop, iCount); // If current command is valid, we store it if (ReadCommand != null) { // If current list is empty, we create it if (_Strategy == null) { _Strategy = new List <StrategyItem>(); } // Create new entry _Strategy.Add(new StrategyItem(ReadCommand, ActionID, NextActionID, TimeoutID)); } } } } }
public void InsertNewCmd_Before(int Index, EnumCmd CmdToAdd, int NewCmdID) { int FreeActionID = -1; if (Index <= 0) { throw (new Exception("Invalid Param")); } if (_Strategy == null) { throw (new Exception("Invalid Param")); } if (Index > _Strategy.Count) { throw (new Exception("Invalid Param")); } Command NewCommand = new Command(CmdToAdd); if (NewCmdID > 1) { FreeActionID = GetPrevFreeActionID(NewCmdID + 1); } else { FreeActionID = GetPrevFreeActionID(_Strategy[Index - 1].ActionID); } StrategyItem NewStrategyItem = new StrategyItem(NewCommand, FreeActionID, -1, -1); _Strategy.Insert(Index - 1, NewStrategyItem); }
private void btnProductCfgAdd_Click(object sender, EventArgs e) { this.curCmd = EnumCmd.增加配置; this.panel2.Enabled = true; this.textBoxBarcode.Enabled = true; CfgFillClear(); presenter.BeginAddProductCfg(); }
/// <summary> /// Get the Command into String /// </summary> /// <param name="Cmd">Command we have to export into a string</param> /// <returns>A string that contains the command into a string</returns> public static String GetCmdToString(EnumCmd Cmd) { foreach (EnumCmd ECmd in Enum.GetValues(typeof(EnumCmd))) { if (Cmd == ECmd) { return(ECmd.ToString()); } } return(EnumCmd.NotSet.ToString()); }
public RobotAction(int ID) { _uID = ID; // Identifiant unique pour l'action _cmd = EnumCmd.NotSet; // Commande _cmdType = EnumCmdType.CmdType_NotSet; // Type de l'action à réaliser _param1 = ""; // Param 1 _param2 = ""; // Param 2 _param3 = ""; // Param 3 _param4 = ""; // Param 4 _activeSensors = new ActiveSensors(); // Sensors actifs durant le mouvement (pas de sensor actif) _nextID = -1; // Action suivante _timeoutID = -1; // Action à réaliser en cas de timeout }
/// <summary> /// Récupère la commande complète d'après la Loop et le GID /// </summary> /// <param name="LoopID">Identifiant de la boucle</param> /// <param name="GID">Identifiant du GID</param> /// <returns>La commande complétée de toutes les infos de la LoopID + GID</returns> public Command GetCommand(int LoopID, int GID) { Command ReadCommand = null; EnumCmd CmdFromFile = EnumCmd.NotSet; EnumCmdType CmdTypeFromFile = EnumCmdType.NotSet; string [] ParamsFromFile = null; EnumStrategyFlag ActiveSensorsFromFile = EnumStrategyFlag.STRATEGYFLAG_NONE; // Lecture de toute la liste pour trouver la bonne LoopID et GID for (int i = 0; i < _Items.Count(); i++) { // Si nous sommes dans la bonne LoopID et GID if ((_Items[i].GetLoopID() == LoopID) && (_Items[i].GetGID() == GID)) { // Lecture des informations // Lecture de la commande if (_Items[i].GetName() == "PATTERN_CMD") { CmdFromFile = Command.GetCmdFromString(_Items[i].GetValue()); } // Lecture du type de la commande if (_Items[i].GetName() == "PATTERN_CMD_TYPE") { CmdTypeFromFile = Command.GetCmdTypeFromString(_Items[i].GetValue()); } // Lecture des flags des sensors if (_Items[i].GetName() == "PATTERN_ACTIVE_SENSORS_FLAG") { ActiveSensorsFromFile = Command.GetSensorsFlagFromString(_Items[i].GetValue()); } // Lecture des paramètres if (_Items[i].GetName() == "PATTERN_PARAMS") { ParamsFromFile = Command.GetParamsListFromString(_Items[i].GetValue()); } } } // Creation de l'objet de retour if (CmdFromFile != EnumCmd.NotSet) { ReadCommand = new Command(CmdFromFile, CmdTypeFromFile, ParamsFromFile[0], ParamsFromFile[1], ParamsFromFile[2], ParamsFromFile[3], ActiveSensorsFromFile); } return(ReadCommand); }
public void InsertNewCmd_After(int Index, EnumCmd CmdToAdd, int NewCmdID) { int FreeActionID = -1; if (Index < 0) { throw (new Exception("Invalid Param")); } if (_Strategy == null) { _Strategy = new List <StrategyItem>(); } if (Index > _Strategy.Count) { throw (new Exception("Invalid Param")); } Command NewCommand = new Command(CmdToAdd); if (_Strategy.Count == 0) { FreeActionID = 1; } else { if (NewCmdID > 1) { FreeActionID = GetNextFreeActionID(NewCmdID - 1); } else { FreeActionID = GetNextFreeActionID(_Strategy[Index - 1].ActionID); } } StrategyItem NewStrategyItem = new StrategyItem(NewCommand, FreeActionID, -1, -1); _Strategy.Insert(Index, NewStrategyItem); }
/// <summary> /// Create a new 'Cmd' command with the 'CmdType' type, 'Params' parameters and ActiveSensors parameters /// </summary> public Command(EnumCmd Cmd, EnumCmdType CmdType, String Param1, String Param2, String Param3, String Param4, EnumStrategyFlag ActiveSensors) { Update(Cmd, CmdType, Param1, Param2, Param3, Param4, ActiveSensors); return; }
/// <summary> /// Create a new 'Cmd' command with the 'CmdType' type /// Default value is used Params /// </summary> public Command(EnumCmd Cmd, EnumCmdType CmdType) { Update(Cmd, CmdType, null, null, null, null, EnumStrategyFlag.STRATEGYFLAG_NONE); return; }
/// <summary> /// Create a new 'Cmd' command with the 'CmdType' type and 'Params' parameters /// </summary> public Command(EnumCmd Cmd, EnumCmdType CmdType, String Param1, String Param2, String Param3, String Param4) { Update(Cmd, CmdType, Param1, Param2, Param3, Param4, EnumStrategyFlag.STRATEGYFLAG_NONE); return; }
/// <summary> /// Update the current command with the given data /// </summary> /// <param name="Cmd">Command</param> /// <param name="CmdType">Command Type</param> /// <param name="Param1">Param 1</param> /// <param name="Param2">Param 2</param> /// <param name="Param3">Param 3</param> /// <param name="Param4">Param 4</param> /// <param name="ActiveSensors"></param> /// <returns></returns> public bool Update(EnumCmd Cmd, EnumCmdType CmdType, String Param1, String Param2, String Param3, String Param4, EnumStrategyFlag ActiveSensors) { bool Ret = false; // Init Cmd to the default value _Cmd = EnumCmd.NotSet; _CmdType = EnumCmdType.NotSet; _Param1 = null; _Param2 = null; _Param3 = null; _Param4 = null; if (ActiveSensors != EnumStrategyFlag.STRATEGYFLAG_NONE) { _ActiveSensorsFlag = ActiveSensors; } _Cmd = Cmd; _CmdType = CmdType; // Check Params for Cmd // Cmd Modif : Add new command here switch (Cmd) { // ________________________________________________________ Param1 / Param2 case EnumCmd.MvtSimple_MoveInMM: case EnumCmd.App_SetStrategyFlags: if ((Param1 != null) && (Param2 != null)) { _Param1 = Param1; _Param2 = Param2; Ret = true; } else { LoadDefaultParamsValue(); Ret = true; } break; // ________________________________________________________ Param1 / Param4 case EnumCmd.Mvt_UseAngleOnly: case EnumCmd.MvtSimple_RotateInDeg: case EnumCmd.MvtSimple_RotateToAngleInDeg: if ((Param1 != null) && (Param4 != null)) { _Param1 = Param1; _Param4 = Param4; Ret = true; } else { LoadDefaultParamsValue(); Ret = true; } break; // ________________________________________________________ Param1 / Param2 / Param3 case EnumCmd.Mvt_UseDistOnly: case EnumCmd.App_IfGoto_System: case EnumCmd.App_IfGoto_Strategy: if ((Param1 != null) && (Param2 != null) && (Param3 != null)) { _Param1 = Param1; _Param2 = Param2; _Param3 = Param3; Ret = true; } else { LoadDefaultParamsValue(); Ret = true; } break; // ________________________________________________________ Param1 / Param2 / Param4 case EnumCmd.Mvt_UsePivotMode: if ((Param1 != null) && (Param2 != null) && (Param4 != null)) { _Param1 = Param1; _Param2 = Param2; _Param4 = Param4; Ret = true; } else { LoadDefaultParamsValue(); Ret = true; } break; // ________________________________________________________ Param2 / Param3 / Param4 case EnumCmd.App_SetNewPos: if ((Param2 != null) && (Param3 != null) && (Param4 != null)) { _Param2 = Param2; _Param3 = Param3; _Param4 = Param4; Ret = true; } else { LoadDefaultParamsValue(); Ret = true; } break; // ________________________________________________________ Param1 / Param2 / Param3 / Param4 case EnumCmd.Mvt_UseMixedMode: case EnumCmd.App_Wait: case EnumCmd.Mvt_UseSpline: if ((Param1 != null) && (Param2 != null) && (Param3 != null) && (Param4 != null)) { _Param1 = Param1; _Param2 = Param2; _Param3 = Param3; _Param4 = Param4; Ret = true; } else { LoadDefaultParamsValue(); Ret = true; } break; // ________________________________________________________ None case EnumCmd.Mvt_Stop: case EnumCmd.Sensors_ArmsClose: case EnumCmd.Sensors_ArmsCloseTotem: case EnumCmd.Sensors_ArmsOpenDown: case EnumCmd.Sensors_ArmsOpenUp: case EnumCmd.Sensors_ArmsOpenOneCD: case EnumCmd.Sensors_ArmsOpenTotem: case EnumCmd.Sensors_ArmsUngrab: case EnumCmd.Sensors_ElevatorLow: Ret = true; break; // ________________________________________________________ default: break; } return(Ret); }
/// <summary> /// Get the Command into String /// </summary> /// <param name="Cmd">Command we have to export into a string</param> /// <returns>A string that contains the command into a string</returns> public static String GetCmdToString(EnumCmd Cmd) { foreach (EnumCmd ECmd in Enum.GetValues(typeof(EnumCmd))) { if (Cmd == ECmd) return ECmd.ToString(); } return EnumCmd.NotSet.ToString(); }
/// <summary> /// Fonction pour verifier la valeur de la commande passée en paramètre /// </summary> /// <param name="valueToCheck">Valeur à tester</param> /// <param name="defaultValue">Valeur à utiliser en cas de valeur non valide</param> /// <returns>La commande verifiée</returns> private EnumCmd CheckEnumCmdValue(String valueToCheck, EnumCmd defaultValue) { EnumCmd Ret = defaultValue; try { foreach (EnumCmd currentValue in Enum.GetValues(typeof(EnumCmd))) { if (currentValue.ToString() == valueToCheck) Ret = currentValue; } } catch (Exception) { Ret = defaultValue; } return Ret; }
/// <summary> /// Update the current command with the given data /// </summary> /// <param name="Cmd">Command</param> /// <param name="CmdType">Command Type</param> /// <param name="Param1">Param 1</param> /// <param name="Param2">Param 2</param> /// <param name="Param3">Param 3</param> /// <param name="Param4">Param 4</param> /// <param name="ActiveSensors"></param> /// <returns></returns> public bool Update(EnumCmd Cmd, EnumCmdType CmdType, String Param1, String Param2, String Param3, String Param4, EnumStrategyFlag ActiveSensors) { bool Ret = false; // Init Cmd to the default value _Cmd = EnumCmd.NotSet; _CmdType = EnumCmdType.NotSet; _Param1 = null; _Param2 = null; _Param3 = null; _Param4 = null; if (ActiveSensors != EnumStrategyFlag.STRATEGYFLAG_NONE) _ActiveSensorsFlag = ActiveSensors; _Cmd = Cmd; _CmdType = CmdType; // Check Params for Cmd // Cmd Modif : Add new command here switch (Cmd) { // ________________________________________________________ Param1 / Param2 case EnumCmd.MvtSimple_MoveInMM: case EnumCmd.App_SetStrategyFlags: if ((Param1 != null) && (Param2 != null)) { _Param1 = Param1; _Param2 = Param2; Ret = true; } else { LoadDefaultParamsValue(); Ret = true; } break; // ________________________________________________________ Param1 / Param4 case EnumCmd.Mvt_UseAngleOnly: case EnumCmd.MvtSimple_RotateInDeg: case EnumCmd.MvtSimple_RotateToAngleInDeg: if ((Param1 != null) && (Param4 != null)) { _Param1 = Param1; _Param4 = Param4; Ret = true; } else { LoadDefaultParamsValue(); Ret = true; } break; // ________________________________________________________ Param1 / Param2 / Param3 case EnumCmd.Mvt_UseDistOnly: case EnumCmd.App_IfGoto_System: case EnumCmd.App_IfGoto_Strategy: if ((Param1 != null) && (Param2 != null) && (Param3 != null)) { _Param1 = Param1; _Param2 = Param2; _Param3 = Param3; Ret = true; } else { LoadDefaultParamsValue(); Ret = true; } break; // ________________________________________________________ Param1 / Param2 / Param4 case EnumCmd.Mvt_UsePivotMode: if ((Param1 != null) && (Param2 != null) && (Param4 != null)) { _Param1 = Param1; _Param2 = Param2; _Param4 = Param4; Ret = true; } else { LoadDefaultParamsValue(); Ret = true; } break; // ________________________________________________________ Param2 / Param3 / Param4 case EnumCmd.App_SetNewPos: if ((Param2 != null) && (Param3 != null) && (Param4 != null)) { _Param2 = Param2; _Param3 = Param3; _Param4 = Param4; Ret = true; } else { LoadDefaultParamsValue(); Ret = true; } break; // ________________________________________________________ Param1 / Param2 / Param3 / Param4 case EnumCmd.Mvt_UseMixedMode: case EnumCmd.App_Wait: case EnumCmd.Mvt_UseSpline: if ((Param1 != null) && (Param2 != null) && (Param3 != null) && (Param4 != null)) { _Param1 = Param1; _Param2 = Param2; _Param3 = Param3; _Param4 = Param4; Ret = true; } else { LoadDefaultParamsValue(); Ret = true; } break; // ________________________________________________________ None case EnumCmd.Mvt_Stop: case EnumCmd.Sensors_ArmsClose: case EnumCmd.Sensors_ArmsCloseTotem: case EnumCmd.Sensors_ArmsOpenDown: case EnumCmd.Sensors_ArmsOpenUp: case EnumCmd.Sensors_ArmsOpenOneCD: case EnumCmd.Sensors_ArmsOpenTotem: case EnumCmd.Sensors_ArmsUngrab: case EnumCmd.Sensors_ElevatorLow: Ret = true; break; // ________________________________________________________ default: break; } return Ret; }
public void InsertNewCmd_Before(int Index, EnumCmd CmdToAdd, int NewCmdID) { int FreeActionID = -1; if (Index <= 0) throw (new Exception("Invalid Param")); if (_Strategy == null) throw (new Exception("Invalid Param")); if (Index > _Strategy.Count) throw (new Exception("Invalid Param")); Command NewCommand = new Command(CmdToAdd); if (NewCmdID > 1) FreeActionID = GetPrevFreeActionID(NewCmdID + 1); else FreeActionID = GetPrevFreeActionID(_Strategy[Index - 1].ActionID); StrategyItem NewStrategyItem = new StrategyItem(NewCommand, FreeActionID, -1, -1); _Strategy.Insert(Index - 1, NewStrategyItem); }
public void InsertNewCmd_After(int Index, EnumCmd CmdToAdd, int NewCmdID) { int FreeActionID = -1; if (Index < 0) throw (new Exception("Invalid Param")); if (_Strategy == null) { _Strategy = new List<StrategyItem>(); } if (Index > _Strategy.Count) throw (new Exception("Invalid Param")); Command NewCommand = new Command(CmdToAdd); if (_Strategy.Count == 0) FreeActionID = 1; else { if (NewCmdID > 1) FreeActionID = GetNextFreeActionID(NewCmdID - 1); else FreeActionID = GetNextFreeActionID(_Strategy[Index - 1].ActionID); } StrategyItem NewStrategyItem = new StrategyItem(NewCommand, FreeActionID, -1, -1); _Strategy.Insert(Index, NewStrategyItem); }
/// <summary> /// Create a new 'Cmd' command /// Default values are used for CmdType and Params /// </summary> public Command(EnumCmd Cmd) { Update(Cmd, EnumCmdType.NotSet, null, null, null, null, EnumStrategyFlag.STRATEGYFLAG_NONE); return; }