Пример #1
0
        //-------------------------------------------------------------
        private void Perceptron()
        {
            ActivitiesStruct TempActivity  = new ActivitiesStruct();
            bool             ActivityValue = true;

            for (int i = 0; i < Activities.Count; i++)                                                         // check logic for each activity
            {
                foreach (SReceptorsStruct ModelReceptor in SDictionary)                                        // go though Dictionary and check needed for current activity
                {
                    if (ModelReceptor.ActivityID == Activities[i].ActivityID)                                  // we need to compare with real Receptor value
                    {
                        foreach (SReceptorsStruct Receptor in SReceptors)                                      // go though real S-receprots
                        {
                            if (Receptor.SName == ModelReceptor.SName)                                         // we found required real receptor
                            {
                                if (!((Receptor.SExist == true) && (Receptor.SValue == ModelReceptor.SValue))) // logic comparation - inverted
                                {
                                    ActivityValue = false;                                                     // comparation failed -> Activity logic function = false -> not this Activity
                                }
                            }
                        }
                    }
                }
                if (ActivityValue == false)
                {
                    TempActivity = Activities[i];
                    TempActivity.ActivityValue = ActivityValue;
                    Activities[i] = TempActivity;
                }
                ActivityValue = true;
            }
        }
Пример #2
0
        //-------------------------------------------------------------
        public void Filler() // creating of dinamic components and activity list filling
        {
            CurrentData = new SurfaceData();
            LastData    = new SurfaceData();

            SReceptors  = new List <SReceptorsStruct>();
            SDictionary = new List <SReceptorsStruct>();
            SReceptorsStruct TempSReceptor;

            String query = "SELECT * FROM SReceptors";

            using (conn = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand(query, conn);
                try
                {
                    conn.Open();
                    SqlDataReader reader = cmd.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            TempSReceptor.SName      = reader.GetString(1);
                            TempSReceptor.ActivityID = reader.GetInt32(2);
                            TempSReceptor.SExist     = true;
                            TempSReceptor.SValue     = reader.GetInt32(3);
                            SDictionary.Add(TempSReceptor);
                            //Console.WriteLine("{0}\t{1}", reader.GetInt32(0), reader.GetString(1));
                        }
                    }
                    else
                    {
                        Console.WriteLine("No Activities");
                    }
                    reader.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);

                    conn.Close();
                }
            }

            Activities = new List <ActivitiesStruct>();
            ActivitiesStruct TempActivity = new ActivitiesStruct();

            query = "SELECT * FROM Activities";
            using (conn = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand(query, conn);
                try
                {
                    conn.Open();
                    SqlDataReader reader = cmd.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            TempActivity.ActivityID     = reader.GetInt32(0);
                            TempActivity.ActivityName   = reader.GetString(1);
                            TempActivity.ActivityValue  = true;
                            TempActivity.ActivityWeight = reader.GetInt32(3);
                            Activities.Add(TempActivity);
                            //Console.WriteLine("{0}\t{1}", reader.GetInt32(0), reader.GetString(1));
                        }
                    }
                    else
                    {
                        Console.WriteLine("No Activities");
                    }
                    reader.Close();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);

                    conn.Close();
                }
            }
        }