Beispiel #1
0
        /// <summary>
        /// Adds device to device list, creates read and write handlers
        /// </summary>
        /// <param name="vDeviceName">string, Name of device that matches variable name in PLC</param>
        /// <param name="vDataType">Type, Data Type of the variable in the PLC</param>
        public MX_PLCDevice AddDevice(string vDeviceName, Type vDataType)
        {
            MX_PLCDevice vNewDevice = new MX_PLCDevice(); // Create a new temporary device

            vNewDevice.Name     = vDeviceName;            // Add name to the temporary device
            vNewDevice.DataType = vDataType;              // Add data type to the temporary device
            vDevices.Add(vNewDevice);                     // Add the new device to the device list
            int vIndex = vDevices.Count() - 1;            // Get the index of the newly added device

            // Create an ADS read handler for the new device
            vDevices[vIndex].ReadHndl = vAdsClient.AddDeviceNotification(vDeviceName, vStream, AdsTransMode.OnChange, updateTime, 0, vDevices[vIndex].Value);

            // Create an ADS write handler for the new device
            vDevices[vIndex].WriteHndl = vAdsClient.CreateVariableHandle(vDeviceName);

            // Return the new device in case the calling function wants it
            return(vDevices[vIndex]);
        }
Beispiel #2
0
 public DeviceChangedArgs(MX_PLCDevice _Device)
 {
     vDevice = _Device;
 }