Ejemplo n.º 1
0
 public EssentialComm(string key, string name, JToken properties) : base(key, name)
 {
     Properties     = JsonConvert.DeserializeObject <EssentialCommConfig>(properties.ToString());
     CommFeedbacks  = new Dictionary <string, StringFeedback>();
     CommDictionary = new Dictionary <uint, EssentialCommsPort>();
     Apis           = new List <BridgeApiEisc>();
     Key            = key;
 }
Ejemplo n.º 2
0
        public EssentialComm(string key, string name, JToken properties) : base(key, name)
        {
            Properties     = JsonConvert.DeserializeObject <EssentialCommConfig>(properties.ToString());
            CommFeedbacks  = new Dictionary <string, StringFeedback>();
            CommDictionary = new Dictionary <uint, EssentialCommsPort>();
            Apis           = new List <BridgeApiEisc>();
            int commNumber = 1;

            foreach (var commConfig in Properties.CommConnections)
            {
                var commPort = new EssentialCommsPort(commConfig.control, string.Format("{0}-{1}", this.Key, commConfig.joinNumber));
                CommDictionary.Add(commConfig.joinNumber, commPort);

                commNumber++;
            }

            foreach (var Ipid in Properties.EiscApiIpids)
            {
                var ApiEisc = new BridgeApiEisc(Ipid);
                Apis.Add(ApiEisc);
                foreach (var commConnection in CommDictionary)
                {
                    Debug.Console(2, "Joining Api{0} to comm {1}", Ipid, commConnection.Key);
                    var tempComm = commConnection.Value;
                    var tempJoin = (uint)commConnection.Key;
                    EssentialComApiMap ApiMap = new EssentialComApiMap(ApiEisc, (uint)tempJoin);

                    tempComm.Outputs.Add(ApiMap);
                    // Check for ApiMap Overide Values here

                    ApiEisc.Eisc.SetBoolSigAction(tempJoin, b => { if (b)
                                                                   {
                                                                       tempComm.Comm.Connect();
                                                                   }
                                                                   else
                                                                   {
                                                                       tempComm.Comm.Disconnect();
                                                                   } });
                    ApiEisc.Eisc.SetStringSigAction(tempJoin, s => tempComm.Comm.SendText(s));

                    tempComm.StatusFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[tempJoin]);
                    tempComm.ConnectedFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[tempJoin]);
                }
                ApiEisc.Eisc.Register();
            }
        }