Exemplo n.º 1
0
        private void LoadConfigToDevice(Device dev)
        {
            int devAddr = IndexForHostDevice();


            //Reload properties and actions if they changed


            //Update

            int inputs = site.siteCfg.deviceConfigs[devAddr].memCFG[ipcDefines.mAdrInputsNO];

            for (int i = 0; i < inputs; i++)
            {
                DeviceProperty prop = new DeviceProperty();
                prop.PropertyName = "Input" + i;    //TODO read from name cfg
                DeviceParameter   param = new DeviceParameter();
                sconnConfigMapper maper = new sconnConfigMapper();
                maper.ConfigType  = ipcDefines.mAdrInput;
                maper.SeqNumber   = i;
                param.sconnMapper = maper;
                param.Value       = sconnConfigToStringVal(maper, site.siteCfg.deviceConfigs[devAddr]);
                prop.ResultParameters.Add(param);
                dev.Properties.Add(prop);
            }

            int outputs = site.siteCfg.deviceConfigs[devAddr].memCFG[ipcDefines.mAdrOutputsNO];

            for (int i = 0; i < outputs; i++)
            {
                DeviceAction action = new DeviceAction();
                action.ActionName = "Output" + i;    //TODO read from name cfg
                DeviceParameter inparam = new DeviceParameter();
                //DeviceParameter outparam = new DeviceParameter();
                sconnConfigMapper maper = new sconnConfigMapper();
                maper.ConfigType    = ipcDefines.mAdrOutput;
                maper.SeqNumber     = i;
                inparam.sconnMapper = maper;
                inparam.Value       = sconnConfigToStringVal(maper, site.siteCfg.deviceConfigs[devAddr]);
                action.ResultParameters.Add(inparam);
                dev.Actions.Add(action);
            }

            int relays = site.siteCfg.deviceConfigs[devAddr].memCFG[ipcDefines.mAdrRelayNO];

            for (int i = 0; i < relays; i++)
            {
                DeviceAction action = new DeviceAction();
                action.ActionName = "Relay" + i;    //TODO read from name cfg
                DeviceParameter inparam = new DeviceParameter();
                //DeviceParameter outparam = new DeviceParameter();
                sconnConfigMapper maper = new sconnConfigMapper();
                maper.ConfigType    = ipcDefines.mAdrRelay;
                maper.SeqNumber     = i;
                inparam.sconnMapper = maper;
                inparam.Value       = sconnConfigToStringVal(maper, site.siteCfg.deviceConfigs[devAddr]);
                action.ResultParameters.Add(inparam);
                dev.Actions.Add(action);
            }
        }
Exemplo n.º 2
0
 private void SetConfigForActionParameterAtDevice(DeviceParameter param, ipcDataType.ipcDeviceConfig config)
 {
     config.memCFG = LoadStringValueToMemoryAtAddr(param.Value, config.memCFG, ConfigAddrForMapperInfo(param.sconnMapper));
 }