Ejemplo n.º 1
0
 public CentrifugeAction()
 {
     StartCoil     = new PLCParameter <bool>();
     ToSpeedTime   = new PLCParameter <short>();
     KeepSpeedTime = new PLCParameter <int>();
     Speed         = new PLCParameter <float>();
 }
Ejemplo n.º 2
0
 public Couveuse()
 {
     HotSwitchCoil  = new PLCParameter <bool>();
     CurentTemp     = new PLCParameter <float>();
     SetupTemp      = new PLCParameter <float>();
     TempCompensate = new PLCParameter <float>();
 }
Ejemplo n.º 3
0
        public void Read2PLC <T>(PLCParameter <T> pLCParameter, Type targetType, float factor)
        {
            if (String.IsNullOrEmpty(pLCParameter.Addr))
            {
                return;
            }
            String TypeName    = targetType == null ? typeof(T).Name : targetType.Name;
            bool   is_time_out = false;

            switch (TypeName)
            {
            case "Boolean":
            {
                ReadCoil(pLCParameter.Addr);
                var value = GetBoolBlock(pLCParameter.Addr, false, 1000, false, out is_time_out);
                pLCParameter.SetValue = Unity.AsType <T>(value);
                break;
            }

            case "Single":
            {
                ReadRegister(pLCParameter.Addr);
                var value = GetIntBlock(pLCParameter.Addr, 1000, out is_time_out) / factor;
                pLCParameter.SetValue = Unity.AsType <T>(value);
                break;
            }

            case "Int32":
            {
                ReadRegister(pLCParameter.Addr);
                var value = GetIntBlock(pLCParameter.Addr, 1000, out is_time_out) / factor;
                pLCParameter.SetValue = Unity.AsType <T>(value);
                break;
            }

            case "Int16":
            {
                ReadRegister(pLCParameter.Addr);
                var value = GetIntBlock(pLCParameter.Addr, 1000, out is_time_out) / factor;
                pLCParameter.SetValue = Unity.AsType <T>(value);
                break;
            }

            default:
            {
                break;
            }
            }
        }
Ejemplo n.º 4
0
 public Centrifuge()
 {
     TimerSemaphore = new Semaphore(0, 1);
     InitCoil       = new PLCParameter <bool>();
     Zero           = new PLCParameter <bool>();
     Angle          = new PLCParameter <float>();
     AngleFactor    = new PLCParameter <float>();
     CurrentSpeed   = new PLCParameter <int>();
     SpeedFactor    = new PLCParameter <float>();
     AngleStartCoil = new PLCParameter <bool>();
     DoneCoil       = new PLCParameter <bool>();
     LowAction      = new CentrifugeAction();
     HighAction     = new CentrifugeAction();
     EndAction      = new CentrifugeAction();
     Speed          = new PLCParameter <float>();
 }
Ejemplo n.º 5
0
        public static void Set2PLC <T>(PLCParameter <T> pLCParameter, Type targetType, float factor, AbstractComm Comm)
        {
            if (String.IsNullOrEmpty(pLCParameter.Addr))
            {
                return;
            }
            String TypeName = targetType == null ? typeof(T).Name : targetType.Name;

            switch (TypeName)
            {
            case "Boolean":
            {
                Comm.SetCoil((bool)(Object)pLCParameter.SetValue, Comm.ConvertFatekAddrToModbusAddr(pLCParameter.Addr));
                break;
            }

            case "Single":
            {
                Comm.SetRegister(pLCParameter.Addr, (float)(Object)pLCParameter.SetValue * factor);
                break;
            }

            case "Int32":
            {
                Comm.SetRegister(pLCParameter.Addr, Convert.ToInt32(Convert.ToSingle((Object)pLCParameter.SetValue) * factor));
                break;
            }

            case "Int16":
            {
                var val = Convert.ToInt16(Convert.ToSingle((Object)pLCParameter.SetValue) * factor);
                //Console.WriteLine("val=" + val);
                Comm.SetRegister(pLCParameter.Addr, val);
                break;
            }

            default:
            {
                break;
            }
            }
        }
