private void K_S2_Init() { log.Debug("K_S2_Init"); Filelist = new filelist(); Parameter = new parameter(); CameraIP = "192.168.0.1"; simCamera = false; }
/// <summary> /// Set a parameter at K-S2 /// </summary> /// <param name="param">empty string for green Button or something like av=4.0, tv=1.160 etc... look at class parameter </param> /// <returns>success or not</returns> public bool SetParameter(string param = "") //Default = Green Button { bool ret = false; try { string url = String.Format(urlSetParam, CameraIP); string postContent = param; if (simCamera) { Content = File.ReadAllText(@"simfiles\setparam.txt"); ErrCode = ""; } else { http.HttpSend(url, "PUT", postContent, out Content, out ErrCode); } if (!String.IsNullOrEmpty(ErrCode)) { throw new Exception(ErrCode); } else { parameter pm = http.JsonDeserialize <parameter>(Content); SetParameterIfNotNull(pm); } ret = true; LastErrorStr = ""; } catch (Exception ex) { if (ex.InnerException == null) { LastErrorStr = String.Format("Error SetParameter: {0}", ex.Message); } else { LastErrorStr = String.Format("Error SetParameter: {0}, InnerEx: {1}", ex.Message, ex.InnerException.Message); } log.Error(LastErrorStr); ret = false; } return(ret); }
/// <summary> /// Get all Parameter from K-S2. Includes List of possible Parameters /// </summary> /// <returns>success or not</returns> public bool GetParameter() { bool ret = false; try { string url = String.Format(urlGetParam, CameraIP); if (simCamera) { Content = File.ReadAllText(@"simfiles\parameter.txt"); ErrCode = ""; } else { http.HttpSend(url, "GET", "", out Content, out ErrCode); } if (!String.IsNullOrEmpty(ErrCode)) { throw new Exception(ErrCode); } else { Parameter = http.JsonDeserialize <parameter>(Content); } ret = true; LastErrorStr = ""; } catch (Exception ex) { if (ex.InnerException == null) { LastErrorStr = String.Format("Error GetParameter: {0}", ex.Message); } else { LastErrorStr = String.Format("Error GetParameter: {0}, InnerEx: {1}", ex.Message, ex.InnerException.Message); } log.Error(LastErrorStr); ret = false; } return(ret); }
/// <summary> /// Set all values of all Controls from the parameter class /// </summary> /// <param name="parameter"></param> private void UpdateParameter(PtxK_S2.parameter parameter) { //TODO: Obsolete, because done already in ks2? propsset = true; cbAv.DataSource = parameter.avList; cbAv.Text = parameter.av; cbTv.DataSource = parameter.tvList; cbTv.Text = parameter.tv; cbSv.DataSource = parameter.svList; cbSv.Text = parameter.sv; cbXv.DataSource = parameter.xvList; cbXv.Text = parameter.xv; if ((parameter.WBModeList != null) && (parameter.WBModeList.Count > 0)) { cbWB.DataSource = parameter.WBModeList; cbShootMode.DataSource = parameter.shootModeList; cbExposureMode.DataSource = parameter.exposureModeList; cbStillSize.DataSource = parameter.stillSizeList; cbMovieSize.DataSource = parameter.movieSizeList; cbEffect.DataSource = parameter.effectList; cbFilter.DataSource = parameter.filterList; lModel.Text = parameter.model; lFirmware.Text = parameter.firmwareVersion; lMACAddr.Text = parameter.macAddress; lSN.Text = parameter.serialNo; lSSID.Text = parameter.ssid; lKey.Text = parameter.key; lChannel.Text = parameter.channel; //TODO: Channellist lLiveState.Text = parameter.liveState; } cbWB.Text = parameter.WBMode; cbShootMode.Text = parameter.shootMode; cbExposureMode.Text = parameter.exposureMode; cbStillSize.Text = parameter.stillSize; cbMovieSize.Text = parameter.movieSize; cbEffect.Text = parameter.effect; cbFilter.Text = parameter.filter; propsset = false; }
/// <summary> /// Update the parameter var with param, if not null /// </summary> /// <param name="param">the new parameter var</param> private void SetParameterIfNotNull(parameter param) { //returncodes Parameter.errCode = param.errCode; Parameter.errMsg = param.errMsg; //Lists of possible parameters if (param.avList != null) { Parameter.avList = param.avList; } if (param.tvList != null) { Parameter.tvList = param.tvList; } if (param.svList != null) { Parameter.svList = param.svList; } if (param.xvList != null) { Parameter.xvList = param.xvList; } if (param.effectList != null) { Parameter.effectList = param.effectList; } if (param.exposureModeList != null) { Parameter.exposureModeList = param.exposureModeList; } if (param.filterList != null) { Parameter.filterList = param.filterList; } if (param.movieResoList != null) { Parameter.movieResoList = param.movieResoList; } if (param.movieSizeList != null) { Parameter.movieSizeList = param.movieSizeList; } if (param.resoList != null) { Parameter.resoList = param.resoList; } if (param.stillSizeList != null) { Parameter.stillSizeList = param.stillSizeList; } if (param.WBModeList != null) { Parameter.WBModeList = param.WBModeList; } if (param.shootModeList != null) { Parameter.shootModeList = param.shootModeList; } //Picture parameter if (param.av != null) { Parameter.av = param.av; } if (param.tv != null) { Parameter.tv = param.tv; } if (param.sv != null) { Parameter.sv = param.sv; } if (param.xv != null) { Parameter.xv = param.xv; } if (param.effect != null) { Parameter.effect = param.effect; } if (param.exposureMode != null) { Parameter.exposureMode = param.exposureMode; } if (param.exposureModeOption != null) { Parameter.exposureModeOption = param.exposureModeOption; } if (param.filter != null) { Parameter.filter = param.filter; } if (param.focusCenters != null) { Parameter.focusCenters = param.focusCenters; } Parameter.focused = param.focused; if (param.focusMode != null) { Parameter.focusMode = param.focusMode; } if (param.liveState != null) { Parameter.liveState = param.liveState; } if (param.movieSize != null) { Parameter.movieSize = param.movieSize; } if (param.shootMode != null) { Parameter.shootMode = param.shootMode; } if (param.state != null) { Parameter.state = param.state; } if (param.stillSize != null) { Parameter.stillSize = param.stillSize; } if (param.WBMode != null) { Parameter.WBMode = param.WBMode; } //Storage information if (param.storages != null) { Parameter.storages = param.storages; } //Camera information if (param.serialNo != null) { Parameter.serialNo = param.serialNo; } if (param.firmwareVersion != null) { Parameter.firmwareVersion = param.firmwareVersion; } if (param.macAddress != null) { Parameter.macAddress = param.macAddress; } if (param.model != null) { Parameter.model = param.model; } Parameter.hot = param.hot; Parameter.battery = param.battery; //WLAN if (param.channel != null) { Parameter.channel = param.channel; } if (param.channelList != null) { Parameter.channelList = param.channelList; } if (param.ssid != null) { Parameter.ssid = param.ssid; } if (param.key != null) { Parameter.key = param.key; } }
/// <summary> /// Update the parameter var with param, if not null /// </summary> /// <param name="param">the new parameter var</param> private void SetParameterIfNotNull(parameter param) { //returncodes Parameter.errCode = param.errCode; Parameter.errMsg = param.errMsg; //Lists of possible parameters if (param.avList != null) Parameter.avList = param.avList; if (param.tvList != null) Parameter.tvList = param.tvList; if (param.svList != null) Parameter.svList = param.svList; if (param.xvList != null) Parameter.xvList = param.xvList; if (param.effectList != null) Parameter.effectList = param.effectList; if (param.exposureModeList != null) Parameter.exposureModeList = param.exposureModeList; if (param.filterList != null) Parameter.filterList = param.filterList; if (param.movieResoList != null) Parameter.movieResoList = param.movieResoList; if (param.movieSizeList != null) Parameter.movieSizeList = param.movieSizeList; if (param.resoList != null) Parameter.resoList = param.resoList; if (param.stillSizeList != null) Parameter.stillSizeList = param.stillSizeList; if (param.WBModeList != null) Parameter.WBModeList = param.WBModeList; if (param.shootModeList != null) Parameter.shootModeList = param.shootModeList; //Picture parameter if (param.av != null) Parameter.av = param.av; if (param.tv != null) Parameter.tv = param.tv; if (param.sv != null) Parameter.sv = param.sv; if (param.xv != null) Parameter.xv = param.xv; if (param.effect != null) Parameter.effect = param.effect; if (param.exposureMode != null) Parameter.exposureMode = param.exposureMode; if (param.exposureModeOption != null) Parameter.exposureModeOption = param.exposureModeOption; if (param.filter != null) Parameter.filter = param.filter; if (param.focusCenters != null) Parameter.focusCenters = param.focusCenters; Parameter.focused = param.focused; if (param.focusMode != null) Parameter.focusMode = param.focusMode; if (param.liveState != null) Parameter.liveState = param.liveState; if (param.movieSize != null) Parameter.movieSize = param.movieSize; if (param.shootMode != null) Parameter.shootMode = param.shootMode; if (param.state != null) Parameter.state = param.state; if (param.stillSize != null) Parameter.stillSize = param.stillSize; if (param.WBMode != null) Parameter.WBMode = param.WBMode; //Storage information if (param.storages != null) Parameter.storages = param.storages; //Camera information if (param.serialNo != null) Parameter.serialNo = param.serialNo; if (param.firmwareVersion != null) Parameter.firmwareVersion = param.firmwareVersion; if (param.macAddress != null) Parameter.macAddress = param.macAddress; if (param.model != null) Parameter.model = param.model; Parameter.hot = param.hot; Parameter.battery = param.battery; //WLAN if (param.channel != null) Parameter.channel = param.channel; if (param.channelList != null) Parameter.channelList = param.channelList; if (param.ssid != null) Parameter.ssid = param.ssid; if (param.key != null) Parameter.key = param.key; }
/// <summary> /// Get all Parameter from K-S2. Includes List of possible Parameters /// </summary> /// <returns>success or not</returns> public bool GetParameter() { bool ret = false; try { string url = String.Format(urlGetParam, CameraIP); if (simCamera) { Content = File.ReadAllText(@"simfiles\parameter.txt"); ErrCode = ""; } else { http.HttpSend(url, "GET", "", out Content, out ErrCode); } if (!String.IsNullOrEmpty(ErrCode)) { throw new Exception(ErrCode); } else { Parameter = http.JsonDeserialize<parameter>(Content); } ret = true; LastErrorStr = ""; } catch (Exception ex) { if (ex.InnerException == null) LastErrorStr = String.Format("Error GetParameter: {0}", ex.Message); else LastErrorStr = String.Format("Error GetParameter: {0}, InnerEx: {1}", ex.Message, ex.InnerException.Message); log.Error(LastErrorStr); ret = false; } return ret; }