Beispiel #1
0
        public void AddList(string adresse, string symbolName, string dataType, string comment, string symbolType, bool dataLog = false)
        {
            int byte_length = 0;
            ClsSingeltonVariablesCollecterDataType data_type = ClsSingeltonVariablesCollecterDataType.Null;

            if (dataType == "BOOL")
            {
                byte_length = 2;
                data_type   = ClsSingeltonVariablesCollecterDataType.Int;
            }
            if (dataType == "INT")
            {
                byte_length = 2;
                data_type   = ClsSingeltonVariablesCollecterDataType.Int;
            }
            if (dataType == "TIME")
            {
                byte_length = 4;
                data_type   = ClsSingeltonVariablesCollecterDataType.Int;
            }
            if (dataType == "REAL")
            {
                byte_length = 4;
                data_type   = ClsSingeltonVariablesCollecterDataType.Double;
            }

            int db_nr   = 0;
            int byte_nr = 0;
            int bit_nr  = 0;

            string[] adressen = adresse.Split('.');
            if (adressen.Count() >= 2)
            {
                db_nr   = Convert.ToInt32(FuncString.GetOnlyNumeric(adressen[0]));
                byte_nr = Convert.ToInt32(FuncString.GetOnlyNumeric(adressen[1]));
                if (adressen.Count() == 3)
                {
                    bit_nr = Convert.ToInt32(FuncString.GetOnlyNumeric(adressen[2]));
                    int rest = byte_nr % 2;
                    byte_length = byte_length - rest;
                }
                if (this.m_DatabasesInfo.ContainsKey(db_nr))
                {
                    int value = Convert.ToInt32(this.m_DatabasesInfo[db_nr]);
                    if ((byte_nr + byte_length) > value)
                    {
                        this.m_DatabasesInfo[db_nr] = byte_nr + byte_length;
                    }
                }
                else
                {
                    this.m_DatabasesInfo.Add(db_nr, byte_nr);
                    this.m_DatabasesNr.Add(db_nr);
                }
            }
            ClsSingeltonPlcDatas data;

            data.Adress         = adresse;
            data.DatabaseNumber = db_nr;
            data.ByteNumber     = byte_nr;
            data.BitNumber      = bit_nr;
            data.Symbolname     = symbolName;
            data.DataType       = dataType;
            data.Comment        = comment;
            data.Value          = "0.0";
            data.DataLog        = dataLog;
            data.SymbolType     = symbolType;
            this.m_Daten.Add(data);
            string keyInfo = "DB" + db_nr + "." + symbolName;

            this.m_VarCollect.CreateVariable(keyInfo, data_type);
            if (!this.m_SymbolInfo.ContainsKey(keyInfo))
            {
                this.m_SymbolInfo.Add(keyInfo, data);
            }
        }
Beispiel #2
0
        public void AddList(string Adress, string Symbolname, string DataType, string Comment, bool DataLog)
        {
            int byteLaenge = 0;

            if (DataType == "BOOL")
            {
                byteLaenge = 2;
            }
            if (DataType == "INT")
            {
                byteLaenge = 2;
            }
            if (
                DataType == "TIME" ||
                DataType == "REAL"
                )
            {
                byteLaenge = 4;
            }
            int dbNr   = 0;
            int byteNr = 0;
            int bitNr  = 0;

            string[] adress = Adress.Split('.');
            if (adress.Count() >= 2)
            {
                dbNr   = Convert.ToInt32(FuncString.GetOnlyNumeric(adress[0]));
                byteNr = Convert.ToInt32(FuncString.GetOnlyNumeric(adress[1]));
                if (adress.Count() == 3)
                {
                    bitNr = Convert.ToInt32(FuncString.GetOnlyNumeric(adress[2]));
                    int rest = byteNr % 2;
                    byteLaenge = byteLaenge - rest;
                }
                if (DatabasesInfo.ContainsKey(dbNr))
                {
                    int value = Convert.ToInt32(DatabasesInfo[dbNr]);
                    if ((byteNr + byteLaenge) > value)
                    {
                        DatabasesInfo[dbNr] = byteNr + byteLaenge;
                    }
                }
                else
                {
                    DatabasesInfo.Add(dbNr, byteNr);
                    DatabasesNr.Add(dbNr);
                }
            }
            PLCDatas data;

            data.Adress         = Adress;
            data.DatabaseNumber = dbNr;
            data.ByteNumber     = byteNr;
            data.BitNumber      = bitNr;
            data.Symbolname     = Symbolname;
            data.DataType       = DataType;
            data.Comment        = Comment;
            data.Value          = "0.0";
            data.DataLog        = DataLog;
            this.Daten.Add(data);

            string keyInfo = "DB" + dbNr + "." + Symbolname;

            if (!SymbolInfo.ContainsKey(keyInfo))
            {
                SymbolInfo.Add(keyInfo, data);
            }
        }