protected override void WriteAuto(CompInfoTemp c, int autoBufferNo, ref string scripts) { ParseTopo(c.content[KeyWordDef.TOP]); //Write IO Config string KeyWord = "IORepeat"; int startIndex = CompManager.GetBufferIndex(ST.AUTO, scripts); List <Dictionary <string, string> > IODictList = GenerateDictList(c, out int IIndex, out int OIndex); IODictList = IODictList.OrderByDescending(d => d["#IOType#"]).Select((d, i) => { if (i != 0) { d.Remove("#StartIndex#"); } return(d); }).ToList(); CheckIndexes(IODictList); TextFunctions.AppendMultiRepeat(ref scripts, KeyWord, IODictList, startIndex); Dictionary <string, string> OADict = new Dictionary <string, string> { { "OA1", "BeforeUnstopRepeat" }, { "OA2", "DuringEMGRepeat" }, { "OA3", "EscapeEMGRepeat" }, }; foreach (var kv in OADict) { if (c.content.ContainsKey(kv.Key)) { KeyWord = kv.Value; IODictList = GetOADictList(c, kv.Key); TextFunctions.AppendMultiRepeat(ref scripts, KeyWord, IODictList, startIndex); } } if (!c.content.ContainsKey("EMG")) { c.content.Add("EMG", "EMG"); } TextFunctions.ReplaceSingle(ref scripts, c.content, startIndex); TextFunctions.AppendMultiNoRepeat(ref scripts, c.content, startIndex); }
protected override void WriteHome(CompInfoTemp c, List <int> homeBufferNo, ref string scripts) { string CHM = c.content[KeyWordDef.HM]; if (CHM.Contains("D")) { return; } int HG = GetHomeBufferNo(c, homeBufferNo); int HGIndex = GetHomeIndex(c, homeBufferNo, scripts); int count = GetHomeCount(c, homeBufferNo, scripts); TextFunctions.ReplaceSingle(ref scripts, "BH", HG.ToString(), HGIndex, count); string HM = ""; if (CHM.Contains("L")) { HM += "L"; } else if (CHM.Contains("R")) { HM += "R"; } else { throw new Exception("未定义回零方向"); } if (CHM.Contains("I")) { HM += "I"; } List <string> homeSpeedList = c.content[KeyWordDef.HS].Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries).ToList(); List <Dictionary <string, string> > homeDictList = new List <Dictionary <string, string> >() { new Dictionary <string, string>() { { "#AxisNo#", GetAxisNo(c).ToString() }, { "#NSpeed#", homeSpeedList[0] }, { "#HSpeed#", homeSpeedList.Count > 1 ? homeSpeedList[1] : (int.Parse(homeSpeedList[0]) / 2).ToString() }, { "@HP", c.content.ContainsKey(KeyWordDef.HP)? c.content[KeyWordDef.HP] : "0" }, { "@HF", c.content[KeyWordDef.HF] }, { "#HomingMethod#", HM }, { "#GoSafe#", c.content.ContainsKey(KeyWordDef.HP)? "" : "!" }, { "#NAME#", GetAxisName(c) }, { "#COMP#", int.Parse(c.content[KeyWordDef.CN]) > 0 ? "" : "!" }, } }; string repeatKeyWord = "HomeRepeat"; TextFunctions.AppendMultiRepeat(ref scripts, repeatKeyWord, homeDictList, HGIndex, count); if (CHM.Contains("Z") || c.content.ContainsKey(KeyWordDef.SZ)) { TextFunctions.ReplaceSingle(ref scripts, "ZLimitSafeLine__", "", HGIndex, count); } if (CHM.Contains("Z")) { homeDictList = new List <Dictionary <string, string> >() { new Dictionary <string, string>() { { "#AxisNo#", GetAxisNo(c).ToString() }, { "@BH", HG.ToString() }, } }; repeatKeyWord = "ZAxisSafeRepeat"; TextFunctions.AppendMultiRepeat(ref scripts, repeatKeyWord, homeDictList, HGIndex, count); repeatKeyWord = "ZLimitSafeRepeat"; TextFunctions.AppendMultiRepeat(ref scripts, repeatKeyWord, homeDictList, HGIndex, count); } if (c.content.ContainsKey(KeyWordDef.SZ)) { List <int> li = MainHandler.GetAxisNoByCompName(c.content[KeyWordDef.SZ]); if (li.Count == 0) { throw new Exception($"部件{c.rname}属性{KeyWordDef.SZ}错误:{c.content[KeyWordDef.SZ]}"); } List <Dictionary <string, string> > SZDictList = new List <Dictionary <string, string> >(); foreach (int i in li) { if (!DictionaryFunctions.GetValueOrAddNewKey(homeSZDict, HG, new List <int>()) .Contains(i)) { homeSZDict[HG].Add(i); SZDictList.Add(new Dictionary <string, string>() { { "#AxisNo#", i.ToString() }, { "@BH", HG.ToString() }, }); } } repeatKeyWord = "ZLimitSafeRepeat"; TextFunctions.AppendMultiRepeat(ref scripts, repeatKeyWord, SZDictList, HGIndex, count); } }