public static void ValidateConnectedFireAlarm(List <Symbol> symbols) { var validation = new Validation(); string messageId = "FireAlarm has no wire found."; var validator = new Validator(); validator.Validate = delegate() { var errors = new List <Symbol>(); var lightFireAlarms = UnitWiring.Masters.LightElectricals.FindAll(p => p.Category == "FireAlarm"); var parentFireAlarms = new List <Symbol>(); var childFireAlarms = new List <Symbol>(); foreach (var alarm in lightFireAlarms) { if (alarm.IsTop) { parentFireAlarms.AddRange(symbols.FindAll(p => p.Equipment.Id == alarm.EquipmentId)); } else { childFireAlarms.AddRange(symbols.FindAll(p => p.Equipment.Id == alarm.EquipmentId)); } } //親のFireAlarmが、子供が0か、2つ以上持っていた場合はエラー foreach (var parentItem in parentFireAlarms) { Symbol child; if (parentItem.Children.Count == 0 || 1 < parentItem.Children.Count) { errors.Add(parentItem); continue; } else { child = parentItem.Children[0]; childFireAlarms.Remove(child); } FindUnConnectionFireAlarm(ref childFireAlarms, child, ref errors); } if (childFireAlarms.Count == 0) { return(null); } else { errors.AddRange(childFireAlarms); } if (errors.Count == 0) { return(null); } var error = new ErrorDialog(messageId, false); errors.ForEach(p => error.AddInfo(p)); return(error); }; validator.Run(messageId); }
public static void ValidateConnectedLightElectricalPair(string category, string equipmentName, List <Symbol> symbols) { string messageId = equipmentName + " has no wire found"; var validator = new Validator(); validator.Validate = delegate() { var errors = new List <Symbol>(); var electricals = UnitWiring.Masters.LightElectricals.FindAll(p => p.Category == category); var tops = new List <Symbol>(); var subs = new List <Symbol>(); foreach (var electrical in electricals) { if (electrical.IsTop) { tops.AddRange(symbols.FindAll(p => p.Equipment.Id == electrical.EquipmentId)); } else { subs.AddRange(symbols.FindAll(p => p.Equipment.Id == electrical.EquipmentId)); } } //親と配線されていない子供がいたらエラー foreach (var top in tops) { if (top.Children.Count == 0) { errors.Add(top); continue; } //Categoryに属していないものが配線されていてもエラーです。 foreach (var child in top.Children) { if (electricals.Exists(p => p.EquipmentId == child.Equipment.Id)) { subs.Remove(child); } else { errors.Add(child); } } } //子供しか配線されていなかったらエラー if (tops.Count == 0 && subs.Count != 0) { errors.AddRange(subs); } if (errors.Count == 0) { return(null); } var error = new ErrorDialog(messageId, false); errors.ForEach(p => error.AddInfo(p)); return(error); }; validator.Run(messageId); }
/// <summary> /// 在庫のない照明を使用してたらエラー /// </summary> /// <param name="constractionCode">工事コード</param> /// <param name="symbols">シンボル群</param> public static void ValidateLightSerialOutOfStock(List <Symbol> symbols) { string messageId = @"Light serial of out of stock is used. Please check light serial."; var validator = new Validator(); validator.Validate = delegate() { List <Symbol> lightSymbols = symbols.FindAll(p => p.IsLight); if (lightSymbols.Count == 0) { return(null); } //在庫無しの品番情報 List <LightSerial> emptyStockLightSerials; //邸ごとの使用できる品番情報 List <UsableLightSerial> usableLightSerials; //加工前依頼か否か bool isBeforeProcessRequest; using (var service = new SocketPlanServiceNoTimeout()) { emptyStockLightSerials = new List <LightSerial>(service.GetEmptyStockLightSerials()); usableLightSerials = new List <UsableLightSerial>(service.GetUsableLightSerials(Static.ConstructionCode)); isBeforeProcessRequest = service.IsBeforeProcessRequest(Static.ConstructionCode); } //非許可の照明品番が設定されていた照明シンボルを設定するリスト List <Symbol> denialLightSymbols = new List <Symbol>(); //非許可の品番名を設定するリスト List <String> deniialLightHinbanName = new List <string>(); List <Light> lights = new List <Light>(); lightSymbols.ForEach(p => lights.Add(new Light(p))); foreach (Light light in lights) { List <string> hinbans = light.GetSerialsForDistinct(); foreach (string hinban in hinbans) { if (!emptyStockLightSerials.Exists(p => p.Name == hinban)) { continue; } if (IsUsableHinban(hinban, isBeforeProcessRequest, usableLightSerials)) { continue; } if (denialLightSymbols.IndexOf(light.Symbol) == -1) { denialLightSymbols.Add(light.Symbol); } if (deniialLightHinbanName.IndexOf(hinban) == -1) { deniialLightHinbanName.Add(hinban); } } } if (denialLightSymbols.Count == 0 && deniialLightHinbanName.Count == 0) { return(null); } var error = new ErrorDialog(messageId, false); denialLightSymbols.ForEach(a => error.AddInfo(a)); deniialLightHinbanName.ForEach(a => error.AddInfo(a + " out of stock.")); return(error); }; validator.Run(messageId); }
/// <summary> /// 登録されている数量と図面上の数量が一致しなかったらエラー /// </summary> /// <param name="lights">照明情報</param> /// <param name="emptyLightSerials">在庫が空である照明品番情報</param> /// <param name="usableLightSerials">使用可能な照明品番情報</param> public static void ValidateLightSerialCountNotMatch(List <Symbol> symbols) { string messageId = @"The count of light serial and stocked light serial does not match. Please inquire of SMD."; var validator = new Validator(); validator.Validate = delegate() { List <Symbol> lightSymbols = symbols.FindAll(p => p.IsLight); if (lightSymbols.Count == 0) { return(null); } //在庫無しの品番情報 List <LightSerial> emptyStockLightSerials; //邸ごとの使用できる品番情報 List <UsableLightSerial> usableLightSerials; using (var service = new SocketPlanServiceNoTimeout()) { emptyStockLightSerials = new List <LightSerial>(service.GetEmptyStockLightSerials()); usableLightSerials = new List <UsableLightSerial>(service.GetUsableLightSerials(Static.ConstructionCode)); } if (emptyStockLightSerials.Count == 0) { return(null); } List <Light> lights = new List <Light>(); lightSymbols.ForEach(p => lights.Add(new Light(p))); //在庫数が一致しなかった照明シンボルを設定するリスト List <Symbol> notMatchLightSymbols = new List <Symbol>(); //在庫数が一致しなかった品番名を設定するリスト List <String> notMatchLightHinbanNames = new List <string>(); foreach (LightSerial emptyLightSerial in emptyStockLightSerials) { UsableLightSerial usableLightSerial = usableLightSerials.Find(p => p.LightSerial == emptyLightSerial.Name); if (usableLightSerial == null)//在庫数情報が取れなかった場合は在庫比較の判断ができない為。 { continue; } List <Light> stockEmptyLights = new List <Light>(); int totalStockEmptyLightCount = 0; //図面内に存在する在庫無し品番をカウント foreach (Light light in lights) { List <string> hinbans = light.GetSerialsForCount(); int count = hinbans.FindAll(p => p == emptyLightSerial.Name).Count; if (count == 0) { continue; } stockEmptyLights.Add(light); totalStockEmptyLightCount += count; } if (totalStockEmptyLightCount == usableLightSerial.UsableCount) { continue; } //図面上と登録されている拾い数量が一致してなければエラーを表示 foreach (var light in stockEmptyLights) { if (notMatchLightSymbols.IndexOf(light.Symbol) == -1) { notMatchLightSymbols.Add(light.Symbol); } } string infoMessage = emptyLightSerial.Name + " count " + totalStockEmptyLightCount + ", stock count " + usableLightSerial.UsableCount;; notMatchLightHinbanNames.Add(infoMessage); } if (notMatchLightSymbols.Count == 0 && notMatchLightHinbanNames.Count == 0) { return(null); } var error = new ErrorDialog(messageId, false); notMatchLightSymbols.ForEach(a => error.AddInfo(a)); notMatchLightHinbanNames.ForEach(a => error.AddInfo(a)); return(error); }; validator.Run(messageId); }
/// <summary>シャワールームに適さない品番が使われていた場合エラー</summary> public static void ValidateShowerRoomMissingSerial(List <TextObject> texts, List <Symbol> symbols) { string messageId = @"Wrong hontai serial used for shower room."; var validator = new Validator(); validator.Validate = delegate() { if (Static.Drawing.Prefix != "HJA") { return(null); } //最上階を取得 var maxFloor = 0; foreach (var text in texts) { if (maxFloor < text.Floor) { maxFloor = text.Floor; } } //階毎にチェック var errors = new List <string>(); for (var i = 1; i <= maxFloor; i++) { var showerRooms = texts.FindAll(p => p.Text == Const.Room.シャワールーム && p.Floor == i); var iSeriesRooms = texts.FindAll(p => p.Text == Const.Room.iシリーズ && p.Floor == i); var serials = symbols.FindAll(p => (p.Equipment.Name == Const.EquipmentName.シャワー01 || p.Equipment.Name == Const.EquipmentName.IUB_01) && p.Floor == i); //判定外のシリアルが使われている場合もあるので、シリアルを基準に判定する foreach (var serial in serials) { if (serial.Equipment.Name == Const.EquipmentName.シャワー01) { if (showerRooms.Count > 0) { showerRooms.RemoveAt(0); } else { errors.Add(i.ToString() + "F"); } } else { if (iSeriesRooms.Count > 0) { iSeriesRooms.RemoveAt(0); } else { errors.Add(i.ToString() + "F"); } } } } if (errors.Count == 0) { return(null); } var error = new ErrorDialog(messageId); errors.ForEach(p => error.AddInfo(p)); return(error); }; validator.Run(messageId); }
/// <summary>279:資格テーブルに未入力箇所があるか、重複入力があればエラー</summary> public static void ValidateShikakuTableInput(List <Control> controls) { var messageId = @"There's portion in shikaku table that has no shade correctly, please check and make attachement."; var dialog = new ErrorDialog(messageId, 0); //警告エラー用 //HJAなら承認可エラー、それ以外は警告 bool isBeforeProcessRequest = true; if (Static.Drawing.Prefix == "HJA") { isBeforeProcessRequest = false; } var validator = new Validator(); validator.Validate = delegate() { //グループに振り分け List <List <Control> > groups = new List <List <Control> >(); groups.Add(controls.FindAll(p => p.Name == "control69" || p.Name == "control70")); groups.Add(controls.FindAll(p => p.Name == "control14" || p.Name == "control15")); groups.Add(controls.FindAll(p => p.Name == "control16" || p.Name == "control17")); groups.Add(controls.FindAll(p => p.Name == "control18" || p.Name == "control19")); groups.Add(controls.FindAll(p => p.Name == "control20" || p.Name == "control21")); groups.Add(controls.FindAll(p => p.Name == "control23" || p.Name == "control24")); groups.Add(controls.FindAll(p => p.Name == "control26" || p.Name == "control27")); groups.Add(controls.FindAll(p => p.Name == "control29" || p.Name == "control30")); groups.Add(controls.FindAll(p => p.Name == "control56" || p.Name == "control57")); groups.Add(controls.FindAll(p => p.Name == "control46" || p.Name == "control43")); groups.Add(controls.FindAll(p => p.Name == "control54" || p.Name == "control55")); groups.Add(controls.FindAll(p => p.Name == "control47" || p.Name == "control50")); groups.Add(controls.FindAll(p => p.Name == "control89" || p.Name == "control90")); groups.Add(controls.FindAll(p => p.Name == "control91" || p.Name == "control92")); groups.Add(controls.FindAll(p => p.Name == "control64" || p.Name == "control68")); groups.Add(controls.FindAll(p => p.Name == "control95" || p.Name == "control96")); groups.Add(controls.FindAll(p => p.Name == "control97" || p.Name == "control98")); groups.Add(controls.FindAll(p => p.Name == "control81" || p.Name == "control88")); groups.Add(controls.FindAll(p => p.Name == "control60" || p.Name == "control61" || p.Name == "control63")); groups.Add(controls.FindAll(p => p.Name == "control111" || p.Name == "control112")); //グループ内のチェックが1個でない場合はエラー foreach (var group in groups) { if (group.Count <= 1) { continue; } var isCheck = group.FindAll(p => ((CheckBox)p).Checked); if (isCheck.Count == 1) { continue; } else if (isCheck.Count == 0 || isCheck.Count > 1) { if (isBeforeProcessRequest) { return(new ErrorDialog(messageId, 0)); } else { return(new ErrorDialog(messageId)); } } } //TV受信工事はチェックなしのみNG var checkTV = controls.FindAll(p => p.Name == "control7" || p.Name == "control8" || p.Name == "control9" || p.Name == "control11" || p.Name == "control12" || p.Name == "control13"); if (checkTV.Find(p => ((CheckBox)p).Checked == true) == null) { if (isBeforeProcessRequest) { return(new ErrorDialog(messageId, 0)); } else { return(new ErrorDialog(messageId)); } } return(null); }; validator.Run(messageId); }
/// <summary>外部かつ同じ位置のシンボルで高さが一定未満の場合エラー</summary> public static void ValidateDuplicateSymbolHeight(List <Symbol> symbols) { string messageId = @"ATTENTION: There is item outside with same height and location, need to secure 227.5 distance"; var validator = new Validator(); validator.Validate = delegate() { if (Static.Drawing.Prefix == "HZA") { return(null); } const decimal limitDistance = 227.5M; List <Symbol> errors = new List <Symbol>(); var targets = symbols.FindAll(p => p.Equipment.Name == Const.EquipmentName.int_03 || p.Equipment.Name == Const.EquipmentName.照明_10 || p.Equipment.Name == Const.EquipmentName.専用E無_04 || p.Equipment.Name == Const.EquipmentName.専用E無_05 || p.Equipment.Name == Const.EquipmentName.専用E無_06 || p.Equipment.Name == Const.EquipmentName.専用E無_07 || p.Equipment.Name == Const.EquipmentName.専用E無_08 || p.Equipment.Name == Const.EquipmentName.専用E付_13 || p.Equipment.Name == Const.EquipmentName.一般_15 || p.Equipment.Name == Const.EquipmentName.専用E付_16 || p.Equipment.Name == Const.EquipmentName.専用E付_20 || p.Equipment.Name == Const.EquipmentName.専用E付_22 || p.Equipment.Name == Const.EquipmentName.専用E付_24 || p.Equipment.Name == Const.EquipmentName.防水専_01 || p.Equipment.Name == Const.EquipmentName.防水専_05 || p.Equipment.Name == Const.EquipmentName.防水専_06 || p.Equipment.Name == Const.EquipmentName.防水専_07 || p.Equipment.Name == Const.EquipmentName.防水E付_01 || p.Equipment.Name == Const.EquipmentName.防水E付_02 || p.Equipment.Name == Const.EquipmentName.防水E付_03 || p.Equipment.Name == Const.EquipmentName.防水E付_04 || p.Equipment.Name == Const.EquipmentName.防水E付_07 || p.Equipment.Name == Const.EquipmentName.E付_08 || p.Equipment.Name == Const.EquipmentName.り); for (int i = 0; i < targets.Count; i++) { if (!(targets[i].RoomName == Const.Room.ポーチ || targets[i].RoomName == Const.Room.外部 || targets[i].RoomName.StartsWith(Const.Room.車庫))) { continue; } if (targets[i].Floor == 0) { continue; } for (int j = 0; j < targets.Count; j++) { if (j <= i) { continue; } if (targets[j].Floor == 0) { continue; } if (!(targets[j].RoomName == Const.Room.ポーチ || targets[j].RoomName == Const.Room.外部 || targets[i].RoomName.StartsWith(Const.Room.車庫))) { continue; } if (targets[i].IsConnected(targets[j]) && targets[i].Floor == targets[j].Floor) { //高さ属性が付加されている場合はその値で比較する var heightI = GetAdditionalHeight(targets[i]); var heightJ = GetAdditionalHeight(targets[j]); var distance = Math.Abs(heightI - heightJ); if (distance < limitDistance) { errors.Add(targets[j]); } } } } if (errors.Count == 0) { return(null); } var error = new ErrorDialog(messageId); errors.ForEach(p => error.AddInfo(p)); return(error); }; validator.Run(messageId); }
//JBOXシンボルがJB-D間に接続されていない場合エラー public static void WarnJboxConnection(CadObjectContainer container) { var messageId = @"There is a JC, JCL, JCT which has no wire to JB-D/JB-DA."; var validator = new Validator(); validator.Validate = delegate() { var errors = new List <Symbol>(); foreach (var symbol in container.Symbols) { if (symbol.IsJBox == false && symbol.Equipment.Name != Const.EquipmentName.JC && symbol.Equipment.Name != Const.EquipmentName.JCL && symbol.Equipment.Name != Const.EquipmentName.JCT) { continue; } if (!container.JboxWires.Exists(p => p.IsConnected(symbol))) { errors.Add(symbol); } } var jboxSymbols = container.GetWiredJboxSymbols(); foreach (var parent in jboxSymbols) { if (parent.Children.Count == 0) { errors.Add(parent); } foreach (var child in parent.Children) { if (child.Parent == null) { errors.Add(child); } else if (child.Parent.IsJBox == false || (child.Equipment.Name != Const.EquipmentName.JC && child.Equipment.Name != Const.EquipmentName.JCL && child.Equipment.Name != Const.EquipmentName.JCT)) { errors.Add(parent); errors.Add(child); } } } if (errors.Count == 0) { return(null); } var error = new ErrorDialog(messageId, 0); errors.ForEach(p => error.AddInfo(p)); return(error); }; validator.Run(messageId); }
//特定のシンボルがパターンの中心から一定距離空いていなければエラー //加工依頼後だと、チェッカーが確認済みのためエラーを表示させる必要はない。7/28中山 public static void ValidateFireAlarmDistance(CadObjectContainer container) { var messageId = @"There is the symbol which is too near to a fire alarm."; var validator = new Validator(); validator.Validate = delegate() { if (Static.Drawing.Prefix == "HJA" || Static.Drawing.Prefix == "HZA") { return(null); } var errors = new List <Symbol>(); var errorTexts = new List <TextObject>(); foreach (var pattern in container.IgnoreSymbols) { //パターンの中心にある火災報知機シンボルを探す var alarm = container.Symbols.Find(p => p.Floor == pattern.Floor && p.Room == pattern.Room && p.Equipment.Block.FileName.Contains("FireAlarm") && //火災報知機を一発で拾う方法がないのでやむなく・・・ p.Contains(pattern.Position)); //Supply Air, Nano Electric, circulator var validateTexts = container.Texts.FindAll(p => p.Floor == pattern.Floor && p.Room == pattern.Room && !p.Text.Contains(" ") && (p.Text.StartsWith("NE") || p.Text == Const.Text.サーキュレーター || p.Text == Const.Text.サーキュレーター)); //Aircon var airconTexts = container.Texts.FindAll(p => p.Floor == pattern.Floor && p.Room == pattern.Room && !p.Text.Contains(" ") && (p.Text.StartsWith("AC"))); //AC①~AC⑳までをエアコンとして判定する foreach (var aircon in airconTexts) { if (aircon.Text.Length < 3) { continue; } var wk = Convert.ToInt32(aircon.Text.Substring(2, 1)[0]); if (wk < 9312 || wk > 9331) { continue; } validateTexts.Add(aircon); } //SAテキスト var saTexts = container.Texts.FindAll(p => p.Floor == pattern.Floor && p.Room == pattern.Room && !p.Text.Contains(" ") && p.Text.Contains("SA")); foreach (var sa in saTexts) { Regex regex = new System.Text.RegularExpressions.Regex(@"SA\d"); if (regex.IsMatch(sa.Text)) { validateTexts.Add(sa); } } foreach (var text in validateTexts) { var rotate = AutoCad.Db.Text.GetRotation(text.ObjectId) / Math.PI * 180; int rad = 0; var width = AutoCad.Db.Text.GetWidth(text.ObjectId); var height = AutoCad.Db.Text.GetHeight(text.ObjectId); var position = AutoCad.Db.Text.GetPosition(text.ObjectId); //回転角とサイズから四隅を取得する var points = new List <PointD>(); if (Int32.TryParse(rotate.ToString(), out rad)) { switch (rad) { case 0: points.Add(new PointD(position.X, position.Y + height)); points.Add(new PointD(position.X + width, position.Y + height)); points.Add(new PointD(position.X + width, position.Y)); break; case 90: points.Add(new PointD(position.X, position.Y + height)); points.Add(new PointD(position.X - width, position.Y)); points.Add(new PointD(position.X - width, position.Y + height)); break; case 180: points.Add(new PointD(position.X - width, position.Y)); points.Add(new PointD(position.X - width, position.Y - height)); points.Add(new PointD(position.X, position.Y - height)); break; case 270: points.Add(new PointD(position.X, position.Y - height)); points.Add(new PointD(position.X + width, position.Y - height)); points.Add(new PointD(position.X + width, position.Y)); break; default: break; } } points.Add(position); foreach (var point in points) { var checkDistance = Edsa.AutoCadProxy.Calc.GetDistance(point, pattern.Position); if (1500 > checkDistance) { errorTexts.Add(text); break; } } } //壁付きのときは照明をチェックしない if (alarm != null) { if (alarm.OtherAttributes.Exists(p => p.Value == Const.Text.壁付)) { continue; } } var validateSymbols = container.Symbols.FindAll(p => p.Floor == pattern.Floor && p.Room == pattern.Room && (p.Equipment.Name == Const.EquipmentName.照明 || p.Equipment.Name == Const.EquipmentName.照明_01 || p.Equipment.Name == Const.EquipmentName.照明_02 || p.Equipment.Name == Const.EquipmentName.照明_05 || p.Equipment.Name == Const.EquipmentName.照明_30)); foreach (var symbol in validateSymbols) { double distance; switch (symbol.Equipment.Name) { case Const.EquipmentName.照明: distance = 300; break; case Const.EquipmentName.照明_01: distance = 700; break; case Const.EquipmentName.照明_02: distance = 300; break; case Const.EquipmentName.照明_05: distance = 700; break; case Const.EquipmentName.照明_30: distance = 700; break; default: continue; } //シンボルは基点だけをチェックする var points = new List <PointD>(); points.Add(symbol.Position); //points.Add(new PointD(symbol.PositionBottomLeft.X, symbol.PositionBottomLeft.Y)); //points.Add(new PointD(symbol.PositionTopRight.X, symbol.PositionBottomLeft.Y)); //points.Add(new PointD(symbol.PositionBottomLeft.X, symbol.PositionTopRight.Y)); //points.Add(new PointD(symbol.PositionTopRight.X, symbol.PositionTopRight.Y)); foreach (var point in points) { var checkDistance = Edsa.AutoCadProxy.Calc.GetDistance(point, pattern.Position); if (distance > checkDistance) { errors.Add(symbol); break; } } } } if (errors.Count == 0 && errorTexts.Count == 0) { return(null); } var error = new ErrorDialog(messageId); errors.ForEach(p => error.AddInfo(p)); errorTexts.ForEach(p => error.AddInfo(p)); return(error); }; validator.Run(messageId); }