/// <summary> /// 写入一个梯形图元件 /// </summary> /// <param name="bvmodel">元件</param> static private void Write(BaseViewModel bvmodel) { // 连线不必写入 if (bvmodel is HorizontalLineViewModel || bvmodel is VerticalLineViewModel) { return; } // 坐标,指令ID edata.Add(Int32_Low(bvmodel.X)); edata.Add(Int32_Low(bvmodel.Y)); edata.Add(Int32_Low(LadderInstViewModelPrototype.GetOrderFromCatalog(bvmodel.GetCatalogID()))); // 写入每个软元件参数 for (int i = 0; i < bvmodel.Model.ParaCount; i++) { IValueModel ivmodel = bvmodel.Model.GetPara(i); // 在软元件表中找到,写入ID if (regids.ContainsKey(ivmodel.ValueString)) { int regid = regids[ivmodel.ValueString]; edata.Add(Int32_Low(regid)); edata.Add(Int32_High(regid)); } // 写入0xFFFF表示空参数 else { edata.Add(0xFF); edata.Add(0xFF); } } }