public void ProcessPropertysFromGPIOConnector(IPropertySet propertys) { // this.m_GPIOEnvironmentConnectors.ProcessPropertysFromGPIOConnector(propertys); var con = getGPIOOConnectorByOutputPropertySet(propertys); if (con == null) { return; } var m_Banks = con.ActiveGPIOInOutBanks; con.UpdateState(0); for (int i = 0; i < m_Banks.InOutBanks.Count; i++) { GPIOOBank bank = m_Banks.InOutBanks[i]; foreach (GPIOObjects OutPuts in bank.GPIOBanks) { foreach (GPIOObject GPIOObj in OutPuts.GPIOs) { con.UpdateOutputPropertySets(GPIOObj); } } } con.UpdateState(1); }
public async void startConnector() { if (m_GPIOConnectorEnable && !m_GPIOConnecorInitialized) { m_GPIOInputServiceConnectorConfig["HostName"] = HostName; m_GPIOInputServiceConnectorConfig["Port"] = Port; m_GPIOInputServiceConnectorConfig["UpdateState"] = PropertyValue.CreateInt32(0); // m_GPIOInputServiceConnectorConfig.Add("UpdateState", PropertyValue.CreateInt32(0)); for (int i = 0; i < m_ActiveGPIOInOutBanks.InOutBanks.Count; i++) { GPIOOBank bank = m_ActiveGPIOInOutBanks.InOutBanks[i]; foreach (GPIOObjects OutPuts in bank.GPIOBanks) { foreach (GPIOObject GPIOObj in OutPuts.GPIOs) { UpdateInputPropertySets(GPIOObj); } } } UpdateState(1); await m_GPIOConnector.startProcessingPackagesAsync(m_GPIOInputServiceConnectorConfig, m_GPIOOutPutServiceConnectorConfig); } }
public void readImages() { for (int i = 0; i < m_InOutBanks.Count; i++) { GPIOOBank obj = m_InOutBanks[i]; obj.readImages(); } }
public async Task <bool> InitializeAsync() { m_GPIOInOutBanks = await GPIOOInOutBanks.GPIOOInOutBanksAsync(m_GPIOInputServiceConnectorConfig); m_Inputs = m_GPIOInOutBanks.InOutBanks[0]; m_OutPuts = m_GPIOInOutBanks.InOutBanks[1]; return(m_GPIOInOutBanks.InOutBanks.Count > 0); }
public void createPropertySet(IPropertySet property) { property.Clear(); for (int i = 0; i < m_InOutBanks.Count; i++) { GPIOOBank obj = m_InOutBanks[i]; obj.createPropertySet(property); } }
public void InitializeActiveBanks() { m_GPIOInputServiceConnectorConfig.Clear(); m_ActiveGPIOInOutBanks = m_GPIOInOutBanks.GPIOOActiveInOutBanks(m_GPIOInputServiceConnectorConfig); // m_ActiveGPIOInOutBanks = await GPIOOInOutBanks.GPIOOInOutBanksAsync(m_GPIOInputServiceConnectorConfig); m_ActiveInputs = m_ActiveGPIOInOutBanks.InOutBanks[0]; m_ActiveOutPuts = m_ActiveGPIOInOutBanks.InOutBanks[1]; }
GPIOOInOutBanks AllocateActiveGPIOs(IPropertySet property) { GPIOOInOutBanks GPIOInOutBanks = new GPIOOInOutBanks(""); GPIOOBank m_OutPuts = new GPIOOBank("Outputs"); GPIOOBank m_Inputs = new GPIOOBank("Inputs"); // ObservableCollection<GPIOObjects>m_GPIOOutputs = new ObservableCollection<GPIOObjects>(); GPIOObjects m_GPIOOutputs = new GPIOObjects("GPIOOutPuts"); GPIOObjects m_GPIOInputs = new GPIOObjects("GPIOInPuts"); for (int i = 0; i < m_InOutBanks.Count; i++) { GPIOOBank bank = m_InOutBanks[i]; foreach (GPIOObjects OutPuts in bank.GPIOBanks) { foreach (GPIOObject GPIOObj in OutPuts.GPIOs) { if (GPIOObj.IsEnabled) { switch (GPIOObj.GPIOtyp) { case GPIOObject.GPIOTyp.output: m_GPIOOutputs.GPIOs.Add(GPIOObj); break; case GPIOObject.GPIOTyp.input: m_GPIOInputs.GPIOs.Add(GPIOObj); break; } } } } } if (m_GPIOOutputs.GPIOs.Count > 0) { m_Inputs.GPIOBanks.Add(m_GPIOInputs); } if (m_GPIOOutputs.GPIOs.Count > 0) { m_OutPuts.GPIOBanks.Add(m_GPIOOutputs); } GPIOInOutBanks.InOutBanks.Add(m_Inputs); GPIOInOutBanks.InOutBanks.Add(m_OutPuts); GPIOInOutBanks.createPropertySet(property); return(GPIOInOutBanks); }
public GPIOOBank getGPIOBankByName(string name) { for (int i = 0; i < m_InOutBanks.Count; i++) { GPIOOBank obj = m_InOutBanks[i]; if (obj.BankName == name) { return(obj); } } return(null); }
async private void GPIOConnector_ChangeGPIOs(object sender, IPropertySet propertys) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { // your code should be here m_GPIOEnvironmentConnectors.ProcessPropertysFromGPIOConnector(propertys); var con = m_GPIOEnvironmentConnectors.getGPIOOConnectorByOutputPropertySet(propertys); if (con == null) { return; } GPIOOBank inputbank = con.ActiveInputs; for (int i = 0; i < m_ConfigProcessItems.ProcessItems.Count; i++) { ConfigProcessItem item = m_ConfigProcessItems.ProcessItems[i]; for (int j = 0; j < item.GPIOInputProcessItems.Count; j++) { GPIOOProcessItem pItem = item.GPIOInputProcessItems[j]; GPIOObject obj = inputbank.getGPIOByName(pItem.GPIOName); if (obj != null) { if (obj.PinValue != obj.InitValue) { ProcessFingerEvent ev = new ProcessFingerEvent(); GPIOObjectProcess OutObjectProcess = new GPIOObjectProcess(); GPIOObjectProcess InObjectProcess = new GPIOObjectProcess(); //item.GPIOOutputProcessItems OutObjectProcess.GPIOEnvironmentConnector = m_GPIOEnvironmentConnectors.getGPIOOConnectorByHostName(pItem.ConnectorName); OutObjectProcess.GPIOObject = obj; InObjectProcess.GPIOEnvironmentConnector = con; InObjectProcess.GPIOObject = obj; ev.GPIOOutputs.Add(OutObjectProcess); ev.GPIOInputs.Add(InObjectProcess); ev.AccessRights = 0x1; m_EventQueue.Enqueue(ev); } } } } }); }
public GPIOEnvironmentConnector(string hostName, int Port) { m_HostName = hostName; m_Port = Port; m_GPIOOutPutServiceConnectorConfig = new PropertySet(); m_GPIOInputServiceConnectorConfig = new PropertySet(); m_GPIOConnector = new GPIOConnector(); m_GPIOInOutBanks = null; m_ActiveGPIOInOutBanks = null; m_OutPuts = null; m_Inputs = null; m_ActiveOutPuts = null; m_ActiveInputs = null; m_GPIOConnectorEnable = false; m_GPIOConnecorInitialized = false; }
public void resetAllOutputs() { if (m_GPIOConnectorEnable && m_GPIOConnecorInitialized) { UpdateState(0); GPIOOBank bank = m_OutPuts; foreach (GPIOObjects OutPuts in bank.GPIOBanks) { foreach (GPIOObject OutPut in OutPuts.GPIOs) { OutPut.SetValue = OutPut.InitValue; double PulseTime = OutPut.PulseTime; // save pulseTime OutPut.PulseTime = 0; // pulsetime set to 0 OutPut.IsFlankActive = true; // Active set UpdateInputPropertySets(OutPut); OutPut.IsFlankActive = false; OutPut.PulseTime = PulseTime; // store back PulseTime } } UpdateState(1); } }
/* * public IList<ConfigProcessItem> ProcessItems * { * get * { * return m_ProcessItems; * } * * * } */ public bool createProcessEvents(IList <ProcessGPIOEvents> processGPIOEvents) { processGPIOEvents.Clear(); ProcessGPIOEvents processGPIOEvent; var map = new Dictionary <string, ProcessGPIOEvents>(); foreach (GPIOEnvironmentConnector con in m_GPIOEnvironmentConnectors.EnvironmentConnectors) { var m_InOutBanks = con.ActiveGPIOInOutBanks.InOutBanks; for (int i = 0; i < m_InOutBanks.Count; i++) { GPIOOBank bank = m_InOutBanks[i]; foreach (GPIOObjects OutPuts in bank.GPIOBanks) { foreach (GPIOObject GPIOObj in OutPuts.GPIOs) { if (GPIOObj.IsEnabled && GPIOObj.IsEventEnabled) { string eventName = GPIOObj.EventName; eventName = Regex.Replace(eventName, @"\s", "");//remove with spaces string eventKey; GPIOObject.GPIOTyp type = GPIOObj.GPIOtyp; string[] array = eventName.Split("."); if (array.Length > 1) { eventKey = array[0]; if (array[1].Equals("output", StringComparison.InvariantCultureIgnoreCase)) { type = GPIOObject.GPIOTyp.output; } if (array[1].Equals("input", StringComparison.InvariantCultureIgnoreCase)) { type = GPIOObject.GPIOTyp.input; } } else { eventKey = eventName; } bool containsKey = map.TryGetValue(eventKey, out processGPIOEvent); if (processGPIOEvent == null) { processGPIOEvent = new ProcessGPIOEvents(eventKey); map[eventKey] = processGPIOEvent; //processGPIOEvent.AccessRights = GPIOObj.EventAccessRights; processGPIOEvents.Add(processGPIOEvent); } switch (type) { case GPIOObject.GPIOTyp.output: { //output object determines Access rights // GPIOOProcessItem gPIOOProcessItem = new GPIOOProcessItem(eventKey); GPIOObjectProcess OutObjectProcess = new GPIOObjectProcess(); OutObjectProcess.GPIOEnvironmentConnector = con; OutObjectProcess.GPIOObject = GPIOObj; processGPIOEvent.AccessRights = GPIOObj.EventAccessRights; processGPIOEvent.GPIOOutputs.Add(OutObjectProcess); break; } case GPIOObject.GPIOTyp.input: { // GPIOOProcessItem gPIOOProcessItem = new GPIOOProcessItem(eventKey); GPIOObjectProcess OutObjectProcess = new GPIOObjectProcess(); OutObjectProcess.GPIOEnvironmentConnector = con; OutObjectProcess.GPIOObject = GPIOObj; processGPIOEvent.GPIOInputs.Add(OutObjectProcess); break; } } } } } } } return(processGPIOEvents.Count > 0); }
static GPIOOInOutBanks Allocate(IPropertySet property) { GPIOOInOutBanks m_GPIOInOutBanks = new GPIOOInOutBanks(""); // m_Banks = new List<GPIOOBank>(); GPIOOBank m_OutPuts = new GPIOOBank("Outputs"); GPIOOBank m_Inputs = new GPIOOBank("Inputs"); // ObservableCollection<GPIOObjects>m_GPIOOutputs = new ObservableCollection<GPIOObjects>(); GPIOObjects m_GPIOOutPut5V = new GPIOObjects("GPIOOutPut.5V"); m_GPIOOutPut5V.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.output, 17, 0, 0)); m_GPIOOutPut5V.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.output, 27, 0, 0)); m_GPIOOutPut5V.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.output, 23, 0, 0)); m_GPIOOutPut5V.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.output, 22, 0, 0)); GPIOObjects m_GPIOOutPut3V3 = new GPIOObjects("GPIOOutPut.3V3"); m_GPIOOutPut3V3.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.output, 13, 0, 0)); m_GPIOOutPut3V3.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.output, 19, 0, 0)); m_GPIOOutPut3V3.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.output, 11, 0, 0)); m_GPIOOutPut3V3.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.output, 21, 0, 0)); GPIOObjects m_GPIOOutPutOC = new GPIOObjects("GPIOOutPut.OpenCol. "); m_GPIOOutPutOC.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.output, 4, 0, 0)); m_GPIOOutPutOC.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.output, 10, 0, 0)); m_GPIOOutPutOC.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.output, 9, 0, 0)); m_GPIOOutPutOC.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.output, 16, 0, 0)); m_OutPuts.GPIOBanks.Add(m_GPIOOutPut5V); m_OutPuts.GPIOBanks.Add(m_GPIOOutPut3V3); m_OutPuts.GPIOBanks.Add(m_GPIOOutPutOC); GPIOObjects GPIOInputs5V = new GPIOObjects("GPIOInputs.4Bank"); GPIOInputs5V.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.input, 15, 0, 0)); GPIOInputs5V.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.input, 14, 0, 0)); GPIOInputs5V.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.input, 12, 0, 0)); GPIOInputs5V.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.input, 20, 0, 0)); GPIOObjects GPIOInputs5V8 = new GPIOObjects("GPIOInputs.8Bank"); GPIOInputs5V8.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.input, 26, 0, 0)); GPIOInputs5V8.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.input, 25, 0, 0)); GPIOInputs5V8.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.input, 24, 0, 0)); GPIOInputs5V8.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.input, 5, 0, 0)); GPIOObjects GPIOInputs5V4 = new GPIOObjects("GPIOInputs.8Bank"); GPIOInputs5V4.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.input, 6, 0, 0)); GPIOInputs5V4.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.input, 7, 0, 0)); GPIOInputs5V4.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.input, 8, 0, 0)); GPIOInputs5V4.GPIOs.Add(new GPIOObject("GPIO", GPIOObject.GPIOTyp.input, 18, 0, 0)); m_Inputs.GPIOBanks.Add(GPIOInputs5V); m_Inputs.GPIOBanks.Add(GPIOInputs5V8); m_Inputs.GPIOBanks.Add(GPIOInputs5V4); m_GPIOInOutBanks.InOutBanks.Add(m_Inputs); m_GPIOInOutBanks.InOutBanks.Add(m_OutPuts); m_GPIOInOutBanks.createPropertySet(property); return(m_GPIOInOutBanks); }