public void min_max_test()
        {
            uint[] test_values_1 = { 15, 64, 19, 7, 0, 75, 73, 97, 41, 17 }; // 9,73
              uint[] test_values_2 = { 33, 6, 97, 24, 81, 85, 53, 49, 34, 100, 95, 23, 47, 31, 14, 57, 94, 17, 82, 7, 37, 64, 4, 83, 52 }; //20,82
              uint[] test_values_3 = { 0, 100 }; // 0,100
              uint[] test_values_4 = { }; // CONST.MAX_SIG_STR,0
              uint[] test_values_5 = { 5, 5, 5}; // 5,5
              uint[] test_values_6 = { 0, 100, 100, 100, 100 }; // 40,100
              uint[] test_values_7 = { 0, 0, 0, 0, 100 }; // 0,60

              List<uint> test_values = new List<uint>();
              MinMaxSignalStrength min_max = new MinMaxSignalStrength();

              test_values.AddRange(test_values_1);
              MinMax expected_min_max = new MinMax(9,73);
              MinMax actual_min_max = min_max.calculate_min_max_signal_strength(test_values) ;
              Specify.That(actual_min_max.ToString()).ShouldEqual(expected_min_max.ToString());

              test_values.Clear();
              test_values.AddRange(test_values_2);
              expected_min_max.min = 20;
              expected_min_max.max = 82;
              actual_min_max = min_max.calculate_min_max_signal_strength(test_values);
              Specify.That(actual_min_max.ToString()).ShouldEqual(expected_min_max.ToString());

              test_values.Clear();
              test_values.AddRange(test_values_3);
              expected_min_max.min = 0;
              expected_min_max.max = 100;
              actual_min_max = min_max.calculate_min_max_signal_strength(test_values);
              Specify.That(actual_min_max.ToString()).ShouldEqual(expected_min_max.ToString());

              test_values.Clear();
              test_values.AddRange(test_values_4);
              expected_min_max.min = Constant.MAX_SIG_STR;
              expected_min_max.max = 0;
              actual_min_max = min_max.calculate_min_max_signal_strength(test_values);
              Specify.That(actual_min_max.ToString()).ShouldEqual(expected_min_max.ToString());

              test_values.Clear();
              test_values.AddRange(test_values_5);
              expected_min_max.min = 5;
              expected_min_max.max = 5;
              actual_min_max = min_max.calculate_min_max_signal_strength(test_values);
              Specify.That(actual_min_max.ToString()).ShouldEqual(expected_min_max.ToString());

              test_values.Clear();
              test_values.AddRange(test_values_6);
              expected_min_max.min = 40;
              expected_min_max.max = 100;
              actual_min_max = min_max.calculate_min_max_signal_strength(test_values);
              Specify.That(actual_min_max.ToString()).ShouldEqual(expected_min_max.ToString());

              test_values.Clear();
              test_values.AddRange(test_values_7);
              expected_min_max.min = 0;
              expected_min_max.max = 60;
              actual_min_max = min_max.calculate_min_max_signal_strength(test_values);
              Specify.That(actual_min_max.ToString()).ShouldEqual(expected_min_max.ToString());
        }
예제 #2
0
        public void by_position_to_by_signal_strength(string by_position_data_file, List<Location>[, ,] transformed_data)
        {
            MinMax min_max_signal_strength;
              uint position_count, node_count, orientation_count;
              MinMaxSignalStrength min_max = new MinMaxSignalStrength();
              PersistedDataByPosition data_in = new PersistedDataByPosition(new FileStream(by_position_data_file, FileMode.Open, FileAccess.Read));
              List<uint>[, ,] loaded_data = data_in.load();
              position_count = (uint)loaded_data.GetLength(0);
              node_count = (uint)loaded_data.GetLength(1);
              orientation_count = (uint)loaded_data.GetLength(2);

              for (uint position_index = 0; position_index < position_count; ++position_index)
              {
            for (uint node = 0; node < node_count; ++node)
            {
              for (uint orientation = 0; orientation < orientation_count; ++orientation)
              {
            min_max_signal_strength = min_max.calculate_min_max_signal_strength(loaded_data[position_index, node, orientation]);
            for (uint signal_strength = min_max_signal_strength.min; signal_strength <= min_max_signal_strength.max; ++signal_strength)
            {
              if (transformed_data[signal_strength, node, orientation] == null)
              {
                transformed_data[signal_strength, node, orientation] = new List<Location>();
              }
              transformed_data[signal_strength, node, orientation].Add(data_in.position_index_to_location(position_index));
              transformed_data[signal_strength, node, orientation].Sort();
            }
              }
            }
              }
        }