Exemplo n.º 1
0
        ZS_Var(String name, VAR_TYPE vtype)
        {
            m_name = name;
            m_type = vtype;
            switch (vtype)
            {
                case VAR_TYPE.VBOOL :
                    m_value = new System.Boolean();
                    break;

                case VAR_TYPE.VFLOAT :
                    m_value = new System.Double();
                    break;

                case VAR_TYPE.VINT :
                    m_value = new System.Int64();
                    break;

                case VAR_TYPE.VSTRING :
                    m_value = "";
                    break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Internal Update Loop
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UpdateLoop(object sender, DoWorkEventArgs e)
        {
            PIVarDirection dir      = PIVarDirection.ePI_INPUT;
            VAR_TYPE       varT     = VAR_TYPE.S_BYTE;
            PI_VAR_UNION   varUnion = new PI_VAR_UNION();

            do
            {
                try
                {
                    Thread.Sleep(LoopInterval);
                    KeyValuePair <CompBase, MMCSingleAxis>[] pairs = listAxis.ToArray();
                    foreach (KeyValuePair <CompBase, MMCSingleAxis> pair in pairs)
                    {
                        try
                        {
                            if (pair.Key is IOBoolChannel)
                            {
                                BoolInput[] inputs = pair.Key.RecursiveFilterByType <BoolInput>();
                                foreach (BoolInput input in inputs)
                                {
                                    pair.Value.ReadPIVar((UInt16)(input.Channel), dir, varT, ref varUnion);

                                    if (varUnion.s_byte == 1)
                                    {
                                        input.Value = true;
                                    }
                                    else
                                    {
                                        input.Value = false;
                                    }
                                }
                            }
                            else
                            {
                                double dVal = pair.Value.GetActualPosition();
                                if (pair.Key is RealAxis)
                                {
                                    (pair.Key as RealAxis).SetCurrentPosition(dVal);
                                    (pair.Key as RealAxis).MoveDone = IsMotionDone(pair.Value);
                                }
                                else if (pair.Key is RealRotary)
                                {
                                    (pair.Key as RealRotary).SetCurrentPosition(dVal);
                                    (pair.Key as RealRotary).MoveDone = IsMotionDone(pair.Value);
                                }
                                BoolInput[] inputs = pair.Key.RecursiveFilterByType <BoolInput>();
                                foreach (BoolInput input in inputs)
                                {
                                    input.Value = pair.Value.GetDigInput(input.Channel + 16) != 0;
                                }
                            }


                            MC_STATE_SINGLE status = (MC_STATE_SINGLE)(pair.Value.ReadStatus() & plcStateMask);
                            if ((status & MC_STATE_SINGLE.ERROR_STOP) == MC_STATE_SINGLE.ERROR_STOP)
                            {
                                pair.Key.MachineStatus(string.Format("{0} ErrorStop", pair.Value.AxisName));
                            }
                        }
                        catch (MMCException ex)
                        {
                            U.LogPopup(ex, "MMC Update Error Axis {0}", pair.Key.Name);
                        }
                    }
                }
                catch (Exception ex)
                {
                    U.LogError(ex, "Error UpdateLoop: ");
                }
            } while (!_destroy);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Set a digital output
        /// </summary>
        /// <param name="boolOutput"></param>
        /// <param name="value"></param>
        public override void Set(BoolOutput boolOutput, bool value)
        {
            VAR_TYPE     varT     = VAR_TYPE.BYTE_ARR;
            PI_VAR_UNION varUnion = new PI_VAR_UNION();


            CompBase compAxis = boolOutput.GetParent <RealAxis>();

            if (compAxis == null)
            {
                compAxis = boolOutput.GetParent <RealRotary>();
                if (compAxis == null)
                {
                    compAxis = boolOutput.GetParent <IOBoolChannel>();
                }
            }


            if (listAxis.ContainsKey(compAxis))
            {
                try
                {
                    MMCSingleAxis singleAxis = listAxis[compAxis];

                    if (compAxis is RealRotary)
                    {
                        int val = value ? 1 : 0;
                        //singleAxis.SetDigOutputs(boolOutput.Channel << 16, (byte)(value ? 0x1 : 0x0), 0x0);
                        singleAxis.SendIntCmdViaSDO(string.Format("OB[{0}]={1}", boolOutput.Channel, val), 1000);
                    }
                    else if (compAxis is RealAxis)
                    {
                        uint val     = outputVal[compAxis];
                        uint chanBit = (uint)(1 << (16 + boolOutput.Channel));
                        if (value)
                        {
                            val |= chanBit;
                        }
                        else
                        {
                            val &= ~chanBit;
                        }
                        singleAxis.SetDigOutputs32Bit(0, val);
                        outputVal[compAxis] = val;
                    }

                    else
                    {
                        UInt16 index = (UInt16)boolOutput.Channel;

                        if (value)
                        {
                            varUnion.s_byte = 0;
                        }
                        else
                        {
                            varUnion.s_byte = 1;
                        }
                        singleAxis.WritePIVar(index, varUnion, varT);
                    }

                    boolOutput.Value = value;
                    //singleAxis.SetDigOutputs(chan, (byte)(value ? 1 : 0), (byte)1);
                }
                catch (Exception ex)
                {
                    U.LogPopup(ex, "Trouble setting Digital Output ({0})", boolOutput.Name);
                }
            }
        }
Exemplo n.º 4
0
 public static Symbol GenerateAnonymousSymbol(VAR_TYPE _type, int _addr, int _level = 0)
 {
     return(new Symbol(_type, _addr, _level));
 }
Exemplo n.º 5
0
 public Symbol(string _name, VAR_TYPE _type, int _addr, int _level = 0)
 {
     name = _name;
     type = _type;
     addr = _addr;
 }
Exemplo n.º 6
0
 private Symbol(VAR_TYPE _type, int _addr, int _level = 0)
 {
     type = _type;
     addr = _addr;
 }
Exemplo n.º 7
0
 ZS_Var(String name, VAR_TYPE vtype, Object value)
 {
     m_name = name;
     m_type = vtype;
     m_value = value;
 }
    public static System.Type GetTypeData(string name, out VAR_TYPE var_type, out VAR_TYPE sub_type)
    {
        var_type = VAR_TYPE.BASIC;
        sub_type = VAR_TYPE.BASIC;

        System.Type t = System.Type.GetType(name);
        if (name == "T")
        {
            var_type = VAR_TYPE.CLASS;
            return(null);
        }
        if (t != null)
        {
            if (t.IsClass == true)
            {
                var_type = VAR_TYPE.CLASS;
            }
            return(t);
        }

        switch (name)
        {
        case "bool":
            return(typeof(bool));

        case "byte":
            return(typeof(byte));

        case "sbyte":
            return(typeof(sbyte));

        case "short":
            return(typeof(short));

        case "int":
            return(typeof(int));

        case "char":
            return(typeof(char));

        case "string":
            return(typeof(string));

        case "float":
            return(typeof(float));

        case "double":
            return(typeof(double));

        case "DateTime":
            var_type = VAR_TYPE.STRUCT;
            return(typeof(System.DateTime));

        case "Vector3":
            var_type = VAR_TYPE.STRUCT;
            return(typeof(Vector3));

        case "Vector4":
            var_type = VAR_TYPE.STRUCT;
            return(typeof(Vector4));

        case "Color":
            var_type = VAR_TYPE.STRUCT;
            return(typeof(Color));

        case "AnimationCurve":
            sub_type = VAR_TYPE.CLASS;
            return(typeof(AnimationCurve));

        // Basic
        case "TableData":
            var_type = VAR_TYPE.CLASS;
            return(typeof(TableData));

        case "GameObject":
            var_type = VAR_TYPE.CLASS;
            return(typeof(GameObject));

        case "AudioClip":
            var_type = VAR_TYPE.CLASS;
            return(typeof(AudioClip));
        }

        var_type = VAR_TYPE.CAST;
        return(typeof(int));
    }
Exemplo n.º 9
0
 public Variant(VAR_TYPE type, int rank, string name)
 {
     m_varType  = type;
     InputRank  = rank;
     ObjectName = name;
 }