/// <summary> /// 向该 Block 添加一个 InputPin /// </summary> /// <param name="to_add"></param> public virtual void Add(Cld_FCInput to_add) { this.Cld_FCInput_List.Add(to_add); to_add.Cld_FCBlock_ID = this.ID; to_add.Prj_Controller_ID = this.Prj_Controller_ID; to_add.Prj_Document_ID = this.Prj_Document_ID; to_add.Prj_Sheet_ID = this.Prj_Sheet_ID; }
/// <summary> /// 创建一个 InputPin /// </summary> /// <returns></returns> public virtual Cld_FCInput New_FCInput() { Cld_FCInput result = new Cld_FCInput(); result.Cld_FCBlock_ID = this.ID; result.Prj_Controller_ID = this.Prj_Controller_ID; result.Prj_Document_ID = this.Prj_Document_ID; result.Prj_Sheet_ID = this.Prj_Sheet_ID; return(result); }
/// <summary> /// 根据ID获得Cld_FCBlock /// </summary> /// <param name="condition">ID type:int</param> /// <returns></returns> public Cld_FCInput GetCld_FCInput_By_ID(int condition) { using (ITransaction transaction = session.BeginTransaction()){ try{ Cld_FCInput result = this.session.Get <Cld_FCInput>(condition); transaction.Commit(); return(result); }catch (Exception e) { transaction.Rollback(); throw e; } } }
public LogicPin(Cld_FCInput pin, LogicSymbol symbol) { this.Type = LogicObjectType.Pin; this.pinType = LogicPinType.Input; this.pinName = pin.PinName; this.pinValue = pin.InitialValue; // 必须先给pinValue赋值 this.PointName = pin.PointName; this.Visible = pin.Visible; this.point1 = this.point2 = new PointF(pin.Cld_FCBlock.X + pin.X, pin.Cld_FCBlock.Y + pin.Y); this.GenerateSubmitGraphicsByPin(symbol); }
/// <summary> /// 创建一个 InputPin /// </summary> /// <returns></returns> public virtual Cld_FCInput New_FCInput() { Cld_FCInput result = new Cld_FCInput(); result.Cld_FCBlock_ID = this.ID; result.Cld_FCBlock = this; result.Prj_Controller_ID = this.Prj_Controller_ID; result.Prj_Controller = this.Prj_Controller; result.Prj_Document_ID = this.Prj_Document_ID; result.Prj_Document = this.Prj_Document; result.Prj_Sheet_ID = this.Prj_Sheet_ID; result.Prj_Sheet = this.Prj_Sheet; this.Cld_FCInput_List.Add(result); return(result); }
public virtual bool Compare(Cld_FCInput arg) { if (this.ID != arg.ID) { throw new Exception("id should be equal"); } if (this.PinName != arg.PinName || this.PointName != arg.PointName || this.InitialValue != arg.InitialValue || this.Point != arg.Point || this.Visible != arg.Visible || this.Description != arg.Description || this.Cld_FCBlock_ID != arg.Cld_FCBlock_ID || this.Prj_Controller_ID != arg.Prj_Controller_ID || this.Prj_Document_ID != arg.Prj_Document_ID || this.Prj_Sheet_ID != arg.Prj_Sheet_ID ) { return(false); } else { return(true); } }
/// <summary> /// 生成一条连接两个Pin的线 /// </summary> /// <param name="startPin">起始Pin</param> /// <param name="endPin">结束Pin</param> /// <returns>表示一条线的字符串</returns> public string GenerateSignalData(Cld_FCOutput startPin, Cld_FCInput endPin) { Cld_FCBlock startBlock = startPin.Cld_FCBlock; Cld_FCBlock endBlock = endPin.Cld_FCBlock; IList startInputList = startBlock.Cld_FCInput_List; IList startOutputList = startBlock.Cld_FCOutput_List; IList endInputList = endBlock.Cld_FCInput_List; IList endOutputList = endBlock.Cld_FCOutput_List; PointF startPoint = new PointF(startBlock.X + startPin.X, startBlock.Y + startPin.Y); PointF endPoint = new PointF(endBlock.X + endPin.X, endBlock.Y + endPin.Y); StringBuilder signalDatails = new StringBuilder(); const float spacing = 8f; // 相邻两个输入引脚的延伸长度差值 const float pinLength = 16f; // 引脚的最小延伸长度 int startPinIndex; int endPinIndex; // 添加开始点 signalDatails.Append(startPoint.X + "_" + startPoint.Y + "{" + startBlock.AlgName + "." + startPin.PinName + "},"); if (startPoint.Y != endPoint.Y) { // 起止点的垂直坐标不在同一直线上,需要增加折点 if (startPoint.Y < endPoint.Y) { startPinIndex = startPin.PinIndex; endPinIndex = endPin.PinIndex; } else { startPinIndex = startOutputList.Count - startPin.PinIndex - 1; endPinIndex = endInputList.Count - endPin.PinIndex - 1; } PointF point = new PointF(); point.Y = startPoint.Y; float firstX = startPoint.X + pinLength + spacing * startPinIndex; // 第一个折点的 X 坐标 float lastX = endPoint.X - pinLength - spacing * endPinIndex; // 最后一个折点的 X 坐标 if (firstX < lastX) { point.X = lastX; } else { if (startPoint.X < endPoint.X) { point.X = (endPoint.X + startPoint.X) / 2; } else { point.X = firstX; signalDatails.Append(point.X + "_" + point.Y + ","); point.Y = Math.Abs(endPoint.Y + startPoint.Y) / 2; signalDatails.Append(point.X + "_" + point.Y + ","); point.X = lastX; } } signalDatails.Append(point.X + "_" + point.Y + "," + point.X + "_" + endPoint.Y + ","); } else if (startPoint.X > endPoint.X) { // 起止点垂直坐标相同,但起点比终点水平坐标值大 float upHeight = (float)(endPoint.Y - endBlock.Y); float downHeight = (float)(endBlock.Y + endBlock.Symbol.height - endPoint.Y); float FirstX; float lastX; float signalY; if (upHeight < downHeight) { // 从Block上面折回 FirstX = startPoint.X + pinLength + spacing * startPin.PinIndex; signalY = (float)(endBlock.Y - pinLength - spacing * endPin.PinIndex); lastX = endPoint.X - pinLength - spacing * endPin.PinIndex; } else { FirstX = startPoint.X + pinLength + spacing * (startOutputList.Count - startPin.PinIndex - 1); signalY = (float)(endBlock.Y + endBlock.Symbol.height + pinLength + spacing * (endInputList.Count - endPin.PinIndex - 1)); lastX = endPoint.X - pinLength - spacing * (endInputList.Count - endPin.PinIndex - 1); } signalDatails.Append(FirstX + "_" + startPoint.Y + "," + FirstX + "_" + signalY + "," + lastX + "_" + signalY + "," + lastX + "_" + endPoint.Y + ","); } // 添加结束点 signalDatails.Append(endPoint.X + "_" + endPoint.Y + "{" + endBlock.AlgName + "." + endPin.PinName + "};"); return signalDatails.ToString(); }
public virtual bool Compare(Cld_FCInput arg) { if (this.ID != arg.ID) { throw new Exception("id should be equal"); } if (this.PinName != arg.PinName || this.PointName != arg.PointName || this.InitialValue != arg.InitialValue || this.Point != arg.Point || this.Visible != arg.Visible || this.Description != arg.Description || this.Cld_FCBlock_ID != arg.Cld_FCBlock_ID || this.Prj_Controller_ID != arg.Prj_Controller_ID || this.Prj_Document_ID != arg.Prj_Document_ID || this.Prj_Sheet_ID != arg.Prj_Sheet_ID ) { return false; } else { return true; } }
/// <summary> /// 创建一个 InputPin /// </summary> /// <returns></returns> public virtual Cld_FCInput New_FCInput() { Cld_FCInput result = new Cld_FCInput(); result.Cld_FCBlock_ID = this.ID; result.Prj_Controller_ID = this.Prj_Controller_ID; result.Prj_Document_ID = this.Prj_Document_ID; result.Prj_Sheet_ID = this.Prj_Sheet_ID; return result; }
/// <summary> /// 创建一个 InputPin /// </summary> /// <returns></returns> public virtual Cld_FCInput New_FCInput() { Cld_FCInput result = new Cld_FCInput(); result.Cld_FCBlock_ID = this.ID; result.Cld_FCBlock = this; result.Prj_Controller_ID = this.Prj_Controller_ID; result.Prj_Controller = this.Prj_Controller; result.Prj_Document_ID = this.Prj_Document_ID; result.Prj_Document = this.Prj_Document; result.Prj_Sheet_ID = this.Prj_Sheet_ID; result.Prj_Sheet = this.Prj_Sheet; this.Cld_FCInput_List.Add(result); return result; }