public IDataItem createByForm(IConnection aConnection, IWin32Window aOwner) { Connection lConnection = (Connection)aConnection; DataItem lItem = new DataItem(); using (var lSetupForm = new ItemSetupForm(lConnection, lItem)) { if (lSetupForm.ShowDialog(aOwner) == DialogResult.OK) { lItem.mMemoryType = lSetupForm.MemoryType; lItem.DB = lSetupForm.DB; lItem.Byte = lSetupForm.Byte; lItem.Bit = lSetupForm.Bit; lItem.DataType = lSetupForm.DataType; lItem.FloatingP = lSetupForm.FloatingP; lItem.Signed = lSetupForm.Signed; lItem.Length = lSetupForm.Length; lConnection.addItem(lItem); } else { lItem = null; } } return(lItem); }
public IDataItem createFromXML(IConnection aConnection, XmlTextReader aXMLTextReader) { Connection lConnection = (Connection)aConnection; DataItem lItem = new DataItem(); XMLAttributeReader lReader = new XMLAttributeReader(aXMLTextReader); lItem.mMemoryType = (EPLCMemoryType)Enum.Parse(typeof(EPLCMemoryType), lReader.getAttribute <String>("MemoryType")); if (lItem.mMemoryType == EPLCMemoryType.DB) { lItem.DB = (int)lReader.getAttribute <UInt32>("DB"); } lItem.DataType = (PointDataTypeConstants)Enum.Parse(typeof(PointDataTypeConstants), lReader.getAttribute <String>("DataType")); lItem.Byte = (int)lReader.getAttribute <UInt32>("Byte"); if (lItem.DataType == PointDataTypeConstants.S7_Bit) { lItem.Bit = (int)lReader.getAttribute <UInt32>("Bit"); } else if (lItem.DataType == PointDataTypeConstants.S7_Byte || lItem.DataType == PointDataTypeConstants.S7_Word) { lItem.Signed = lReader.getAttribute <Boolean>("Signed", lItem.Signed); } else if (lItem.DataType == PointDataTypeConstants.S7_DoubleWord) { lItem.FloatingP = lReader.getAttribute <Boolean>("FloatingPoint", lItem.FloatingP); if (lItem.FloatingP == false) { lItem.Signed = lReader.getAttribute <Boolean>("Signed", lItem.Signed); } } if ((lItem.mMemoryType == EPLCMemoryType.I || lItem.mMemoryType == EPLCMemoryType.Q) && lItem.DataType != PointDataTypeConstants.S7_Bit) { lItem.Length = (int)lReader.getAttribute <UInt32>("Length", 1); } lConnection.addItem(lItem); return(lItem); }