Ejemplo n.º 1
0
        public int[] ReadPortsValueArray()
        {
            int[] result = new int[3];
            var   r      = new ParallelPortInfo(port_api.Input(ParallelPortInfo.P378), port_api.Input(ParallelPortInfo.P379), port_api.Input(ParallelPortInfo.P37A));

            result[0] = r.getPortState(ParallelPortInfo.P378);
            result[1] = r.getPortState(ParallelPortInfo.P379);
            result[2] = r.getPortState(ParallelPortInfo.P37A);
            return(result);
        }
Ejemplo n.º 2
0
 private void PublishEvent(object inf)
 {
     if (detecting)
     {
         lock (_publish_sync)
         {
             ParallelPortInfo info = inf as ParallelPortInfo;
             ChannelFactory <IPubSubEventAPI> factory = new ChannelFactory <IPubSubEventAPI>("IPubSubEventAPI");
             try
             {
                 IPubSubEventAPI client = factory.CreateChannel();
                 client.PublishEvent("PSC", new Uri(ConfigurationManager.AppSettings["service_address"]), new EventData[] {
                     new EventData {
                         Data_ID = "TIME", Data_Val = DateTime.Now
                     },
                     new EventData {
                         Data_ID = "P378", Data_Val = info.getPortState(ParallelPortInfo.P378)
                     },
                     new EventData {
                         Data_ID = "P379", Data_Val = info.getPortState(ParallelPortInfo.P379)
                     },
                     new EventData {
                         Data_ID = "P37A", Data_Val = info.getPortState(ParallelPortInfo.P37A)
                     }
                 });
                 Console.WriteLine("***Event Publihed***" + "Event Type:" + "PSC");
                 Console.WriteLine("TIME:{0}", DateTime.Now);
                 Console.WriteLine("port:{0}_value:{1}", "378", info.getPortState(ParallelPortInfo.P378));
                 Console.WriteLine("port:{0}_value:{1}", "379", info.getPortState(ParallelPortInfo.P379));
                 Console.WriteLine("port:{0}_value:{1}", "37A", info.getPortState(ParallelPortInfo.P37A));
             }
             catch (Exception e)
             {
                 Console.WriteLine("**No se pudo establecer el canal de comunicacion con el subsistema Pub-Sub de eventos***, Evento PSC***");
                 Console.WriteLine("**Detalle de la excepcion:{0}**" + e.Message);
             }
         }
     }
 }