245 lines
		
	
	
		
			6.0 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			245 lines
		
	
	
		
			6.0 KiB
		
	
	
	
		
			C#
		
	
	
	
| using System;
 | ||
| using System.Collections.Generic;
 | ||
| using System.Linq;
 | ||
| using System.Runtime.Serialization;
 | ||
| using System.ServiceModel;
 | ||
| using System.Text;
 | ||
| using DeiNiu.wms.Data.Model;
 | ||
| using DeiNiu.Utils;
 | ||
| 
 | ||
| namespace DeiNiu.wms.win
 | ||
| {
 | ||
|     // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的类名“ServiceLight”。
 | ||
| 
 | ||
|     public delegate void addNewLabelsToPool(List<ELabel> labels);
 | ||
|     public delegate void lightLable(List<ELabel> lables,int portNo);
 | ||
|     public delegate void turnoffLable(int portNo);
 | ||
|     public delegate void turnOnLights(int portNo, List<ELight> lights);
 | ||
|     public delegate void turnOffLights(int portNo, List<ELight> lights);
 | ||
|      
 | ||
|     [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]   
 | ||
|     public class ServiceLight : IServiceLight
 | ||
|     {
 | ||
|         public ELabel getLabel(string Id) 
 | ||
|         {
 | ||
|             ELabel lb = new ELabel();
 | ||
|             lb.labelId = int.Parse(Id);
 | ||
|             lb.color = 1;
 | ||
|             lb.address = 11;
 | ||
|              
 | ||
|             return lb;
 | ||
|              
 | ||
|         }
 | ||
|         WmsOutSeeds _seedsItem;
 | ||
| 
 | ||
| 
 | ||
|         WmsOutSeeds  seedsItem
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_seedsItem == null)
 | ||
|                 {
 | ||
|                     _seedsItem = new WmsOutSeeds();
 | ||
|                 }
 | ||
|                 return _seedsItem;
 | ||
| 
 | ||
|             } 
 | ||
|         }
 | ||
|         WmsImportSeeds _importSeeds;
 | ||
| 
 | ||
| 
 | ||
|         WmsImportSeeds  importSeeds
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if (_importSeeds == null)
 | ||
|                 {
 | ||
|                     _importSeeds = new WmsImportSeeds();
 | ||
|                 }
 | ||
|                 return _importSeeds;
 | ||
| 
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         public addNewLabelsToPool newLabels = null;
 | ||
|         public string lightLabels(List<ELabel> labels)
 | ||
|         {
 | ||
|             //labelPool.Concat(labels);
 | ||
|             if (null != newLabels)
 | ||
|             {
 | ||
|                 newLabels(labels);
 | ||
|                 return "succeed";
 | ||
|             }
 | ||
| 
 | ||
|             return "bad";
 | ||
|         }
 | ||
| 
 | ||
|       public  string lightLabels2(String s)
 | ||
|         {
 | ||
|             return s;
 | ||
|         }
 | ||
| 
 | ||
|         public static List<ELabel> labelPool = new List<ELabel>();
 | ||
| 
 | ||
|         public lightLable lightUp = null;
 | ||
|        
 | ||
|         public string lightLabel(string Id)
 | ||
|         {
 | ||
|             List<ELabel> lbs = new List<ELabel>();
 | ||
|             ELabel lb = new ELabel();
 | ||
|             lb.labelId = int.Parse(Id);
 | ||
|             lb.color = 1;
 | ||
|             lb.address = 0;
 | ||
|             lb.count = 11;
 | ||
|             lb.port = 13;
 | ||
|             lbs.Add(lb);
 | ||
| 
 | ||
|              lb = new ELabel();
 | ||
|              lb.labelId = 2;
 | ||
|              lb.color = 2;
 | ||
|              lb.address = 0;
 | ||
|              lb.count = 12;
 | ||
|              lb.port = 13; 
 | ||
|              lbs.Add(lb);
 | ||
| 
 | ||
|             if (lightUp != null)
 | ||
|             {
 | ||
|                 lightUp(lbs,13);
 | ||
|                 return "success";
 | ||
|             }
 | ||
| 
 | ||
| 
 | ||
|             return "服务出错";
 | ||
| 
 | ||
|         }
 | ||
|          
 | ||
| 
 | ||
|         public turnoffLable turnOff = null;
 | ||
|         public turnOffLights turnOffLts = null;
 | ||
