Beispiel #1
0
 /// <summary>
 /// 初始化来自某个PLC控制器类型的IO点(一个点)
 /// </summary>
 public MCComponentGroup(ControllerTypeConst controllerType, string tagName)
 {
     Components = new List <MCComponent>()
     {
         new MCComponent(tagName, controllerType)
     };
 }
Beispiel #2
0
        /// <summary>
        /// 按给定符号名、控制器类型构建地址对象(推荐使用)
        /// </summary>
        public FxAddress(string tagName, ControllerTypeConst controllerType)
        {
            _BaseNumberOfXY = controllerType.ToBaseNumber();

            _TagName     = tagName;
            _AddressType = FxAddressManager.Instance[tagName];

            // 按实际地址更新 地址布局类型
            switch (_AddressType)
            {
            case FxAddressType.X:
            case FxAddressType.Y:
            case FxAddressType.M:
                _AddressLayoutType = FxAddressLayoutType.AddressLayoutBin;
                break;

            case FxAddressType.T:
                _AddressLayoutType = FxAddressLayoutType.AddressLayoutInt32;
                break;

            default:
                _AddressLayoutType = FxAddressLayoutType.AddressLayoutBin;
                break;
            }

            _TagOffset = GetTagOffset(tagName, _BaseNumberOfXY);

            if (controllerType.IsFxPLCController())
            {
                _UniformAddr = GetUniformAddr(tagName, out _AddressType, _AddressLayoutType);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 构建FxSerialDeamon类实例
        /// </summary>
        /// <param name="controllerType">目前仅支持ctPLC_Fx</param>
        /// <param name="controllerId"></param>
        /// <param name="controllerName">控制器名称----程序内部一般不需要</param>
        /// <param name="controllerAddress">表示为:串口号、IP地址</param>
        /// <param name="controllerAddressPort">控制器地址的端口号(表示为:TCP/UDP的Port、485的设备ID)</param>
        /// <param name="controllerChannelCount">通道数,例如128,256 ... ...</param>
        public FxSerialDeamon(ControllerTypeConst controllerType, int controllerId, string controllerName, string controllerAddress, short controllerAddressPort, short controllerChannelCount)
            : base(controllerType, controllerId, controllerName, controllerAddress, controllerAddressPort, controllerChannelCount)
        {
            Debug.Assert(controllerType == ControllerTypeConst.ctPLC_Fx, "请确认!这里仅仅支持 ControllerTypeConst.ctPLC_Fx .");

            _SerialPort = null;
            _RingBuffer = new FxRingBuffer();
        }
Beispiel #4
0
 /// <summary>
 /// 根据地址类型与地址偏移构建地址
 /// </summary>
 public FxAddress(ControllerTypeConst controllerType, FxAddressType addressType, int offset)
 {
     _BaseNumberOfXY    = controllerType.ToBaseNumber();
     _TagOffset         = offset;
     _AddressType       = addressType;
     _AddressLayoutType = FxAddressManager.DefaultLayoutType;
     _TagName           = ToFormatedTagName();
     _UniformAddr       = GetUniformAddr(_TagName, out _AddressType, _AddressLayoutType);
 }
 public ControllerBaseImpl(ControllerTypeConst controllerType, int controllerId, string controllerName, string controllerAddress, short controllerAddressPort, short controllerChannelCount)
 {
     _ControllerType         = controllerType;
     _ControllerId           = controllerId;
     _ControllerName         = controllerName;
     _ControllerAddress      = controllerAddress;
     _ControllerAddressPort  = controllerAddressPort;
     _ControllerChannelCount = controllerChannelCount;
     _APConversion           = AcquirePointConversion.GetDefaultNullConversion();
 }
Beispiel #6
0
 /// <summary>
 /// 得到并返回给定的PLC控制器类型的地址表示法中 X/Y 点的进制数
 /// 例如:
 ///		1,针对 Fx 系列 X007、Y117 等中的 007、117 均为 8进制,则返回8
 ///		2,针对 Qn 系列,X101、Y00F 等中的 101、00F 均为 16进制,则返回16进制
 ///		3、其它非PLC控制器类型,返回 0
 /// </summary>
 public static int ToBaseNumber(this ControllerTypeConst ct)
 {
     if (ct == ControllerTypeConst.ctPLC_Fx)
     {
         return(8);
     }
     else if (ct == ControllerTypeConst.ctPLC_Qn || ct == ControllerTypeConst.ctPLC_QnMC)
     {
         return(16);
     }
     else
     {
         return(0);
     }
 }
Beispiel #7
0
 /// <summary>
 /// 判断并返回控制器是否属于 “FX 系列 PLC控制器”
 /// </summary>
 public static bool IsFxPLCController(this ControllerTypeConst ct)
 {
     return(ct == ControllerTypeConst.ctPLC_Fx);
 }
Beispiel #8
0
 /// <summary>
 /// 判断并返回控制器是否属于 “PLC控制器”
 /// </summary>
 public static bool IsPLCController(this ControllerTypeConst ct)
 {
     return((int)ct >= (int)ControllerTypeConst.ctPLC && (int)ct <= ((int)ControllerTypeConst.ctPLC + 0xff));
 }
Beispiel #9
0
 /// <summary>
 /// 判断并返回控制器是否属于 “慢速控制器”
 /// </summary>
 public static bool IsSlowController(this ControllerTypeConst ct)
 {
     return((ct & ControllerTypeConst.ctSlowController) == ControllerTypeConst.ctSlowController);
 }
Beispiel #10
0
 /// <summary>
 /// 判断并返回控制器是否属于 “主动控制器”
 /// </summary>
 public static bool IsInitiativeController(this ControllerTypeConst ct)
 {
     return((ct & ControllerTypeConst.ctInitiativeController) == ControllerTypeConst.ctInitiativeController);
 }
 public ControllerBaseImpl(ControllerTypeConst controllerType, int controllerId, string controllerName)
     : this(controllerType, controllerId, controllerName, string.Empty, 0, 1)
 {
 }
 public ControllerBaseImpl(ControllerTypeConst controllerType)
     : this(controllerType, 0, string.Empty, string.Empty, 0, 1)
 {
 }
Beispiel #13
0
 /// <summary>
 /// 初始化来自某个PLC控制器类型的IO点(一个点)
 /// </summary>
 public MCComponent(ControllerTypeConst controllerType, string tagName)
 {
     this.Address = new FxAddress(tagName, controllerType);
     this.Value   = (short)0;
 }