コード例 #1
0
        private void LoadFromXml(string aConfigFileName)
        {
            var document = new XmlDocument();
            document.Load(aConfigFileName);
            var aRoot = document.DocumentElement;

            var items = aRoot.ChildNodes;
            for (var i = 0; i < items.Count; ++i) {
                var item = items[i];
                switch (item.Name) {
                    case NODE_SENSORS:
                        var sensorsNodes = item.ChildNodes;
                        sensors = new Sensor[sensorsNodes.Count];
                        for (var j = 0; j < sensorsNodes.Count; ++j) {
                            var configuration = new SensorConfiguration(sensorsNodes[j]);
                            sensors[j] = new Sensor();
                            sensors[j].SetConfiguration(configuration);
                        }
                        break;
                    case NODE_INGOT:
                        ingot = new Ingot();
                        ingot.LoadFromXmlNode(item);
                        break;
                    case NODE_RATTLE:
                        rattleMax = Convert.ToDouble(item.InnerText);
                        break;
                    case NODE_SHIFT:
                        shift = Convert.ToDouble(item.InnerText);
                        break;
                } // switch
            } // for
        }
コード例 #2
0
        private SensorValue[] GenerateSideValues(Sensor aSensor)
        {
            switch (aSensor.Configuration.SideType) {
                case SensorType.TOP:
                    return GenerateValuesByParameters(aSensor.Configuration.Horizont,
                                                      aSensor.Configuration.Remove,
                                                      ingot.Height,
                                                      1,
                                                      -1,
                                                      0,
                                                      0);
                case SensorType.BOTTOM:
                    return GenerateValuesByParameters(aSensor.Configuration.Horizont,
                                                      aSensor.Configuration.Remove,
                                                      ingot.Height,
                                                      -1,
                                                      1,
                                                      0,
                                                      0);
                case SensorType.LEFT:
                case SensorType.RIGHT:
                    return GenerateValuesByParameters(aSensor.Configuration.Horizont,
                                                      aSensor.Configuration.Remove,
                                                      ingot.Width,
                                                      0,
                                                      0,
                                                      0,
                                                      0);
            }

            return null;
        }
コード例 #3
0
 private SensorValue[] GenerateValues(Sensor aSensor)
 {
     if (aSensor.Configuration.SideType == SensorType.POSITION) {
         return GeneratePositionValues(aSensor);
     }
     else {
         return GenerateSideValues(aSensor);
     }
 }
コード例 #4
0
        private SensorValue[] GeneratePositionValues(Sensor aSensor)
        {
            var values = new SensorValue[(int)(1 + (ingot.Length + prePosition + postPosition) / step)];
            var currentPosition = .0;
            var currentTime = 0;
            for (var i = 0; i < values.Length; ++i) {
                var value = currentPosition; // обкновенное линейное движение.
                values[i] = new SensorValue(value, currentTime);
                currentTime++;
                currentPosition += step;
            }

            return values;
        }