|         public turnOnLights turnOnLts = null;  
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 开始新的一组
 | ||
|         /// </summary>
 | ||
|         /// <param name="deskId"></param>
 | ||
|         /// <param name="seedsNo"></param>
 | ||
|         /// <returns></returns>
 | ||
|         public string startSeeds(int deskId, string seedsNo)
 | ||
|         {
 | ||
|             if (turnOff != null)
 | ||
|             {
 | ||
|                 turnOff(deskId);
 | ||
|             }
 | ||
|              
 | ||
|             if (seedsItem.startSeeds(deskId, seedsNo))
 | ||
|             {
 | ||
|                 return "成功开始新播种";
 | ||
|             } 
 | ||
| 
 | ||
|             return "服务出错"; 
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
|         public string lightSeed(int deskId, string seedsNo, string barcode)
 | ||
|         {
 | ||
|             List<ELabel> els = importSeeds.getSeedLabels(deskId, seedsNo, barcode);
 | ||
| 
 | ||
|             if (els.Count > 0)
 | ||
|             {
 | ||
| 
 | ||
|                 int portNo = els[0].port;
 | ||
|                 int color = els[0].color;
 | ||
| #if DEBUG
 | ||
|               //  portNo = 13;
 | ||
| #endif
 | ||
| 
 | ||
| 
 | ||
|                 if (lightUp != null)
 | ||
|                 {
 | ||
|                     lightUp(els, color);
 | ||
| 
 | ||
|                     if (WmsConstants.WAVE_CURRENT_LIGHTS_PORT_STATUS.Count>0 &&
 | ||
|                         WmsConstants.WAVE_CURRENT_LIGHTS_PORT_STATUS[color])
 | ||
|                     {
 | ||
|                         seedsItem.lightSeeds(seedsNo, enumSeedsState.已亮灯);
 | ||
|                     }
 | ||
|                     else
 | ||
|                     {
 | ||
|                         return "亮灯失败";
 | ||
|                     }
 | ||
|                 }
 | ||
|                 return "亮灯成功";
 | ||
| 
 | ||
|             }
 | ||
|             return "服务出错:没有找到亮灯数据";
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         public string uploadSeeds(List<SeedsItem> seeds)
 | ||
|         {
 | ||
| 
 | ||
|             foreach (SeedsItem si in seeds)
 | ||
|             {
 | ||
|                 WmsOutSeeds dbObj = si.getDbObject();
 | ||
|                 
 | ||
|              /// dbObj.Add();
 | ||
| 
 | ||
|             }
 | ||
|              
 | ||
| 
 | ||
|             return "服务完成";
 | ||
|         }
 | ||
| 
 | ||
| 
 | ||
|         public string turnOnLight (int lightId, byte color, int portNo)
 | ||
|         {
 | ||
|            
 | ||
|             List<ELight> els = new List<ELight>();
 | ||
|             ELight el = new ELight();
 | ||
|             el.port =portNo;
 | ||
|             el.color =color;
 | ||
|             el.lightId=lightId;
 | ||
|             els.Add(el);
 | ||
| 
 | ||
|               el = new ELight();
 | ||
|             el.port = portNo;
 | ||
|             el.color = 2 ;
 | ||
|             el.lightId = lightId+1;
 | ||
|             els.Add(el);
 | ||
| 
 | ||
|               el = new ELight();
 | ||
|             el.port = portNo;
 | ||
|             el.color = 3;
 | ||
|             el.lightId = lightId+2;
 | ||
|             els.Add(el);
 | ||
| 
 | ||
|             if (turnOnLts != null)
 | ||
|             {
 | ||
|                 turnOnLts(portNo,els);
 | ||
|  
 | ||
|             }
 | ||
|             return "亮灯成功";
 | ||
|              
 | ||
|         }
 | ||
| 
 | ||
|         public string turnOffLight(int lightId, int portNo)
 | ||
|         {
 | ||
|             List<ELight> els = new List<ELight>();
 | ||
|             ELight el = new ELight();
 | ||
|             el.port = portNo;
 | ||
|           
 | ||
|             el.lightId = lightId;
 | ||
|             els.Add(el);
 | ||
| 
 | ||
|             if (turnOffLts != null)
 | ||
|             {
 | ||
|                 turnOffLts(portNo, els);
 | ||
| 
 | ||
|             }
 | ||
|             return "灭灯成功";
 | ||
|         }
 | ||
|         
 | ||
|     }
 | ||
| }
 |