internal static void ConstrainTipInfo_back(Layout layout) { var ditiInfos = layout.DitiInfo.DitiBoxInfos; List<DitiBoxInfo> constrainedDitiInfos = new List<DitiBoxInfo>(); if (ditiInfos == null) return; //add value for the diti labware without this information foreach (var labwareTrait in layout._labwareTraits) { if (!ditiInfos.Exists( x=>x.label == labwareTrait.Label)) { DitiType ditiType = DitiBox.Parse(labwareTrait.TypeName); constrainedDitiInfos.Add(new DitiBoxInfo(ditiType,labwareTrait.Label, 96)); } } foreach (var tipInfo in ditiInfos) { LabwareTrait labwareTrait = layout._labwareTraits.Find(x => x.Label == tipInfo.label); if (Labware.IsDiti(labwareTrait.TypeName)) { constrainedDitiInfos.Add(tipInfo); } } layout.DitiInfo.DitiBoxInfos = constrainedDitiInfos; if (layout.DitiInfo.DitiBoxInfos.Count == 0) { foreach(var ditiInfo in constrainedDitiInfos) { if (layout.DitiInfo.GetCurrentLabel(ditiInfo.type) != "") layout.DitiInfo.DitiBoxInfos.Add(new DitiBoxInfo(ditiInfo.type, ditiInfo.label,96)); } } }
public LabwareTrait GetCurrentDitiBox(DitiType ditiType) { var ditiInfo = _layout.DitiInfo; var labware = _layout.LabwareTraits.Find(x => x.Label == ditiInfo.GetCurrentLabel(ditiType)); //.CurrentDitiLabwares[ditiType]); return(labware); }
internal static void ConstrainTipInfo(Layout layout) { if (layout.DitiInfo != null && layout.DitiInfo.DitiBoxInfos != null && layout.DitiInfo.DitiBoxInfos.Count != 0) return; DitiInfo ditiInfo = new DitiInfo(); Dictionary<DitiType, string> currentDitis = new Dictionary<DitiType, string>(); foreach (Carrier carrier in layout.Carriers ) { if (carrier.TypeName == BuildInCarrierType.Diti.ToString()) { foreach (Labware labware in carrier.Labwares) { //LabwareTraits.Add(new LabwareTrait(labware)); DitiType ditiType = DitiBox.Parse(labware.TypeName); DitiBoxInfo ditiBoxInfo = new DitiBoxInfo(ditiType, labware.Label,96); if (ditiInfo.GetCurrentLabel(ditiType) == "") { ditiBoxInfo.isUsing = true; } ditiInfo.DitiBoxInfos.Add(ditiBoxInfo); } } } layout.DitiInfo = ditiInfo; }
private Tuple <Labware, System.Windows.Point> Move2NextTipPosition(DitiType ditiType) { KeyValuePair <LabwareTrait, List <int> > ditiPair = new KeyValuePair <LabwareTrait, List <int> >(); bool needRetry = false; try { ditiPair = tipManagement.GetTip(ditiType, 1).First(); } catch (NoEngouhDitiException notipException) { log.Warn("枪头用完!"); MessageBox.Show("请更换枪头!", "枪头已用完", MessageBoxButtons.OK); //here we replace all ditis tipManagement.ReplaceTips(); needRetry = true; } if (needRetry) { log.Debug("更换枪头后第一次取枪头。"); ditiPair = tipManagement.GetTip(ditiType, 1).First(); } var labware = layout.FindLabware(ditiPair.Key.Label); var position = labware.GetAbsPosition(ditiPair.Value.First()); xyz.X = position.X; xyz.Y = position.Y; xyz.Z = labware.ZValues.ZStart; Move2XYZ(xyz); return(Tuple.Create(labware, position)); }
//public void SetCurrentDitiBox(LabwareTrait labwareTrait) //{ // var ditiInfo = _layout.DitiInfo; // if (!_layout.LabwareTraits.Contains(labwareTrait)) // throw new Exception(string.Format(strings.DitiCannotFind, labwareTrait.Label)); // DitiType ditiType = DitiBox.Parse(labwareTrait.TypeName); // ditiInfo.ChangeCurrentLabel(ditiType, labwareTrait.Label); //} public int GetCurrentDitiID(DitiType ditiType) { var ditiInfo = _layout.DitiInfo; DitiBoxInfo ditiInfoItem = ditiInfo.DitiBoxInfos.Find(x => x.label == ditiInfo.GetCurrentLabel(ditiType)); return(ditiInfoItem.count); }
public static void MountThis(BasewareUIElement baseUIElement, Point position, Grid container, Layout workingLayout) { bool bValid = IsValid(baseUIElement, position, container); if (!bValid) { if (baseUIElement is LabwareUIElement) //if labware has parent, let it go back { LabwareUIElement labwareUIElement = (LabwareUIElement)baseUIElement; if (labwareUIElement.Labware.ParentCarrier != null) { return; } } container.Children.Remove(baseUIElement); if (baseUIElement is CarrierUIElement) { RemoveUIElementsOnCarrier(container, baseUIElement as CarrierUIElement); } baseUIElement = null; return; } int grid = VisualCommon.FindCorrespondingGrid(position.X); if (baseUIElement is CarrierUIElement) { CarrierUIElement carrierUIElement = (CarrierUIElement)baseUIElement; carrierUIElement.Grid = grid; } if (baseUIElement is LabwareUIElement) { LabwareUIElement labwareUIElement = (LabwareUIElement)baseUIElement; Labware labware = labwareUIElement.Labware; CarrierUIElement carrierUIElement = null; int siteID = -1; bool bFound = FindSuitableCarrier(position, labware.TypeName, container, ref carrierUIElement, ref siteID); if (bFound) { if (labware.ParentCarrier != null) { labware.ParentCarrier.Labwares.Remove(labware); } labware.SiteID = siteID; if (labware.IsDitiBox) { var ditiInfo = workingLayout.DitiInfo.DitiBoxInfos.Find(x => x.label == labware.Label); if (ditiInfo == null) { DitiType ditiType = DitiBox.Parse(labware.TypeName); workingLayout.DitiInfo.DitiBoxInfos.Add(new DitiBoxInfo(ditiType, labware.Label, 96)); } } } carrierUIElement.Carrier.AddLabware(labware); } }
public void GetTip(List <int> tipIDs, DitiType ditiType, out DitiTrackInfo trackInfos) { //throw new NotImplementedException(); Debug.WriteLine("Get tip:{0}", tipIDs.First()); trackInfos = new Core.Data.DitiTrackInfo("diti1", tipID++, true); isTipMounted = true; Delay(); }
public DitiBoxInfo(DitiType ditiType, string newLabel, int newCnt) { // TODO: Complete member initialization label = newLabel; count = newCnt; this.type = ditiType; isUsing = false; }
public void SetUsingDitiBox(DitiType ditiType, string label) { var thisTypeDitiBoxes = DitiBoxInfos.Where(x => x.type == ditiType).ToList(); for (int i = 0; i < thisTypeDitiBoxes.Count; i++) { thisTypeDitiBoxes[i].isUsing = thisTypeDitiBoxes[i].label == label; } }
public LihaCommand(string barcode, string srcLabware, int srcWellID, double volume, string dstLabware, int dstWellID, DitiType ditiType, string liquidClass) { this.barcode = barcode; this.srcLabware = srcLabware; this.srcWellID = srcWellID; this.volume = volume; this.dstLabware = dstLabware; this.dstWellID = dstWellID; this.liquidClass = liquidClass; this.ditiType = ditiType; }
internal string GetCurrentLabel(DitiType ditiType) { var info = DitiBoxInfos.Find(x => IsUsing(x, ditiType)); if (info == null) { return(""); } else { return(info.label); } }
public void GetTip(List <int> tipIDs, DitiType ditiType, out DitiTrackInfo trackInfo) { string sCommandDesc = string.Format("从ditibox:{0}中取枪头,还剩:{1}", tipManagement.GetCurrentDitiBox(ditiType), tipManagement.GetCurrentDitiID(ditiType)); log.Debug(sCommandDesc); string errDes = "只支持单针!"; if (tipIDs.Count != 1) { log.Error(errDes); throw new Exception(errDes); } var tuple = Move2NextTipPosition(DitiType.OneK); var ditiBox = tuple.Item1; //zDistanceFetchTip = ditiBox.ZValues.ZMax - ditiBox.ZValues.ZStart; //get tip while (true) { bool bok = TryGetTip(ditiBox.ZValues.ZMax); log.DebugFormat("获取枪头:{0}", bok ? success:fail); trackInfo = new DitiTrackInfo(tipManagement.GetCurrentDitiBox(ditiType).Label, tipManagement.GetCurrentDitiID(ditiType), bok); if (bok) { break; } TipNotFetched tipNotFetched = new TipNotFetched(); tipNotFetched.ShowDialog(); if (tipNotFetched.UserSelection == NextActionOfNoTip.abort) { errDes = "取不到枪头,放弃运行程序!"; log.Error(errDes); throw new CriticalException(errDes); } else if (tipNotFetched.UserSelection == NextActionOfNoTip.retryNextPosition) { tuple = Move2NextTipPosition(DitiType.OneK); } else { Move2SearchTipPosition(tuple); } } }
public StepDefinition(string[] strs, int no) { LineNumber = no; Volume = 0; //DeadVolume = 0; Description = strs[(int)StepDefCol.Description]; //RepeatTimes = lines[(int)StepDefCol.RepeatTimes]; string sVolume = strs[(int)StepDefCol.Volume]; if (sVolume == "") { return; } Volume = int.Parse(sVolume); //string sDeadVolume = lines[(int)StepDefCol.DeadVolume]; //DeadVolume = int.Parse(sDeadVolume); SourceLabware = strs[(int)StepDefCol.SourceLabware]; DestLabware = strs[(int)StepDefCol.DestLabware]; //TipType = lines[(int)StepDefCol.TipType]; LiquidClass = strs[(int)StepDefCol.LiquidClass]; DitiType = DitiBox.Parse(strs[(int)StepDefCol.DitiType]); }
public NoDitiBoxException(DitiType ditiType) { this.DitiType = ditiType; }
public Dictionary <LabwareTrait, List <int> > GetTip(DitiType ditiType, int cnt) { Dictionary <LabwareTrait, List <int> > eachLabware_Tips = new Dictionary <LabwareTrait, List <int> >(); var ditiInfo = _layout.DitiInfo; var thisTypeDitiBoxInfos = ditiInfo.DitiBoxInfos.Where(x => x.type == ditiType).ToList(); if (thisTypeDitiBoxInfos == null || thisTypeDitiBoxInfos.Count == 0) { throw new NoDitiBoxException(ditiType); } string currentLabwareLable = ditiInfo.GetCurrentLabel(ditiType); if (!thisTypeDitiBoxInfos.Exists(x => x.label == currentLabwareLable)) { throw new Exception(string.Format(strings.DitiCannotFind, currentLabwareLable)); } DitiBoxInfo ditiBoxInfo = thisTypeDitiBoxInfos.Find(x => x.label == currentLabwareLable); var labware = _layout.LabwareTraits.Find(x => x.Label == currentLabwareLable); if (ditiBoxInfo.count >= cnt) { eachLabware_Tips.Add(labware, GetToUseTipIDs(ditiBoxInfo.count, cnt)); ditiBoxInfo.count -= cnt; } else { eachLabware_Tips.Add(labware, GetToUseTipIDs(ditiBoxInfo.count, ditiBoxInfo.count)); cnt -= ditiBoxInfo.count; ditiBoxInfo.count = 0; if (thisTypeDitiBoxInfos.Count == 1) { throw new NoEngouhDitiException(labware, cnt); } else //try next one { List <DitiBoxInfo> existingDitiLabwares = thisTypeDitiBoxInfos.OrderBy(x => GetID(x)).ToList(); int currentIndex = existingDitiLabwares.IndexOf(ditiBoxInfo); currentIndex++; currentIndex = currentIndex % existingDitiLabwares.Count; ditiBoxInfo.isUsing = false; ditiBoxInfo = existingDitiLabwares[currentIndex]; ditiBoxInfo.isUsing = true; labware = _layout.LabwareTraits.Find(x => x.Label == ditiInfo.GetCurrentLabel(ditiType)); if (ditiBoxInfo.count > cnt) { eachLabware_Tips.Add(labware, GetToUseTipIDs(ditiBoxInfo.count, cnt)); ditiBoxInfo.count -= cnt; } else { eachLabware_Tips.Add(labware, GetToUseTipIDs(ditiBoxInfo.count, ditiBoxInfo.count)); cnt -= ditiBoxInfo.count; ditiBoxInfo.count = 0; labware = _layout.LabwareTraits.Find(x => x.Label == ditiInfo.GetCurrentLabel(ditiType)); throw new NoEngouhDitiException(labware, cnt); } } } return(eachLabware_Tips); }
private bool IsUsing(DitiBoxInfo x, DitiType ditiType) { return(x.type == ditiType && x.isUsing); }