// PUT: api/TestInput/5 public HttpResponseMessage Put(int id, HttpRequestMessage request) { try { if (id == 0) { PLCInput plcInput = new PLCInput(); string json = request.Content.ReadAsStringAsync().Result; //string json_minified = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(json), Formatting.None); plcInput = JsonConvert.DeserializeObject <PLCInput>(json); //plcInput = json_array.ToObject<PLCInput>(); dbClient.UpdatePLCInput(plcInput); } return(new HttpResponseMessage(HttpStatusCode.OK)); } catch (Exception ex) { return(new HttpResponseMessage(HttpStatusCode.Conflict)); } //id = 5b4fa581dae6883fe0efc663 //return; //var a = value; //return a; }
public void UpdatePLCInput(PLCInput plcInput) { var collection = _database.GetCollection <BsonDocument>("PLC_inputs"); // var filter = Builders<BsonDocument>.Filter.Eq("id", plcInput.id); var filter = Builders <BsonDocument> .Filter.Eq("_id", new ObjectId(plcInput.id)); var update = Builders <BsonDocument> .Update.Set("iPLC_STATUS", plcInput.iPLC_STATUS); //.Set("input_int", plcInput.input_int); //var update = Builders<BsonDocument>.Update.Set("order_status", order.order_status); var result = collection.UpdateMany(filter, update); }
public List <PLCInput> GetPLCInputs() { List <PLCInput> _plcInputs = new List <PLCInput>(); var collection = _database.GetCollection <BsonDocument>("PLC_inputs"); var filter = new BsonDocument(); var results = collection.Find(filter).Limit(100).ToList(); if (results.Count > 0) { foreach (var result in results) { PLCInput plcInput = new PLCInput(result); _plcInputs.Add(plcInput); } } return(_plcInputs); }
void WriteItems(OPCGroup ObjOPCGroup) { try { while (!stopThreads) { if (Workflow.plcInputs != null && Workflow.plcInputs.Count > 0) { CurrentPLCInput = Workflow.plcInputs.First(); if (previousPLCInput == null || !previousPLCInput.Equals(CurrentPLCInput)) { int index = Globals.INPUT_TAGS.FirstOrDefault(x => x.Name == "iPLC_STATUS").Index; ItemServerWriteValues.SetValue(CurrentPLCInput.iPlc_Status, index); // ItemServerWriteValues.SetValue(CurrentTestInput.input_bool, 1); // ItemServerWriteValues.SetValue(CurrentTestInput.input_int, 2); try { ObjOPCGroup.SyncWrite(tagIndexWriter - 1, ref writerItemServerHandles, ref ItemServerWriteValues, out writerItemServerErrors); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } previousPLCInput = CurrentPLCInput; } } //ItemServerWriteValues.SetValue(1.1, Array.IndexOf(OPCItemIDs,(object)("Bucket Brigade.Real1"))); System.Threading.Thread.Sleep(1000); } } catch (Exception ex) { Console.Write(ex.Message); throw; } }
//// GET: api/TestInput/5 //public TestInput Get(string _id) //{ // ObjectId id = ObjectId.Parse(_id); // return dbClient.testInputs.Where(x => x.id == id).First(); //} // POST: api/TestInput public void Post(PLCInput plcInput) { dbClient.InsertPLCInput(plcInput); }
public void updatePLCInput(PLCInput plcInput) { var collection = _database.GetCollection <BsonDocument>("PLC_inputs"); var filter = Builders <BsonDocument> .Filter.Eq("id", plcInput.id); }
internal void InsertPLCInput(PLCInput pLCInput) { throw new NotImplementedException(); }