Ejemplo n.º 6
0
        public void Set2PLC <T>(PLCParameter <T> pLCParameter, Type targetType, float factor)
        {
            if (String.IsNullOrEmpty(pLCParameter.Addr))
            {
                return;
            }
            String TypeName = targetType == null ? typeof(T).Name : targetType.Name;

            switch (TypeName)
            {
            case "Boolean":
            {
                SetCoil(pLCParameter.Addr, (bool)(Object)pLCParameter.SetValue);
                break;
            }

            case "Single":
            {
                SetRegister(pLCParameter.Addr, Convert.ToInt32((float)(Object)pLCParameter.SetValue * factor));
                break;
            }

            case "Int32":
            {
                SetRegister(pLCParameter.Addr, Convert.ToInt32(Convert.ToSingle((Object)pLCParameter.SetValue) * factor));
                break;
            }

            case "Int16":
            {
                var val = Convert.ToInt16(Convert.ToSingle((Object)pLCParameter.SetValue) * factor);
                SetRegister(pLCParameter.Addr, val);
                break;
            }

            default:
            {
                break;
            }
            }
        }
Ejemplo n.º 7
0
 public Electromotor()
 {
     this.InitCoil  = new PLCParameter <bool>();
     Zero           = new PLCParameter <Boolean>();
     Distance       = new PLCParameter <float>();
     Speed          = new PLCParameter <Int32>();
     Factor         = new PLCParameter <float>();
     Maximum        = new PLCParameter <float>();
     DoneCoil       = new PLCParameter <Boolean>();
     StartCoil      = new PLCParameter <Boolean>();
     InitSpeed      = new PLCParameter <int>();
     InitDistance   = new PLCParameter <float>();
     RealDistance   = new PLCParameter <float>();
     InitTime       = new PLCParameter <float>();
     DistanceTime   = new PLCParameter <float>();
     PressureTime   = new PLCParameter <Int32>();
     PressureSwitch = new PLCParameter <Boolean>();
     Pressure       = new PLCParameter <Int32>();
     PickTMotor     = new PLCParameter <Int32>();
     StopCoil       = new PLCParameter <Boolean>();
     StartAfter     = new PLCParameter <Int32>();
 }
Ejemplo n.º 8
0
 public DoubleSpeedMotor() : base()
 {
     SecondSpeed = new PLCParameter <Int32>();
     DownSpeed   = new PLCParameter <Int32>();
 }
Ejemplo n.º 9
0
 public void Set2PLC <T>(PLCParameter <T> pLCParameter)
 {
     Set2PLC <T>(pLCParameter, null, 1);
 }
Ejemplo n.º 10
0
 public void Read2PLC <T>(PLCParameter <T> pLCParameter)
 {
     Read2PLC <T>(pLCParameter, null, 1);
 }
Ejemplo n.º 11
0
 public Mixer() : base()
 {
     TimeSpan = new PLCParameter <short>();
 }
Ejemplo n.º 12
0
        public static void LoadPLC <T>(PLCParameter <T> pLCParameter, Type pclType, float factor, AbstractComm Comm)
        {
            if (String.IsNullOrEmpty(pLCParameter.Addr))
            {
                return;
            }
            String TypeName = pclType == null ? typeof(T).Name : pclType.Name;
            Object curVal   = null;

            switch (TypeName)
            {
            case "Boolean":
            {
                curVal = (Object)Comm.ReadCoil(1, pLCParameter.Addr)[0];
                break;
            }

            case "Single":
            {
                curVal = (Single)(Comm.ReadFloat(pLCParameter.Addr) / factor);
                break;
            }

            case "Int32":
            {
                curVal = (Comm.ReadInt32(pLCParameter.Addr) / factor);
                break;
            }

            case "Int16":
            {
                curVal = (Comm.ReadInt16(pLCParameter.Addr) / factor);
                break;
            }

            default:
            {
                break;
            }
            }
            switch (typeof(T).Name)
            {
            case "Boolean":
            case "Single":
            {
                pLCParameter.CurrentValue = (T)curVal;
                break;
            }

            case "Int32":
            {
                pLCParameter.CurrentValue = (T)(Object)Convert.ToInt32(curVal);
                break;
            }

            case "Int16":
            {
                pLCParameter.CurrentValue = (T)(Object)Convert.ToInt16(curVal);
                break;
            }

            default:
            {
                break;
            }
            }
        }
Ejemplo n.º 13
0
 public static void LoadPLC <T>(PLCParameter <T> pLCParameter, AbstractComm Comm)
 {
     LoadPLC <T>(pLCParameter, null, 1, Comm);
 }